diff --git a/Apps/CesiumViewer/CesiumViewer.js b/Apps/CesiumViewer/CesiumViewer.js index 8522ad4e3e6b..65b99578eced 100644 --- a/Apps/CesiumViewer/CesiumViewer.js +++ b/Apps/CesiumViewer/CesiumViewer.js @@ -9,6 +9,7 @@ define([ 'Widgets/Viewer/Viewer', 'Widgets/Viewer/viewerDragDropMixin', 'Widgets/Viewer/viewerDynamicObjectMixin', + 'Widgets/Viewer/viewerCesiumInspectorMixin', 'domReady!' ], function( defined, @@ -19,7 +20,8 @@ define([ checkForChromeFrame, Viewer, viewerDragDropMixin, - viewerDynamicObjectMixin) { + viewerDynamicObjectMixin, + viewerCesiumInspectorMixin) { "use strict"; /*global console*/ @@ -70,6 +72,9 @@ define([ var viewer = new Viewer('cesiumContainer'); viewer.extend(viewerDragDropMixin); viewer.extend(viewerDynamicObjectMixin); + if (endUserOptions.inspector) { + viewer.extend(viewerCesiumInspectorMixin); + } var showLoadError = function(name, error) { var title = 'An error occurred while loading the file: ' + name; @@ -83,7 +88,7 @@ define([ }); var scene = viewer.scene; - var context = scene.getContext(); + var context = scene.context; if (endUserOptions.debug) { context.setValidateShaderProgram(true); context.setValidateFramebuffer(true); diff --git a/Apps/Sandcastle/gallery/Animations.html b/Apps/Sandcastle/gallery/Animations.html index 2f7231b4d399..2b913d32acd4 100644 --- a/Apps/Sandcastle/gallery/Animations.html +++ b/Apps/Sandcastle/gallery/Animations.html @@ -32,12 +32,12 @@ function addAlphaAnimation(primitive, scene) { Sandcastle.declare(addAlphaAnimation); // For highlighting in Sandcastle. - scene.getAnimations().addAlpha(primitive.material, 0.0, 0.5); + scene.animations.addAlpha(primitive.material, 0.0, 0.5); } function addStripeAnimation(primitive, scene) { Sandcastle.declare(addStripeAnimation); // For highlighting in Sandcastle. - scene.getAnimations().addOffsetIncrement(primitive.material); + scene.animations.addOffsetIncrement(primitive.material); } function resetExtentPropeties(extent) { @@ -46,9 +46,9 @@ } function createPrimitives(widget) { - var ellipsoid = widget.centralBody.getEllipsoid(); + var ellipsoid = widget.centralBody.ellipsoid; var scene = widget.scene; - var primitives = scene.getPrimitives(); + var primitives = scene.primitives; extent = new Cesium.ExtentPrimitive({ extent : new Cesium.Extent( @@ -86,14 +86,14 @@ createPrimitives(widget); Sandcastle.addToolbarButton('Alpha Animation', function() { - scene.getAnimations().removeAll(); + scene.animations.removeAll(); resetExtentPropeties(extent); addAlphaAnimation(extent, scene); Sandcastle.highlight(addAlphaAnimation); }); Sandcastle.addToolbarButton('Stripe Animation', function() { - scene.getAnimations().removeAll(); + scene.animations.removeAll(); addStripeAnimation(rectangularSensor, scene); Sandcastle.highlight(addStripeAnimation); }); diff --git a/Apps/Sandcastle/gallery/Billboards.html b/Apps/Sandcastle/gallery/Billboards.html index ee76cbc16da4..8c27b7e4309d 100644 --- a/Apps/Sandcastle/gallery/Billboards.html +++ b/Apps/Sandcastle/gallery/Billboards.html @@ -32,7 +32,7 @@ var image = new Image(); image.onload = function() { var billboards = new Cesium.BillboardCollection(); - var textureAtlas = scene.getContext().createTextureAtlas({ + var textureAtlas = scene.context.createTextureAtlas({ image : image }); billboards.setTextureAtlas(textureAtlas); @@ -41,7 +41,7 @@ position : ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-75.59777, 40.03883)), imageIndex : 0 }); - scene.getPrimitives().add(billboards); + scene.primitives.add(billboards); }; image.src = '../images/Cesium_Logo_overlay.png'; } @@ -51,7 +51,7 @@ var image = new Image(); image.onload = function() { var billboards = new Cesium.BillboardCollection(); - var textureAtlas = scene.getContext().createTextureAtlas({ + var textureAtlas = scene.context.createTextureAtlas({ image : image }); billboards.setTextureAtlas(textureAtlas); @@ -71,7 +71,7 @@ width : 100, // default: undefined height : 25 // default: undefined }); - scene.getPrimitives().add(billboards); + scene.primitives.add(billboards); }; image.src = '../images/Cesium_Logo_overlay.png'; } @@ -81,7 +81,7 @@ var image = new Image(); image.onload = function() { var billboards = new Cesium.BillboardCollection(); - var textureAtlas = scene.getContext().createTextureAtlas({ + var textureAtlas = scene.context.createTextureAtlas({ image : image }); billboards.setTextureAtlas(textureAtlas); @@ -97,7 +97,7 @@ b.setScale(3.0); b.setColor(new Cesium.Color(1.0, 1.0, 1.0, 0.25)); - scene.getPrimitives().add(billboards); + scene.primitives.add(billboards); }; image.src = '../images/Cesium_Logo_overlay.png'; } @@ -115,7 +115,7 @@ // references an image in the texture atlas. var billboards = new Cesium.BillboardCollection(); - var textureAtlas = scene.getContext().createTextureAtlas({ + var textureAtlas = scene.context.createTextureAtlas({ images : images }); billboards.setTextureAtlas(textureAtlas); @@ -138,7 +138,7 @@ imageIndex : 1 }); - scene.getPrimitives().add(billboards); + scene.primitives.add(billboards); }); } @@ -147,7 +147,7 @@ var image = new Image(); image.onload = function() { var billboards = new Cesium.BillboardCollection(); - var textureAtlas = scene.getContext().createTextureAtlas({ + var textureAtlas = scene.context.createTextureAtlas({ image : image }); billboards.setTextureAtlas(textureAtlas); @@ -157,7 +157,7 @@ imageIndex : 0, scaleByDistance : new Cesium.NearFarScalar(1.5e2, 2.0, 1.5e7, 0.5) }); - scene.getPrimitives().add(billboards); + scene.primitives.add(billboards); }; image.src = '../images/facility.gif'; } @@ -167,7 +167,7 @@ var image = new Image(); image.onload = function() { var billboards = new Cesium.BillboardCollection(); - var textureAtlas = scene.getContext().createTextureAtlas({ + var textureAtlas = scene.context.createTextureAtlas({ image : image }); billboards.setTextureAtlas(textureAtlas); @@ -177,7 +177,7 @@ imageIndex : 0, translucencyByDistance : new Cesium.NearFarScalar(1.5e2, 1.0, 1.5e7, 0.2) }); - scene.getPrimitives().add(billboards); + scene.primitives.add(billboards); }; image.src = '../images/Cesium_Logo_overlay.png'; } @@ -191,7 +191,7 @@ ], function(images) { var billboards = new Cesium.BillboardCollection(); - var textureAtlas = scene.getContext().createTextureAtlas({ + var textureAtlas = scene.context.createTextureAtlas({ images : images }); billboards.setTextureAtlas(textureAtlas); @@ -216,7 +216,7 @@ pixelOffsetScaleByDistance : new Cesium.NearFarScalar(1.0e3, 1.0, 1.5e6, 0.0), translucencyByDistance : new Cesium.NearFarScalar(1.0e3, 1.0, 1.5e6, 0.1) }); - scene.getPrimitives().add(billboards); + scene.primitives.add(billboards); }); } @@ -239,7 +239,7 @@ context2D.fill(); var billboards = new Cesium.BillboardCollection(); - var textureAtlas = scene.getContext().createTextureAtlas({ + var textureAtlas = scene.context.createTextureAtlas({ image : canvas }); billboards.setTextureAtlas(textureAtlas); @@ -264,7 +264,7 @@ imageIndex : 0 }); - scene.getPrimitives().add(billboards); + scene.primitives.add(billboards); } function addMarkerBillboards(scene, ellipsoid) { @@ -272,7 +272,7 @@ var image = new Image(); image.onload = function() { var billboards = new Cesium.BillboardCollection(); - var textureAtlas = scene.getContext().createTextureAtlas({ + var textureAtlas = scene.context.createTextureAtlas({ borderWidthInPixels : 0 }); @@ -361,7 +361,7 @@ scale : 1, color : Cesium.Color.YELLOW }); - scene.getPrimitives().add(billboards); + scene.primitives.add(billboards); }; image.src = '../images/whiteShapes.png'; } @@ -371,7 +371,7 @@ var image = new Image(); image.onload = function() { var billboards = new Cesium.BillboardCollection(); - var textureAtlas = scene.getContext().createTextureAtlas({ + var textureAtlas = scene.context.createTextureAtlas({ image : image }); billboards.setTextureAtlas(textureAtlas); @@ -398,16 +398,16 @@ imageIndex : 0, position : new Cesium.Cartesian3(0.0, 0.0, 1000000.0) }); - scene.getPrimitives().add(billboards); + scene.primitives.add(billboards); }; image.src = '../images/facility.gif'; } var widget = new Cesium.CesiumWidget('cesiumContainer'); - var ellipsoid = widget.centralBody.getEllipsoid(); + var ellipsoid = widget.centralBody.ellipsoid; var scene = widget.scene; - var primitives = scene.getPrimitives(); + var primitives = scene.primitives; addBillboard(scene, ellipsoid); diff --git a/Apps/Sandcastle/gallery/Box Outline.html b/Apps/Sandcastle/gallery/Box Outline.html index f55e2f76fd4b..3672a3944bac 100644 --- a/Apps/Sandcastle/gallery/Box Outline.html +++ b/Apps/Sandcastle/gallery/Box Outline.html @@ -29,8 +29,8 @@ var viewer = new Cesium.Viewer('cesiumContainer'); var scene = viewer.scene; - var primitives = scene.getPrimitives(); - var ellipsoid = viewer.centralBody.getEllipsoid(); + var primitives = scene.primitives; + var ellipsoid = viewer.centralBody.ellipsoid; var dimensions = new Cesium.Cartesian3(400000.0, 400000.0, 400000.0); var positionOnEllipsoid = ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-106.0, 45.0)); @@ -57,7 +57,7 @@ depthTest : { enabled : true }, - lineWidth : Math.min(1.0, scene.getContext().getMaximumAliasedLineWidth()) + lineWidth : Math.min(1.0, scene.context.getMaximumAliasedLineWidth()) } }) })); diff --git a/Apps/Sandcastle/gallery/Box.html b/Apps/Sandcastle/gallery/Box.html index 960882b6782e..408096ee5827 100644 --- a/Apps/Sandcastle/gallery/Box.html +++ b/Apps/Sandcastle/gallery/Box.html @@ -28,8 +28,8 @@ "use strict"; var viewer = new Cesium.Viewer('cesiumContainer'); - var primitives = viewer.scene.getPrimitives(); - var ellipsoid = viewer.centralBody.getEllipsoid(); + var primitives = viewer.scene.primitives; + var ellipsoid = viewer.centralBody.ellipsoid; // Create box and position with a model matrix var dimensions = new Cesium.Cartesian3(400000.0, 300000.0, 500000.0); diff --git a/Apps/Sandcastle/gallery/CZML.html b/Apps/Sandcastle/gallery/CZML.html index e4d4097c2291..539759944a19 100644 --- a/Apps/Sandcastle/gallery/CZML.html +++ b/Apps/Sandcastle/gallery/CZML.html @@ -142,7 +142,7 @@ // Zoom in a little closer... var extent = new Cesium.Extent(-2.056, 0.587, -2.010, 0.633); - viewer.scene.getCamera().controller.viewExtent(extent); + viewer.scene.camera.controller.viewExtent(extent); } var viewer = new Cesium.Viewer('cesiumContainer'); diff --git a/Apps/Sandcastle/gallery/Camera Tutorial.html b/Apps/Sandcastle/gallery/Camera Tutorial.html index 1b6b9525b139..e16a8e6e22d4 100644 --- a/Apps/Sandcastle/gallery/Camera Tutorial.html +++ b/Apps/Sandcastle/gallery/Camera Tutorial.html @@ -60,7 +60,7 @@ negativeZ : skyBoxBaseUrl + '_mz.jpg' }); - var primitives = scene.getPrimitives(); + var primitives = scene.primitives; // Bing Maps var bing = new Cesium.BingMapsImageryProvider({ @@ -73,18 +73,18 @@ var ellipsoid = Cesium.Ellipsoid.WGS84; var centralBody = new Cesium.CentralBody(ellipsoid); - centralBody.getImageryLayers().addImageryProvider(bing); + centralBody.imageryLayerCollection.addImageryProvider(bing); - primitives.setCentralBody(centralBody); + primitives.centralBody = centralBody; var transitioner = new Cesium.SceneTransitioner(scene, ellipsoid); // disable the default event handlers - scene.getScreenSpaceCameraController().enableRotate = false; - scene.getScreenSpaceCameraController().enableTranslate = false; - scene.getScreenSpaceCameraController().enableZoom = false; - scene.getScreenSpaceCameraController().enableTilt = false; - scene.getScreenSpaceCameraController().enableLook = false; + scene.screenSpaceCameraController.enableRotate = false; + scene.screenSpaceCameraController.enableTranslate = false; + scene.screenSpaceCameraController.enableZoom = false; + scene.screenSpaceCameraController.enableTilt = false; + scene.screenSpaceCameraController.enableLook = false; var startMousePosition; var mousePosition; @@ -99,7 +99,7 @@ }; function animate() { - var camera = scene.getCamera(); + var camera = scene.camera; var controller = camera.controller; if (flags.looking) { @@ -213,7 +213,7 @@ canvas.width = width; canvas.height = height; - scene.getCamera().frustum.aspectRatio = width / height; + scene.camera.frustum.aspectRatio = width / height; }; window.addEventListener('resize', onResize, false); onResize(); diff --git a/Apps/Sandcastle/gallery/Camera.html b/Apps/Sandcastle/gallery/Camera.html index 311aff32e25a..863c1f62527e 100644 --- a/Apps/Sandcastle/gallery/Camera.html +++ b/Apps/Sandcastle/gallery/Camera.html @@ -36,7 +36,7 @@ var flight = Cesium.CameraFlightPath.createAnimationCartographic(scene, { destination : destination }); - scene.getAnimations().add(flight); + scene.animations.add(flight); } function flyToMyLocation(scene) { @@ -48,7 +48,7 @@ var flight = Cesium.CameraFlightPath.createAnimation(scene, { destination : destination }); - scene.getAnimations().add(flight); + scene.animations.add(flight); } navigator.geolocation.getCurrentPosition(fly); @@ -62,7 +62,7 @@ var north = Cesium.Math.toRadians(42.0); var extent = new Cesium.Extent(west, south, east, north); - scene.getCamera().controller.viewExtent(extent, ellipsoid); + scene.camera.controller.viewExtent(extent, ellipsoid); // Show the extent. Not required; just for show. var polylines = new Cesium.PolylineCollection(); @@ -76,7 +76,7 @@ new Cesium.Cartographic(west, south) ]) }); - scene.getPrimitives().add(polylines); + scene.primitives.add(polylines); } function flyToExtent(scene) { @@ -91,7 +91,7 @@ var flight = Cesium.CameraFlightPath.createAnimationExtent(scene, { destination : extent }); - scene.getAnimations().add(flight); + scene.animations.add(flight); // Show the extent. Not required; just for show. var polylines = new Cesium.PolylineCollection(); @@ -105,7 +105,7 @@ new Cesium.Cartographic(west, south) ]) }); - scene.getPrimitives().add(polylines); + scene.primitives.add(polylines); } function eastNorthUp(scene) { @@ -114,11 +114,11 @@ var transform = Cesium.Transforms.eastNorthUpToFixedFrame(center); // View in east-north-up frame - var camera = scene.getCamera(); + var camera = scene.camera; camera.transform = transform; camera.controller.constrainedAxis = Cesium.Cartesian3.UNIT_Z; - var controller = scene.getScreenSpaceCameraController(); + var controller = scene.screenSpaceCameraController; controller.setEllipsoid(Cesium.Ellipsoid.UNIT_SPHERE); controller.enableTilt = false; @@ -129,7 +129,7 @@ Cesium.Cartesian3.UNIT_Z); // Show reference frame. Not required. - var primitives = scene.getPrimitives(); + var primitives = scene.primitives; var polylines = new Cesium.PolylineCollection(); polylines.modelMatrix = transform; @@ -164,10 +164,10 @@ } function reset(scene) { - scene.getPrimitives().removeAll(); - scene.getAnimations().removeAll(); + scene.primitives.removeAll(); + scene.animations.removeAll(); - var camera = scene.getCamera(); + var camera = scene.camera; if (camera.transform.equals(Cesium.Matrix4.IDENTITY)) { return; } @@ -175,11 +175,11 @@ camera.transform = Cesium.Matrix4.IDENTITY; camera.controller.constrainedAxis = undefined; camera.controller.lookAt( - Cesium.Cartesian3.multiplyByScalar(Cesium.Cartesian3.normalize(new Cesium.Cartesian3(0.0, -2.0, 1.0)), 2.0 * ellipsoid.getMaximumRadius()), + Cesium.Cartesian3.multiplyByScalar(Cesium.Cartesian3.normalize(new Cesium.Cartesian3(0.0, -2.0, 1.0)), 2.0 * ellipsoid.maximumRadius), Cesium.Cartesian3.ZERO, Cesium.Cartesian3.UNIT_Z); - var controller = scene.getScreenSpaceCameraController(); + var controller = scene.screenSpaceCameraController; controller.setEllipsoid(ellipsoid); controller.enableTilt = true; } diff --git a/Apps/Sandcastle/gallery/Cesium Inspector.html b/Apps/Sandcastle/gallery/Cesium Inspector.html new file mode 100644 index 000000000000..a2dbafcc8ffe --- /dev/null +++ b/Apps/Sandcastle/gallery/Cesium Inspector.html @@ -0,0 +1,105 @@ + + +
+ + + + + +times
and tn
is the last element
* in the array times
.
*/
- Spline.prototype.evaluate = function(time, result) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ Spline.prototype.evaluate = DeveloperError.throwInstantiationError;
/**
* Finds an index i
in times
such that the parameter
diff --git a/Source/Core/TimeIntervalCollection.js b/Source/Core/TimeIntervalCollection.js
index d0af394944b9..8985e75a5c08 100644
--- a/Source/Core/TimeIntervalCollection.js
+++ b/Source/Core/TimeIntervalCollection.js
@@ -2,12 +2,14 @@
define([
'./defined',
'./DeveloperError',
+ './Event',
'./binarySearch',
'./TimeInterval',
'./JulianDate'
], function(
defined,
DeveloperError,
+ Event,
binarySearch,
TimeInterval,
JulianDate) {
@@ -28,6 +30,17 @@ define([
*/
var TimeIntervalCollection = function() {
this._intervals = [];
+ this._intervalsChanged = new Event();
+ };
+
+ /**
+ * Gets an event that is raised whenever the collection of intervals change.
+ * @memberof TimeIntervalCollection
+ *
+ * @returns {Event} The event
+ */
+ TimeIntervalCollection.prototype.getChangedEvent = function() {
+ return this._intervalsChanged;
};
/**
@@ -117,7 +130,10 @@ define([
* @memberof TimeIntervalCollection
*/
TimeIntervalCollection.prototype.clear = function() {
- this._intervals = [];
+ if (this._intervals.length > 0) {
+ this._intervals.length = 0;
+ this._intervalsChanged.raiseEvent(this);
+ }
};
/**
@@ -267,6 +283,7 @@ define([
if (thisIntervals.length === 0 ||
interval.start.greaterThan(thisIntervals[thisIntervals.length - 1].stop)) {
thisIntervals.push(interval);
+ this._intervalsChanged.raiseEvent(this);
return;
}
@@ -382,6 +399,7 @@ define([
// Add the new interval
thisIntervals.splice(index, 0, interval);
+ this._intervalsChanged.raiseEvent(this);
}
};
@@ -489,6 +507,10 @@ define([
thisIntervals[index] = new TimeInterval(intervalStop, indexInterval.stop, !intervalIsStopIncluded, indexInterval.isStopIncluded, indexInterval.data);
}
+ if (result) {
+ this._intervalsChanged.raiseEvent(this);
+ }
+
return result;
};
diff --git a/Source/Core/Transforms.js b/Source/Core/Transforms.js
index 756a3d1aef25..2a6d795bee05 100644
--- a/Source/Core/Transforms.js
+++ b/Source/Core/Transforms.js
@@ -273,7 +273,7 @@ define([
* function updateAndRender() {
* var now = new Cesium.JulianDate();
* scene.initializeFrame();
- * scene.getCamera().transform = Cesium.Matrix4.fromRotationTranslation(Cesium.Transforms.computeTemeToPseudoFixedMatrix(now), Cesium.Cartesian3.ZERO);
+ * scene.camera.transform = Cesium.Matrix4.fromRotationTranslation(Cesium.Transforms.computeTemeToPseudoFixedMatrix(now), Cesium.Cartesian3.ZERO);
* scene.render();
* Cesium.requestAnimationFrame(updateAndRender);
* }
@@ -412,7 +412,7 @@ define([
* scene.initializeFrame();
* var icrfToFixed = Cesium.Transforms.computeIcrfToFixedMatrix(now);
* if (Cesium.defined(icrfToFixed)) {
- * scene.getCamera().transform = Cesium.Matrix4.fromRotationTranslation(icrfToFixed, Cesium.Cartesian3.ZERO);
+ * scene.camera.transform = Cesium.Matrix4.fromRotationTranslation(icrfToFixed, Cesium.Cartesian3.ZERO);
* }
* scene.render();
* Cesium.requestAnimationFrame(updateAndRender);
diff --git a/Source/Core/WallGeometryLibrary.js b/Source/Core/WallGeometryLibrary.js
index 143d8731659d..361443379510 100644
--- a/Source/Core/WallGeometryLibrary.js
+++ b/Source/Core/WallGeometryLibrary.js
@@ -51,7 +51,7 @@ define([
}
function latLonEquals(c0, c1) {
- return ((CesiumMath.equalsEpsilon(c0.latitude, c1.latitude, CesiumMath.EPSILON6)) && (CesiumMath.equalsEpsilon(c0.longitude, c1.longitude, CesiumMath.EPSILON6)));
+ return ((CesiumMath.equalsEpsilon(c0.latitude, c1.latitude, CesiumMath.EPSILON14)) && (CesiumMath.equalsEpsilon(c0.longitude, c1.longitude, CesiumMath.EPSILON14)));
}
var scratchCartographic1 = new Cartographic();
diff --git a/Source/Core/WebMercatorProjection.js b/Source/Core/WebMercatorProjection.js
index 1a761dda5919..64fa69e69e10 100644
--- a/Source/Core/WebMercatorProjection.js
+++ b/Source/Core/WebMercatorProjection.js
@@ -30,7 +30,7 @@ define([
*/
var WebMercatorProjection = function(ellipsoid) {
this._ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);
- this._semimajorAxis = this._ellipsoid.getMaximumRadius();
+ this._semimajorAxis = this._ellipsoid.maximumRadius;
this._oneOverSemimajorAxis = 1.0 / this._semimajorAxis;
};
diff --git a/Source/Core/combine.js b/Source/Core/combine.js
index 3542380aec06..77f55e293712 100644
--- a/Source/Core/combine.js
+++ b/Source/Core/combine.js
@@ -1,17 +1,16 @@
/*global define*/
define([
- './DeveloperError',
'./defaultValue',
'./defined'
], function(
- DeveloperError,
defaultValue,
defined) {
"use strict";
/**
* Merges two objects, copying their properties onto a new combined object. When two objects have the same
- * property, the value of the property on the first object is used.
+ * property, the value of the property on the first object is used. If either object is undefined,
+ * it will be treated as an empty object.
*
* @example
* var object1 = {
@@ -32,8 +31,8 @@ define([
* // }
* // }
*
- * @param {Object} object1 The first object to merge.
- * @param {Object} object2 The second object to merge.
+ * @param {Object} [object1] The first object to merge.
+ * @param {Object} [object2] The second object to merge.
* @param {Boolean} [deep=false] Perform a recursive merge.
*
* @returns {Object} The combined object containing all properties from both objects.
@@ -44,28 +43,35 @@ define([
deep = defaultValue(deep, false);
var result = {};
+
+ var object1Defined = defined(object1);
+ var object2Defined = defined(object2);
var property;
var object1Value;
var object2Value;
- for (property in object1) {
- if (object1.hasOwnProperty(property)) {
- object1Value = object1[property];
- if (deep && typeof object1Value === 'object' && object2.hasOwnProperty(property)) {
- object2Value = object2[property];
- if (typeof object2Value === 'object') {
- result[property] = combine(object1Value, object2Value, deep);
+ if (object1Defined) {
+ for (property in object1) {
+ if (object1.hasOwnProperty(property)) {
+ object1Value = object1[property];
+ if (object2Defined && deep && typeof object1Value === 'object' && object2.hasOwnProperty(property)) {
+ object2Value = object2[property];
+ if (typeof object2Value === 'object') {
+ result[property] = combine(object1Value, object2Value, deep);
+ } else {
+ result[property] = object1Value;
+ }
} else {
result[property] = object1Value;
}
- } else {
- result[property] = object1Value;
}
}
}
- for (property in object2) {
- if (object2.hasOwnProperty(property) && !result.hasOwnProperty(property)) {
- object2Value = object2[property];
- result[property] = object2Value;
+ if (object2Defined) {
+ for (property in object2) {
+ if (object2.hasOwnProperty(property) && !result.hasOwnProperty(property)) {
+ object2Value = object2[property];
+ result[property] = object2Value;
+ }
}
}
return result;
diff --git a/Source/Core/getTimestamp.js b/Source/Core/getTimestamp.js
index 3ab8d090ab30..58f51630983c 100644
--- a/Source/Core/getTimestamp.js
+++ b/Source/Core/getTimestamp.js
@@ -1,9 +1,10 @@
-/*global define,performance*/
+/*global define*/
define([
'./defined'
], function(
defined) {
"use strict";
+ /*global performance*/
/**
* Gets a timestamp that can be used in measuring the time between events. Timestamps
diff --git a/Source/Core/isArray.js b/Source/Core/isArray.js
new file mode 100644
index 000000000000..b5dc2dabd8fd
--- /dev/null
+++ b/Source/Core/isArray.js
@@ -0,0 +1,22 @@
+/*global define*/
+define(['./defined'
+ ], function(
+ defined) {
+ "use strict";
+
+ /**
+ * Tests an object to see if it is an array.
+ * @exports isArray
+ *
+ * @param {Object} value The value to test.
+ * @returns {Boolean} true if the value is an array, false otherwise.
+ */
+ var isArray = Array.isArray;
+ if (!defined(isArray)) {
+ isArray = function(value) {
+ return Object.prototype.toString.call(value) === '[object Array]';
+ };
+ }
+
+ return isArray;
+});
\ No newline at end of file
diff --git a/Source/DynamicScene/ColorMaterialProperty.js b/Source/DynamicScene/ColorMaterialProperty.js
index 6a2f26ed426c..facf3c9dd69d 100644
--- a/Source/DynamicScene/ColorMaterialProperty.js
+++ b/Source/DynamicScene/ColorMaterialProperty.js
@@ -1,29 +1,86 @@
/*global define*/
-define([
- '../Core/Color',
+define(['../Core/Color',
+ '../Core/defaultValue',
'../Core/defined',
+ '../Core/defineProperties',
+ '../Core/DeveloperError',
+ '../Core/Event',
+ './createDynamicPropertyDescriptor',
'./ConstantProperty',
'./Property'
], function(
Color,
+ defaultValue,
defined,
+ defineProperties,
+ DeveloperError,
+ Event,
+ createDynamicPropertyDescriptor,
ConstantProperty,
Property) {
"use strict";
/**
* A {@link MaterialProperty} that maps to solid color {@link Material} uniforms.
+ *
+ * @param {Property} [color] The {@link Color} property to be used.
+ *
* @alias ColorMaterialProperty
* @constructor
*/
- var ColorMaterialProperty = function() {
+ var ColorMaterialProperty = function(colorProperty) {
+ this._definitionChanged = new Event();
+ this._color = undefined;
+ this._colorSubscription = undefined;
+ this.color = defaultValue(colorProperty, new ConstantProperty(Color.WHITE));
+ };
+
+ /**
+ * Creates a new instance that represents a constant color.
+ *
+ * @param {Color} color The color.
+ * @returns {ColorMaterialProperty} A new instance configured to represent the provided color.
+ */
+ ColorMaterialProperty.fromColor = function(color) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(color)) {
+ throw new DeveloperError('color is required');
+ }
+ //>>includeEnd('debug');
+ return new ColorMaterialProperty(new ConstantProperty(color));
+ };
+
+ defineProperties(ColorMaterialProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof ColorMaterialProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return Property.isConstant(this._color);
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is considered to have changed if a call to getValue would return
+ * a different result for the same time.
+ * @memberof ColorMaterialProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
/**
* A {@link Color} {@link Property} which determines the material's color.
+ * @memberof ColorMaterialProperty.prototype
* @type {Property}
- * @default new ConstantProperty(Color.WHITE)
*/
- this.color = new ConstantProperty(Color.WHITE);
- };
+ color : createDynamicPropertyDescriptor('color')
+ });
/**
* Gets the {@link Material} type at the provided time.
@@ -48,7 +105,7 @@ define([
if (!defined(result)) {
result = {};
}
- result.color = defined(this.color) ? this.color.getValue(time, result.color) : undefined;
+ result.color = defined(this._color) ? this._color.getValue(time, result.color) : undefined;
return result;
};
@@ -63,7 +120,14 @@ define([
ColorMaterialProperty.prototype.equals = function(other) {
return this === other || //
(other instanceof ColorMaterialProperty && //
- Property.equals(this.color, other.color));
+ Property.equals(this._color, other._color));
+ };
+
+ /**
+ * @private
+ */
+ ColorMaterialProperty.prototype._raiseDefinitionChanged = function() {
+ this._definitionChanged.raiseEvent(this);
};
return ColorMaterialProperty;
diff --git a/Source/DynamicScene/CompositeDynamicObjectCollection.js b/Source/DynamicScene/CompositeDynamicObjectCollection.js
index cefc5220a26e..2c53af5ce726 100644
--- a/Source/DynamicScene/CompositeDynamicObjectCollection.js
+++ b/Source/DynamicScene/CompositeDynamicObjectCollection.js
@@ -22,7 +22,7 @@ define(['../Core/createGuid',
function clean(dynamicObject) {
var propertyNames = dynamicObject.propertyNames;
var propertyNamesLength = propertyNames.length;
- for ( var i = 0; i < propertyNamesLength; i++) {
+ for (var i = 0; i < propertyNamesLength; i++) {
dynamicObject[propertyNames[i]] = undefined;
}
}
@@ -35,7 +35,7 @@ define(['../Core/createGuid',
var compositeProperty = compositeObject[propertyName];
var collections = that._collectionsCopy;
var collectionsLength = collections.length;
- for ( var q = collectionsLength - 1; q >= 0; q--) {
+ for (var q = collectionsLength - 1; q >= 0; q--) {
var object = collections[q].getById(dynamicObject.id);
if (defined(object)) {
var objectProperty = object[propertyName];
@@ -66,7 +66,7 @@ define(['../Core/createGuid',
var collections = that._collectionsCopy;
var collectionsLength = collections.length;
var firstTime = true;
- for ( var q = collectionsLength - 1; q >= 0; q--) {
+ for (var q = collectionsLength - 1; q >= 0; q--) {
var object = collections[q].getById(dynamicObject.id);
if (defined(object)) {
var property = object[propertyName];
@@ -92,12 +92,12 @@ define(['../Core/createGuid',
}
function subscribeToProperty(that, eventHash, collectionId, dynamicObject, propertyName, property) {
- if (defined(property) && defined(property.propertyChanged)) {
- var subpropertyChanged = createSubPropertyChangedCallback(that, dynamicObject, propertyName);
+ if (defined(property) && defined(property.definitionChanged)) {
+ var subdefinitionChanged = createSubPropertyChangedCallback(that, dynamicObject, propertyName);
propertyIdScratch[0] = collectionId;
propertyIdScratch[1] = dynamicObject.id;
propertyIdScratch[2] = propertyName;
- eventHash[JSON.stringify(propertyIdScratch)] = property.propertyChanged.addEventListener(subpropertyChanged);
+ eventHash[JSON.stringify(propertyIdScratch)] = property.definitionChanged.addEventListener(subdefinitionChanged);
}
}
@@ -116,11 +116,11 @@ define(['../Core/createGuid',
function subscribeToDynamicObject(that, eventHash, collectionId, dynamicObject) {
dynamicObjectIdScratch[0] = collectionId;
dynamicObjectIdScratch[1] = dynamicObject.id;
- eventHash[JSON.stringify(dynamicObjectIdScratch)] = dynamicObject.propertyChanged.addEventListener(createPropertyChangedCallback(that, collectionId));
+ eventHash[JSON.stringify(dynamicObjectIdScratch)] = dynamicObject.definitionChanged.addEventListener(createPropertyChangedCallback(that, collectionId));
var properties = dynamicObject.propertyNames;
var length = properties.length;
- for ( var i = 0; i < length; i++) {
+ for (var i = 0; i < length; i++) {
var propertyName = properties[i];
subscribeToProperty(that, eventHash, collectionId, dynamicObject, propertyName, dynamicObject[propertyName]);
}
@@ -135,13 +135,18 @@ define(['../Core/createGuid',
var properties = dynamicObject.propertyNames;
var length = properties.length;
- for ( var i = 0; i < length; i++) {
+ for (var i = 0; i < length; i++) {
var propertyName = properties[i];
unsubscribeFromProperty(eventHash, collectionId, dynamicObject, propertyName);
}
}
function recomposite(that) {
+ that._shouldRecomposite = true;
+ if (that._suspendCount !== 0) {
+ return;
+ }
+
var collections = that._collections;
var collectionsLength = collections.length;
@@ -202,7 +207,6 @@ define(['../Core/createGuid',
composite.add(newObjectsArray[i]);
}
composite.resumeEvents();
- return true;
}
/**
@@ -220,11 +224,13 @@ define(['../Core/createGuid',
*/
var CompositeDynamicObjectCollection = function(collections) {
this._composite = new DynamicObjectCollection();
+ this._suspendCount = 0;
this._collections = defined(collections) ? collections.slice() : [];
this._collectionsCopy = [];
this._id = createGuid();
this._eventHash = {};
recomposite(this);
+ this._shouldRecomposite = false;
};
defineProperties(CompositeDynamicObjectCollection.prototype, {
@@ -465,18 +471,22 @@ define(['../Core/createGuid',
* until a corresponding call is made to {@link DynamicObjectCollection#resumeEvents}, at which
* point a single event will be raised that covers all suspended operations.
* This allows for many items to be added and removed efficiently.
+ * While events are suspended, recompositing of the collections will
+ * also be suspended, as this can be a costly operation.
* This function can be safely called multiple times as long as there
* are corresponding calls to {@link DynamicObjectCollection#resumeEvents}.
* @memberof CompositeDynamicObjectCollection
*/
CompositeDynamicObjectCollection.prototype.suspendEvents = function() {
+ this._suspendCount++;
this._composite.suspendEvents();
};
/**
* Resumes raising {@link DynamicObjectCollection#collectionChanged} events immediately
* when an item is added or removed. Any modifications made while while events were suspended
- * will be triggered as a single event when this function is called.
+ * will be triggered as a single event when this function is called. This function also ensures
+ * the collection is recomposited if events are also resumed.
* This function is reference counted and can safely be called multiple times as long as there
* are corresponding calls to {@link DynamicObjectCollection#resumeEvents}.
* @memberof CompositeDynamicObjectCollection
@@ -484,7 +494,22 @@ define(['../Core/createGuid',
* @exception {DeveloperError} resumeEvents can not be called before suspendEvents.
*/
CompositeDynamicObjectCollection.prototype.resumeEvents = function() {
+ //>>includeStart('debug', pragmas.debug);
+ if (this._suspendCount === 0) {
+ throw new DeveloperError('resumeEvents can not be called before suspendEvents.');
+ }
+ //>>includeEnd('debug');
+
+ this._suspendCount--;
+ // recomposite before triggering events (but only if required for performance) that might depend on a composited collection
+ if (this._shouldRecomposite && this._suspendCount === 0) {
+ recomposite(this);
+ this._shouldRecomposite = false;
+
+ }
+
this._composite.resumeEvents();
+
};
/**
diff --git a/Source/DynamicScene/CompositeMaterialProperty.js b/Source/DynamicScene/CompositeMaterialProperty.js
index ebfa7c185953..92c5bc4424a3 100644
--- a/Source/DynamicScene/CompositeMaterialProperty.js
+++ b/Source/DynamicScene/CompositeMaterialProperty.js
@@ -1,15 +1,16 @@
/*global define*/
-define([
- '../Core/defined',
+define(['../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
- '../Core/TimeIntervalCollection',
+ '../Core/Event',
+ './CompositeProperty',
'./Property'
], function(
defined,
defineProperties,
DeveloperError,
- TimeIntervalCollection,
+ Event,
+ CompositeProperty,
Property) {
"use strict";
@@ -20,10 +21,35 @@ define([
* @constructor
*/
var CompositeMaterialProperty = function() {
- this._intervals = new TimeIntervalCollection();
+ this._definitionChanged = new Event();
+ this._composite = new CompositeProperty();
+ this._composite.definitionChanged.addEventListener(CompositeMaterialProperty.prototype._raiseDefinitionChanged, this);
};
defineProperties(CompositeMaterialProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof CompositeMaterialProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return this._composite.isConstant;
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is changed whenever setValue is called with data different
+ * than the current value.
+ * @memberof CompositeMaterialProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
/**
* Gets the interval collection.
* @memberof CompositeMaterialProperty.prototype
@@ -32,7 +58,7 @@ define([
*/
intervals : {
get : function() {
- return this._intervals;
+ return this._composite._intervals;
}
}
});
@@ -51,7 +77,7 @@ define([
}
//>>includeEnd('debug');
- var innerProperty = this._intervals.findDataForIntervalContainingDate(time);
+ var innerProperty = this._composite._intervals.findDataForIntervalContainingDate(time);
if (defined(innerProperty)) {
return innerProperty.getType(time);
}
@@ -73,7 +99,7 @@ define([
}
//>>includeEnd('debug');
- var innerProperty = this._intervals.findDataForIntervalContainingDate(time);
+ var innerProperty = this._composite._intervals.findDataForIntervalContainingDate(time);
if (defined(innerProperty)) {
return innerProperty.getValue(time, result);
}
@@ -91,7 +117,14 @@ define([
CompositeMaterialProperty.prototype.equals = function(other) {
return this === other || //
(other instanceof CompositeMaterialProperty && //
- this._intervals.equals(other._intervals, Property.equals));
+ this._composite.equals(other._composite, Property.equals));
+ };
+
+ /**
+ * @private
+ */
+ CompositeMaterialProperty.prototype._raiseDefinitionChanged = function() {
+ this._definitionChanged.raiseEvent(this);
};
return CompositeMaterialProperty;
diff --git a/Source/DynamicScene/CompositePositionProperty.js b/Source/DynamicScene/CompositePositionProperty.js
index a1780e81296f..9793b26e2a15 100644
--- a/Source/DynamicScene/CompositePositionProperty.js
+++ b/Source/DynamicScene/CompositePositionProperty.js
@@ -1,19 +1,20 @@
/*global define*/
-define([
- '../Core/defaultValue',
+define(['../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
- '../Core/TimeIntervalCollection',
+ '../Core/Event',
'../Core/ReferenceFrame',
+ './CompositeProperty',
'./Property'
], function(
defaultValue,
defined,
defineProperties,
DeveloperError,
- TimeIntervalCollection,
+ Event,
ReferenceFrame,
+ CompositeProperty,
Property) {
"use strict";
@@ -24,11 +25,36 @@ define([
* @constructor
*/
var CompositePositionProperty = function(referenceFrame) {
- this._intervals = new TimeIntervalCollection();
this._referenceFrame = defaultValue(referenceFrame, ReferenceFrame.FIXED);
+ this._definitionChanged = new Event();
+ this._composite = new CompositeProperty();
+ this._composite.definitionChanged.addEventListener(CompositePositionProperty.prototype._raiseDefinitionChanged, this);
};
defineProperties(CompositePositionProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof CompositePositionProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return this._composite.isConstant;
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is changed whenever setValue is called with data different
+ * than the current value.
+ * @memberof CompositePositionProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
/**
* Gets the interval collection.
* @memberof CompositePositionProperty.prototype
@@ -37,7 +63,7 @@ define([
*/
intervals : {
get : function() {
- return this._intervals;
+ return this._composite.intervals;
}
},
/**
@@ -90,7 +116,7 @@ define([
}
//>>includeEnd('debug');
- var innerProperty = this._intervals.findDataForIntervalContainingDate(time);
+ var innerProperty = this._composite._intervals.findDataForIntervalContainingDate(time);
if (defined(innerProperty)) {
return innerProperty.getValueInReferenceFrame(time, referenceFrame, result);
}
@@ -109,7 +135,14 @@ define([
return this === other || //
(other instanceof CompositePositionProperty && //
this._referenceFrame === other._referenceFrame && //
- this._intervals.equals(other._intervals, Property.equals));
+ this._composite.equals(other._composite, Property.equals));
+ };
+
+ /**
+ * @private
+ */
+ CompositePositionProperty.prototype._raiseDefinitionChanged = function() {
+ this._definitionChanged.raiseEvent(this);
};
return CompositePositionProperty;
diff --git a/Source/DynamicScene/CompositeProperty.js b/Source/DynamicScene/CompositeProperty.js
index 87e2c139e4b1..d22143792878 100644
--- a/Source/DynamicScene/CompositeProperty.js
+++ b/Source/DynamicScene/CompositeProperty.js
@@ -1,18 +1,37 @@
/*global define*/
-define([
+define(['./Property',
'../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
- '../Core/TimeIntervalCollection',
- './Property'
+ '../Core/Event',
+ '../Core/EventHelper',
+ '../Core/TimeIntervalCollection'
], function(
+ Property,
defined,
defineProperties,
DeveloperError,
- TimeIntervalCollection,
- Property) {
+ Event,
+ EventHelper,
+ TimeIntervalCollection) {
"use strict";
+ function subscribeAll(property, eventHelper, definitionChanged, intervals) {
+ var callback = function() {
+ definitionChanged.raiseEvent(property);
+ };
+
+ var items = [];
+ eventHelper.removeAll();
+ var length = intervals.getLength();
+ for (var i = 0; i < length; i++) {
+ var interval = intervals.get(i);
+ if (defined(interval.data) && items.indexOf(interval.data) === -1) {
+ eventHelper.add(interval.data.definitionChanged, callback);
+ }
+ }
+ }
+
/**
* A {@link Property} which is defined by a {@link TimeIntervalCollection}, where the
* data property of each {@link TimeInterval} is another Property instance which is
@@ -37,10 +56,36 @@ define([
* composite.intervals.addInterval(Cesium.TimeInterval.fromIso8601('2012-08-01T12:00:00.00Z/2012-08-02T00:00:00.00Z', false, false, sampledProperty));
*/
var CompositeProperty = function() {
+ this._eventHelper = new EventHelper();
+ this._definitionChanged = new Event();
this._intervals = new TimeIntervalCollection();
+ this._intervals.getChangedEvent().addEventListener(CompositeProperty.prototype._intervalsChanged, this);
};
defineProperties(CompositeProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof CompositeProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return this._intervals.isEmpty();
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is changed whenever setValue is called with data different
+ * than the current value.
+ * @memberof CompositeProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
/**
* Gets the interval collection.
* @memberof CompositeProperty.prototype
@@ -90,5 +135,13 @@ define([
this._intervals.equals(other._intervals, Property.equals));
};
+ /**
+ * @private
+ */
+ CompositeProperty.prototype._intervalsChanged = function() {
+ subscribeAll(this, this._eventHelper, this._definitionChanged, this._intervals);
+ this._definitionChanged.raiseEvent(this);
+ };
+
return CompositeProperty;
});
\ No newline at end of file
diff --git a/Source/DynamicScene/ConstantPositionProperty.js b/Source/DynamicScene/ConstantPositionProperty.js
index 99751b9a86e7..80a7432f7da3 100644
--- a/Source/DynamicScene/ConstantPositionProperty.js
+++ b/Source/DynamicScene/ConstantPositionProperty.js
@@ -1,24 +1,23 @@
/*global define*/
-define([
- './ConstantProperty',
- './PositionProperty',
+define(['./PositionProperty',
+ './Property',
'../Core/Cartesian3',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
- '../Core/ReferenceFrame',
- './Property'
+ '../Core/Event',
+ '../Core/ReferenceFrame'
], function(
- ConstantProperty,
PositionProperty,
+ Property,
Cartesian3,
defaultValue,
defined,
defineProperties,
DeveloperError,
- ReferenceFrame,
- Property) {
+ Event,
+ ReferenceFrame) {
"use strict";
/**
@@ -28,19 +27,39 @@ define([
* @alias ConstantPositionProperty
* @constructor
*
- * @param {Cartesian3} value The property value.
+ * @param {Cartesian3} [value] The property value.
* @param {ReferenceFrame} [referenceFrame=ReferenceFrame.FIXED] The reference frame in which the position is defined.
- *
- * @example
- * //Create a constant position in the inertial frame.
- * var constantProperty = new Cesium.ConstantPositionProperty(new Cesium.Cartesian3(-4225824.0, 1261219.0, -5148934.0), Cesium.ReferenceFrame.INERTIAL);
*/
var ConstantPositionProperty = function(value, referenceFrame) {
- this._property = new ConstantProperty(value);
+ this._definitionChanged = new Event();
+ this._value = Cartesian3.clone(value);
this._referenceFrame = defaultValue(referenceFrame, ReferenceFrame.FIXED);
};
defineProperties(ConstantPositionProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof ConstantPositionProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return !defined(this._value) || this._referenceFrame === ReferenceFrame.FIXED;
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is considered to have changed if a call to getValue would return
+ * a different result for the same time.
+ * @memberof ConstantPositionProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
/**
* Gets the reference frame in which the position is defined.
* @memberof ConstantPositionProperty.prototype
@@ -66,6 +85,28 @@ define([
return this.getValueInReferenceFrame(time, ReferenceFrame.FIXED, result);
};
+ /**
+ * Sets the value of the property.
+ * @memberof ConstantPositionProperty
+ *
+ * @param {Cartesian3} value The property value.
+ * @param {ReferenceFrame} [referenceFrame=this.referenceFrame] The reference frame in which the position is defined.
+ */
+ ConstantPositionProperty.prototype.setValue = function(value, referenceFrame) {
+ var definitionChanged = false;
+ if (!Cartesian3.equals(this._value, value)) {
+ definitionChanged = true;
+ this._value = Cartesian3.clone(value);
+ }
+ if (defined(referenceFrame) && this._referenceFrame !== referenceFrame) {
+ definitionChanged = true;
+ this._referenceFrame = referenceFrame;
+ }
+ if (definitionChanged) {
+ this._definitionChanged.raiseEvent(this);
+ }
+ };
+
/**
* Gets the value of the property at the provided time and in the provided reference frame.
* @memberof ConstantPositionProperty
@@ -85,8 +126,7 @@ define([
}
//>>includeEnd('debug');
- var value = this._property.getValue(time, result);
- return PositionProperty.convertToReferenceFrame(time, value, this._referenceFrame, referenceFrame, value);
+ return PositionProperty.convertToReferenceFrame(time, this._value, this._referenceFrame, referenceFrame, result);
};
/**
@@ -100,9 +140,9 @@ define([
ConstantPositionProperty.prototype.equals = function(other) {
return this === other ||
(other instanceof ConstantPositionProperty &&
- Property.equals(this._property, other._property) &&
+ Cartesian3.equals(this._value, other._value) &&
this._referenceFrame === other._referenceFrame);
};
return ConstantPositionProperty;
-});
\ No newline at end of file
+});
diff --git a/Source/DynamicScene/ConstantProperty.js b/Source/DynamicScene/ConstantProperty.js
index 06815e795f19..2001e4b3459b 100644
--- a/Source/DynamicScene/ConstantProperty.js
+++ b/Source/DynamicScene/ConstantProperty.js
@@ -1,68 +1,109 @@
/*global define*/
-define([
- '../Core/defaultValue',
+define(['../Core/defaultValue',
'../Core/defined',
+ '../Core/defineProperties',
'../Core/DeveloperError',
- '../Core/Enumeration'
+ '../Core/Enumeration',
+ '../Core/Event',
+ '../Core/isArray'
], function(
defaultValue,
defined,
+ defineProperties,
DeveloperError,
- Enumeration) {
+ Enumeration,
+ Event,
+ isArray) {
"use strict";
/**
- * A {@link Property} whose value never changes.
+ * A {@link Property} whose value does not change with respect to simulation time.
+ * If the value is a non-basic type, then it must provide clone and equals functions.
*
* @alias ConstantProperty
* @constructor
*
- * @param {Object|Number|String} value The property value.
- * This parameter is only required if the value is not a number or string and does not have a clone function.
+ * @param {Object} [value] The property value.
*
* @see ConstantPositionProperty
*
- * @example
- * //Create a constant value from a Cartesian2 instance.
- * var constantProperty = new ConstantProperty(new Cartesian2(10, 12));
+ * @exception {DeveloperError} value.clone is a required function.
+ * @exception {DeveloperError} value.equals is a required function.
*/
var ConstantProperty = function(value) {
- //>>includeStart('debug', pragmas.debug);
- if (!defined(value)) {
- throw new DeveloperError('value is required.');
- }
- //>>includeEnd('debug');
-
- var simple = typeof value !== 'object' || Array.isArray(value) || value instanceof Enumeration;
+ this._value = undefined;
+ this._simple = true;
+ this._definitionChanged = new Event();
+ this.setValue(value);
+ };
- //>>includeStart('debug', pragmas.debug);
- if (!simple) {
- if (typeof value.clone !== 'function') {
- throw new DeveloperError('clone is a required function.');
- }
- if (typeof value.equals !== 'function') {
- throw new DeveloperError('equals is a required function.');
+ defineProperties(ConstantProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant.
+ * This property always returns true
.
+ * @memberof ConstantProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ value : true
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is changed whenever setValue is called with data different
+ * than the current value.
+ * @memberof ConstantProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
}
}
- //>>includeEnd('debug');
-
- this._value = value;
- this._simple = simple;
- };
+ });
/**
- * Gets the value of the property at the provided time.
- * @memberof CompositeProperty
+ * Gets the value of the property.
+ * @memberof ConstantProperty
*
- * @param {JulianDate} time The time for which to retrieve the value. This parameter is unused since the value never changes.
+ * @param {JulianDate} [time] The time for which to retrieve the value. This parameter is unused since the value does not change with respect to time.
* @param {Object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {Object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
ConstantProperty.prototype.getValue = function(time, result) {
- if (this._simple) {
- return this._value;
+ return this._simple ? this._value : this._value.clone(result);
+ };
+
+ /**
+ * Sets the value of the property.
+ * If the value is a non-basic type, then it must provide clone and equals functions.
+ * @memberof ConstantProperty
+ *
+ * @param {Object} value The property value.
+ *
+ * @exception {DeveloperError} value.clone is a required function.
+ * @exception {DeveloperError} value.equals is a required function.
+ */
+ ConstantProperty.prototype.setValue = function(value) {
+ var oldValue = this._value;
+ var simple = this._simple;
+ if ((simple && oldValue !== value) || (!simple && !oldValue.equals(value))) {
+ simple = typeof value !== 'object' || isArray(value) || value instanceof Enumeration;
+
+ //>>includeStart('debug', pragmas.debug);
+ if (!simple) {
+ if (typeof value.clone !== 'function') {
+ throw new DeveloperError('clone is a required function.');
+ }
+ if (typeof value.equals !== 'function') {
+ throw new DeveloperError('equals is a required function.');
+ }
+ }
+ //>>includeEnd('debug');
+
+ this._value = simple ? value : value.clone();
+ this._simple = simple;
+ this._definitionChanged.raiseEvent(this);
}
- return this._value.clone(result);
};
/**
diff --git a/Source/DynamicScene/CzmlDataSource.js b/Source/DynamicScene/CzmlDataSource.js
index 7515584ff53c..f1eeacc4e0bd 100644
--- a/Source/DynamicScene/CzmlDataSource.js
+++ b/Source/DynamicScene/CzmlDataSource.js
@@ -1,6 +1,5 @@
/*global define*/
-define([
- '../Core/Cartesian2',
+define(['../Core/Cartesian2',
'../Core/Cartesian3',
'../Core/Cartographic',
'../Core/Color',
@@ -9,11 +8,13 @@ define([
'../Core/createGuid',
'../Core/defaultValue',
'../Core/defined',
+ '../Core/defineProperties',
'../Core/DeveloperError',
'../Core/Ellipsoid',
'../Core/Event',
'../Core/getFilenameFromUri',
'../Core/HermitePolynomialApproximation',
+ '../Core/isArray',
'../Core/Iso8601',
'../Core/JulianDate',
'../Core/LagrangePolynomialApproximation',
@@ -34,13 +35,13 @@ define([
'./CompositeProperty',
'./ConstantPositionProperty',
'./ConstantProperty',
+ './createDynamicPropertyDescriptor',
'./DynamicBillboard',
'./DynamicClock',
'./ColorMaterialProperty',
'./PolylineOutlineMaterialProperty',
'./DynamicCone',
'./DynamicLabel',
- './DynamicDirectionsProperty',
'./DynamicEllipse',
'./DynamicEllipsoid',
'./GridMaterialProperty',
@@ -53,7 +54,8 @@ define([
'./DynamicPolygon',
'./DynamicPyramid',
'./DynamicVector',
- './DynamicVertexPositionsProperty',
+ './PositionPropertyArray',
+ './ReferenceProperty',
'./SampledPositionProperty',
'./SampledProperty',
'./TimeIntervalCollectionPositionProperty',
@@ -70,11 +72,13 @@ define([
createGuid,
defaultValue,
defined,
+ defineProperties,
DeveloperError,
Ellipsoid,
Event,
getFilenameFromUri,
HermitePolynomialApproximation,
+ isArray,
Iso8601,
JulianDate,
LagrangePolynomialApproximation,
@@ -95,13 +99,13 @@ define([
CompositeProperty,
ConstantPositionProperty,
ConstantProperty,
+ createDynamicPropertyDescriptor,
DynamicBillboard,
DynamicClock,
ColorMaterialProperty,
PolylineOutlineMaterialProperty,
DynamicCone,
DynamicLabel,
- DynamicDirectionsProperty,
DynamicEllipse,
DynamicEllipsoid,
GridMaterialProperty,
@@ -114,7 +118,8 @@ define([
DynamicPolygon,
DynamicPyramid,
DynamicVector,
- DynamicVertexPositionsProperty,
+ PositionPropertyArray,
+ ReferenceProperty,
SampledPositionProperty,
SampledProperty,
TimeIntervalCollectionPositionProperty,
@@ -123,6 +128,58 @@ define([
when) {
"use strict";
+ //This class is a workaround for CZML represented as two properties which get turned into a single Cartesian2 property once loaded.
+ var Cartesian2WrapperProperty = function() {
+ this._definitionChanged = new Event();
+ this._x = undefined;
+ this._xSubscription = undefined;
+ this._y = undefined;
+ this._ySubscription = undefined;
+
+ this.x = new ConstantProperty(0);
+ this.y = new ConstantProperty(0.1);
+ };
+
+ defineProperties(Cartesian2WrapperProperty.prototype, {
+ isConstant : {
+ get : function() {
+ return this._x.isConstant && this._y.isConstant;
+ }
+ },
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
+ x : createDynamicPropertyDescriptor('x'),
+ y : createDynamicPropertyDescriptor('y')
+ });
+
+ Cartesian2WrapperProperty.prototype.getValue = function(time, result) {
+ if (!defined(result)) {
+ result = new Cartesian2();
+ }
+ result.x = this._x.getValue(time);
+ result.y = this._y.getValue(time);
+ return result;
+ };
+
+ Cartesian2WrapperProperty.prototype._raiseDefinitionChanged = function() {
+ this._definitionChanged.raiseEvent(this);
+ };
+
+ function combineIntoCartesian2(object, packetDataX, packetDataY) {
+ if (!defined(packetDataX) && !defined(packetDataY)) {
+ return object;
+ }
+ if (!(object instanceof Cartesian2WrapperProperty)) {
+ object = new Cartesian2WrapperProperty();
+ }
+ processPacketData(Number, object, 'x', packetDataX);
+ processPacketData(Number, object, 'y', packetDataY);
+ return object;
+ }
+
var scratchCartesian = new Cartesian3();
var scratchSpherical = new Spherical();
var scratchCartographic = new Cartographic();
@@ -144,7 +201,7 @@ define([
var len = rgba.length;
rgbaf = new Array(len);
- for ( var i = 0; i < len; i += 5) {
+ for (var i = 0; i < len; i += 5) {
rgbaf[i] = rgba[i];
rgbaf[i + 1] = Color.byteToFloat(rgba[i + 1]);
rgbaf[i + 2] = Color.byteToFloat(rgba[i + 2]);
@@ -317,11 +374,11 @@ define([
function updateInterpolationSettings(packetData, property) {
var interpolator = interpolators[packetData.interpolationAlgorithm];
- if (defined(interpolator)) {
- property.interpolationAlgorithm = interpolator;
- }
- if (defined(packetData.interpolationDegree)) {
- property.interpolationDegree = packetData.interpolationDegree;
+ if (defined(interpolator) || defined(packetData.interpolationDegree)) {
+ property.setInterpolationOptions({
+ interpolationAlgorithm : interpolator,
+ interpolationDegree : packetData.interpolationDegree
+ });
}
}
@@ -356,6 +413,12 @@ define([
var propertyCreated = false;
var property = object[propertyName];
+ var epoch;
+ var packetEpoch = packetData.epoch;
+ if (defined(packetEpoch)) {
+ epoch = JulianDate.fromIso8601(packetEpoch);
+ }
+
//Without an interval, any sampled value is infinite, meaning it completely
//replaces any non-sampled property that may exist.
if (isSampled && !hasInterval) {
@@ -364,11 +427,6 @@ define([
object[propertyName] = property;
propertyCreated = true;
}
- var epoch;
- var packetEpoch = packetData.epoch;
- if (defined(packetEpoch)) {
- epoch = JulianDate.fromIso8601(packetEpoch);
- }
property.addSamplesPackedArray(unwrappedInterval, epoch);
updateInterpolationSettings(packetData, property);
return propertyCreated;
@@ -456,7 +514,7 @@ define([
interval.data = new SampledProperty(type);
intervals.addInterval(interval);
}
- interval.data.addSamplesPackedArray(unwrappedInterval, JulianDate.fromIso8601(packetData.epoch));
+ interval.data.addSamplesPackedArray(unwrappedInterval, epoch);
updateInterpolationSettings(packetData, interval.data);
return propertyCreated;
}
@@ -466,8 +524,8 @@ define([
return;
}
- if (Array.isArray(packetData)) {
- for ( var i = 0, len = packetData.length; i < len; i++) {
+ if (isArray(packetData)) {
+ for (var i = 0, len = packetData.length; i < len; i++) {
processProperty(type, object, propertyName, packetData[i], interval, sourceUri);
}
} else {
@@ -487,7 +545,7 @@ define([
combinedInterval = constrainedInterval;
}
- var referenceFrame = ReferenceFrame[defaultValue(packetData.referenceFrame, "FIXED")];
+ var referenceFrame = defaultValue(ReferenceFrame[packetData.referenceFrame], undefined);
var unwrappedInterval = unwrapCartesianInterval(packetData);
var hasInterval = defined(combinedInterval) && !combinedInterval.equals(Iso8601.MAXIMUM_INTERVAL);
var packedLength = Cartesian3.packedLength;
@@ -503,19 +561,20 @@ define([
var propertyCreated = false;
var property = object[propertyName];
+ var epoch;
+ var packetEpoch = packetData.epoch;
+ if (defined(packetEpoch)) {
+ epoch = JulianDate.fromIso8601(packetEpoch);
+ }
+
//Without an interval, any sampled value is infinite, meaning it completely
//replaces any non-sampled property that may exist.
if (isSampled && !hasInterval) {
- if (!(property instanceof SampledPositionProperty) || property.referenceFrame !== referenceFrame) {
+ if (!(property instanceof SampledPositionProperty) || (defined(referenceFrame) && property.referenceFrame !== referenceFrame)) {
property = new SampledPositionProperty(referenceFrame);
object[propertyName] = property;
propertyCreated = true;
}
- var epoch;
- var packetEpoch = packetData.epoch;
- if (defined(packetEpoch)) {
- epoch = JulianDate.fromIso8601(packetEpoch);
- }
property.addSamplesPackedArray(unwrappedInterval, epoch);
updateInterpolationSettings(packetData, property);
return propertyCreated;
@@ -538,7 +597,7 @@ define([
propertyCreated = true;
}
- if (property instanceof TimeIntervalCollectionPositionProperty && property.referenceFrame === referenceFrame) {
+ if (property instanceof TimeIntervalCollectionPositionProperty && (defined(referenceFrame) && property.referenceFrame === referenceFrame)) {
//If we create a collection, or it already existed, use it.
property.intervals.addInterval(combinedInterval);
} else if (property instanceof CompositePositionProperty) {
@@ -591,13 +650,13 @@ define([
//Check if the interval already exists in the composite
var intervals = property.intervals;
interval = intervals.findInterval(combinedInterval.start, combinedInterval.stop, combinedInterval.isStartIncluded, combinedInterval.isStopIncluded);
- if (!defined(interval) || !(interval.data instanceof SampledPositionProperty) || interval.data.referenceFrame !== referenceFrame) {
+ if (!defined(interval) || !(interval.data instanceof SampledPositionProperty) || (defined(referenceFrame) && interval.data.referenceFrame !== referenceFrame)) {
//If not, create a SampledPositionProperty for it.
interval = combinedInterval.clone();
interval.data = new SampledPositionProperty(referenceFrame);
intervals.addInterval(interval);
}
- interval.data.addSamplesPackedArray(unwrappedInterval, JulianDate.fromIso8601(packetData.epoch));
+ interval.data.addSamplesPackedArray(unwrappedInterval, epoch);
updateInterpolationSettings(packetData, interval.data);
return propertyCreated;
}
@@ -607,8 +666,8 @@ define([
return;
}
- if (Array.isArray(packetData)) {
- for ( var i = 0, len = packetData.length; i < len; i++) {
+ if (isArray(packetData)) {
+ for (var i = 0, len = packetData.length; i < len; i++) {
processPositionProperty(object, propertyName, packetData[i], interval, sourceUri);
}
} else {
@@ -616,32 +675,6 @@ define([
}
}
- var Cartesian2WrapperProperty = function() {
- this._x = new ConstantProperty(0);
- this._y = new ConstantProperty(0);
- };
-
- Cartesian2WrapperProperty.prototype.getValue = function(time, result) {
- if (!defined(result)) {
- result = new Cartesian2();
- }
- result.x = this._x.getValue(time);
- result.y = this._y.getValue(time);
- return result;
- };
-
- function combineIntoCartesian2(object, packetDataX, packetDataY) {
- if (!defined(packetDataX) && !defined(packetDataY)) {
- return object;
- }
- if (!(object instanceof Cartesian2WrapperProperty)) {
- object = new Cartesian2WrapperProperty();
- }
- processPacketData(Number, object, '_x', packetDataX);
- processPacketData(Number, object, '_y', packetDataY);
- return object;
- }
-
function processMaterialProperty(object, propertyName, packetData, constrainedInterval, sourceUri) {
var combinedInterval;
var packetInterval = packetData.interval;
@@ -654,29 +687,29 @@ define([
combinedInterval = constrainedInterval;
}
- combinedInterval = defaultValue(combinedInterval, Iso8601.MAXIMUM_INTERVAL);
-
- var propertyCreated = false;
var property = object[propertyName];
- if (!defined(property)) {
- property = new CompositeMaterialProperty();
- object[propertyName] = property;
- propertyCreated = true;
- }
-
- //See if we already have data at that interval.
- var thisIntervals = property.intervals;
- var existingInterval = thisIntervals.findInterval(combinedInterval.start, combinedInterval.stop);
var existingMaterial;
+ var existingInterval;
- if (defined(existingInterval)) {
- //We have an interval, but we need to make sure the
- //new data is the same type of material as the old data.
- existingMaterial = existingInterval.data;
+ if (defined(combinedInterval)) {
+ if (!(property instanceof CompositeMaterialProperty)) {
+ property = new CompositeMaterialProperty();
+ object[propertyName] = property;
+ //See if we already have data at that interval.
+ var thisIntervals = property.intervals;
+ existingInterval = thisIntervals.findInterval(combinedInterval.start, combinedInterval.stop);
+ if (defined(existingInterval)) {
+ //We have an interval, but we need to make sure the
+ //new data is the same type of material as the old data.
+ existingMaterial = existingInterval.data;
+ } else {
+ //If not, create it.
+ existingInterval = combinedInterval.clone();
+ thisIntervals.addInterval(existingInterval);
+ }
+ }
} else {
- //If not, create it.
- existingInterval = combinedInterval.clone();
- thisIntervals.addInterval(existingInterval);
+ existingMaterial = property;
}
var materialData;
@@ -703,9 +736,12 @@ define([
processPacketData(Image, existingMaterial, 'image', materialData.image, undefined, sourceUri);
existingMaterial.repeat = combineIntoCartesian2(existingMaterial.repeat, materialData.horizontalRepeat, materialData.verticalRepeat);
}
- existingInterval.data = existingMaterial;
- return propertyCreated;
+ if (defined(existingInterval)) {
+ existingInterval.data = existingMaterial;
+ } else {
+ object[propertyName] = existingMaterial;
+ }
}
function processMaterialPacketData(object, propertyName, packetData, interval, sourceUri) {
@@ -713,8 +749,8 @@ define([
return;
}
- if (Array.isArray(packetData)) {
- for ( var i = 0, len = packetData.length; i < len; i++) {
+ if (isArray(packetData)) {
+ for (var i = 0, len = packetData.length; i < len; i++) {
processMaterialProperty(object, propertyName, packetData[i], interval, sourceUri);
}
} else {
@@ -760,11 +796,55 @@ define([
return;
}
- var vertexPositions = dynamicObject.vertexPositions;
- if (!defined(vertexPositions)) {
- dynamicObject.vertexPositions = vertexPositions = new DynamicVertexPositionsProperty();
+ var i;
+ var len;
+ var references = vertexPositionsData.references;
+ if (defined(references)) {
+ var properties = [];
+ for (i = 0, len = references.length; i < len; i++) {
+ properties.push(ReferenceProperty.fromString(dynamicObjectCollection, references[i]));
+ }
+
+ var iso8601Interval = vertexPositionsData.interval;
+ if (defined(iso8601Interval)) {
+ iso8601Interval = TimeInterval.fromIso8601(iso8601Interval);
+ if (!(dynamicObject.vertexPositions instanceof CompositePositionProperty)) {
+ dynamicObject.vertexPositions = new CompositePositionProperty();
+ iso8601Interval.data = new PositionPropertyArray(properties);
+ dynamicObject.vertexPositions.intervals.addInterval(iso8601Interval);
+ }
+ } else {
+ dynamicObject.vertexPositions = new PositionPropertyArray(properties);
+ }
+ } else {
+ var values = [];
+ var tmp = vertexPositionsData.cartesian;
+ if (defined(tmp)) {
+ for (i = 0, len = tmp.length; i < len; i += 3) {
+ values.push(new Cartesian3(tmp[i], tmp[i + 1], tmp[i + 2]));
+ }
+ vertexPositionsData.array = values;
+ } else {
+ tmp = vertexPositionsData.cartographicRadians;
+ if (defined(tmp)) {
+ for (i = 0, len = tmp.length; i < len; i += 3) {
+ values.push(Ellipsoid.WGS84.cartographicToCartesian(new Cartographic(tmp[i], tmp[i + 1], tmp[i + 2])));
+ }
+ vertexPositionsData.array = values;
+ } else {
+ tmp = vertexPositionsData.cartographicDegrees;
+ if (defined(tmp)) {
+ for (i = 0, len = tmp.length; i < len; i += 3) {
+ values.push(Ellipsoid.WGS84.cartographicToCartesian(Cartographic.fromDegrees(tmp[i], tmp[i + 1], tmp[i + 2])));
+ }
+ vertexPositionsData.array = values;
+ }
+ }
+ }
+ if (defined(vertexPositionsData.array)) {
+ processPacketData(Array, dynamicObject, 'vertexPositions', vertexPositionsData, undefined, sourceUri);
+ }
}
- vertexPositions.processCzmlIntervals(vertexPositionsData, undefined, dynamicObjectCollection);
}
function processAvailability(dynamicObject, packet, dynamicObjectCollection, sourceUri) {
@@ -775,7 +855,7 @@ define([
}
var intervals;
- if (Array.isArray(packetData)) {
+ if (isArray(packetData)) {
var length = packetData.length;
for (var i = 0; i < length; i++) {
if (!defined(intervals)) {
@@ -902,9 +982,19 @@ define([
dynamicObject.ellipse = ellipse = new DynamicEllipse();
}
+ processPacketData(Boolean, ellipse, 'show', ellipseData.show, interval, sourceUri);
processPacketData(Number, ellipse, 'rotation', ellipseData.rotation, interval, sourceUri);
processPacketData(Number, ellipse, 'semiMajorAxis', ellipseData.semiMajorAxis, interval, sourceUri);
processPacketData(Number, ellipse, 'semiMinorAxis', ellipseData.semiMinorAxis, interval, sourceUri);
+ processPacketData(Number, ellipse, 'height', ellipseData.height, interval, sourceUri);
+ processPacketData(Number, ellipse, 'extrudedHeight', ellipseData.extrudedHeight, interval, sourceUri);
+ processPacketData(Number, ellipse, 'granularity', ellipseData.granularity, interval, sourceUri);
+ processPacketData(Number, ellipse, 'stRotation', ellipseData.stRotation, interval, sourceUri);
+ processMaterialPacketData(ellipse, 'material', ellipseData.material, interval, sourceUri);
+ processPacketData(Boolean, ellipse, 'fill', ellipseData.fill, interval, sourceUri);
+ processPacketData(Boolean, ellipse, 'outline', ellipseData.outline, interval, sourceUri);
+ processPacketData(Color, ellipse, 'outlineColor', ellipseData.outlineColor, interval, sourceUri);
+ processPacketData(Number, ellipse, 'numberOfVerticalLines', ellipseData.numberOfVerticalLines, interval, sourceUri);
}
function processEllipsoid(dynamicObject, packet, dynamicObjectCollection, sourceUri) {
@@ -926,6 +1016,9 @@ define([
processPacketData(Boolean, ellipsoid, 'show', ellipsoidData.show, interval, sourceUri);
processPacketData(Cartesian3, ellipsoid, 'radii', ellipsoidData.radii, interval, sourceUri);
processMaterialPacketData(ellipsoid, 'material', ellipsoidData.material, interval, sourceUri);
+ processPacketData(Boolean, ellipsoid, 'fill', ellipsoidData.fill, interval, sourceUri);
+ processPacketData(Boolean, ellipsoid, 'outline', ellipsoidData.outline, interval, sourceUri);
+ processPacketData(Color, ellipsoid, 'outlineColor', ellipsoidData.outlineColor, interval, sourceUri);
}
function processLabel(dynamicObject, packet, dynamicObjectCollection, sourceUri) {
@@ -1025,6 +1118,14 @@ define([
processPacketData(Boolean, polygon, 'show', polygonData.show, interval, sourceUri);
processMaterialPacketData(polygon, 'material', polygonData.material, interval, sourceUri);
+ processPacketData(Number, polygon, 'height', polygonData.height, interval, sourceUri);
+ processPacketData(Number, polygon, 'extrudedHeight', polygonData.extrudedHeight, interval, sourceUri);
+ processPacketData(Number, polygon, 'granularity', polygonData.granularity, interval, sourceUri);
+ processPacketData(Number, polygon, 'stRotation', polygonData.stRotation, interval, sourceUri);
+ processPacketData(Boolean, polygon, 'fill', polygonData.fill, interval, sourceUri);
+ processPacketData(Boolean, polygon, 'outline', polygonData.outline, interval, sourceUri);
+ processPacketData(Color, polygon, 'outlineColor', polygonData.outlineColor, interval, sourceUri);
+ processPacketData(Boolean, polygon, 'perPositionHeight', polygonData.perPositionHeight, interval, sourceUri);
}
function processPolyline(dynamicObject, packet, dynamicObjectCollection, sourceUri) {
@@ -1101,12 +1202,28 @@ define([
processPacketData(Number, pyramid, 'intersectionWidth', pyramidData.intersectionWidth, interval, sourceUri);
processMaterialPacketData(pyramid, 'material', pyramidData.material, interval, sourceUri);
+ //The directions property is a special case value that can be an array of unitSpherical or unit Cartesians.
+ //We pre-process this into Spherical instances and then process it like any other array.
if (defined(pyramidData.directions)) {
- var directions = pyramid.directions;
- if (!defined(directions)) {
- pyramid.directions = directions = new DynamicDirectionsProperty();
+ var i;
+ var len;
+ var values = [];
+ var tmp = pyramidData.directions.unitSpherical;
+ if (defined(tmp)) {
+ for (i = 0, len = tmp.length; i < len; i += 2) {
+ values.push(new Spherical(tmp[i], tmp[i + 1]));
+ }
+ pyramidData.directions.array = values;
+ }
+
+ tmp = pyramidData.directions.unitCartesian;
+ if (defined(tmp)) {
+ for (i = 0, len = tmp.length; i < len; i += 3) {
+ values.push(Spherical.fromCartesian3(new Cartesian3(tmp[i], tmp[i + 1], tmp[i + 2])));
+ }
+ pyramidData.directions.array = values;
}
- directions.processCzmlIntervals(pyramidData.directions, interval);
+ processPacketData(Array, pyramid, 'directions', pyramidData.directions, interval, sourceUri);
}
}
@@ -1453,8 +1570,8 @@ define([
CzmlDataSource._processCzml = function(czml, dynamicObjectCollection, sourceUri, updaterFunctions, dataSource) {
updaterFunctions = defined(updaterFunctions) ? updaterFunctions : CzmlDataSource.updaters;
- if (Array.isArray(czml)) {
- for ( var i = 0, len = czml.length; i < len; i++) {
+ if (isArray(czml)) {
+ for (var i = 0, len = czml.length; i < len; i++) {
processCzmlPacket(czml[i], dynamicObjectCollection, updaterFunctions, sourceUri, dataSource);
}
} else {
diff --git a/Source/DynamicScene/DataSource.js b/Source/DynamicScene/DataSource.js
index 13b11552ac20..70c4e8b5fad0 100644
--- a/Source/DynamicScene/DataSource.js
+++ b/Source/DynamicScene/DataSource.js
@@ -5,10 +5,6 @@ define([
DeveloperError) {
"use strict";
- function throwInstantiationError() {
- throw new DeveloperError('This type should not be instantiated directly.');
- }
-
/**
* Defines the interface for data sources, which turn arbitrary data into a
* {@link DynamicObjectCollection} for generic consumption. This object is an interface
@@ -16,7 +12,9 @@ define([
* @alias DataSource
* @constructor
*/
- var DataSource = throwInstantiationError;
+ var DataSource = function() {
+ DeveloperError.throwInstantiationError();
+ };
/**
* Gets an event that will be raised when non-time-varying data changes, such
@@ -26,7 +24,7 @@ define([
*
* @returns {Event} The event.
*/
- DataSource.prototype.getChangedEvent = throwInstantiationError;
+ DataSource.prototype.getChangedEvent = DeveloperError.throwInstantiationError;
/**
* Gets an event that will be raised if an error is encountered during processing.
@@ -35,7 +33,7 @@ define([
*
* @returns {Event} The event.
*/
- DataSource.prototype.getErrorEvent = throwInstantiationError;
+ DataSource.prototype.getErrorEvent = DeveloperError.throwInstantiationError;
/**
* Gets the DynamicObjectCollection generated by this data source.
@@ -44,7 +42,7 @@ define([
*
* @returns {DynamicObjectCollection} The collection of objects generated by this data source.
*/
- DataSource.prototype.getDynamicObjectCollection = throwInstantiationError;
+ DataSource.prototype.getDynamicObjectCollection = DeveloperError.throwInstantiationError;
/**
* Gets the name of this data source. If the return value of
@@ -53,7 +51,7 @@ define([
*
* @returns {String} The name.
*/
- DataSource.prototype.getName = throwInstantiationError;
+ DataSource.prototype.getName = DeveloperError.throwInstantiationError;
/**
* Gets the top level clock associated with this data source, or undefined if no clock exists.
@@ -63,7 +61,7 @@ define([
*
* @returns {DynamicClock} The clock associated with this data source, or undefined if none exists.
*/
- DataSource.prototype.getClock = throwInstantiationError;
+ DataSource.prototype.getClock = DeveloperError.throwInstantiationError;
/**
* Gets a value indicating if the data varies with simulation time. If the return value of
@@ -73,7 +71,7 @@ define([
*
* @returns {Boolean} True if the data is varies with simulation time, false otherwise.
*/
- DataSource.prototype.getIsTimeVarying = throwInstantiationError;
+ DataSource.prototype.getIsTimeVarying = DeveloperError.throwInstantiationError;
return DataSource;
});
\ No newline at end of file
diff --git a/Source/DynamicScene/DataSourceDisplay.js b/Source/DynamicScene/DataSourceDisplay.js
index dd068785f8d6..08cb0e5f4eab 100644
--- a/Source/DynamicScene/DataSourceDisplay.js
+++ b/Source/DynamicScene/DataSourceDisplay.js
@@ -1,21 +1,21 @@
/*global define*/
-define([
- '../Core/defaultValue',
+define(['../Core/defaultValue',
'../Core/defined',
'../Core/destroyObject',
'../Core/DeveloperError',
'../Core/EventHelper',
'./DynamicBillboardVisualizer',
- './DynamicEllipsoidVisualizer',
'./DynamicConeVisualizerUsingCustomSensor',
'./DynamicLabelVisualizer',
'./DynamicPathVisualizer',
'./DynamicPointVisualizer',
- './DynamicPolygonVisualizer',
- './DynamicPolylineVisualizer',
'./DynamicPyramidVisualizer',
'./DynamicVectorVisualizer',
- './VisualizerCollection'
+ './EllipseGeometryUpdater',
+ './EllipsoidGeometryUpdater',
+ './GeometryVisualizer',
+ './PolygonGeometryUpdater',
+ './PolylineGeometryUpdater'
], function(
defaultValue,
defined,
@@ -23,28 +23,33 @@ define([
DeveloperError,
EventHelper,
DynamicBillboardVisualizer,
- DynamicEllipsoidVisualizer,
DynamicConeVisualizerUsingCustomSensor,
DynamicLabelVisualizer,
DynamicPathVisualizer,
DynamicPointVisualizer,
- DynamicPolygonVisualizer,
- DynamicPolylineVisualizer,
DynamicPyramidVisualizer,
DynamicVectorVisualizer,
- VisualizerCollection) {
+ EllipseGeometryUpdater,
+ EllipsoidGeometryUpdater,
+ GeometryVisualizer,
+ PolygonGeometryUpdater,
+ PolylineGeometryUpdater) {
"use strict";
- var defaultVisualizerTypes = [DynamicBillboardVisualizer,
- DynamicEllipsoidVisualizer,
- DynamicConeVisualizerUsingCustomSensor,
- DynamicLabelVisualizer,
- DynamicPointVisualizer,
- DynamicPolygonVisualizer,
- DynamicPolylineVisualizer,
- DynamicPyramidVisualizer,
- DynamicPathVisualizer,
- DynamicVectorVisualizer];
+ var createDefaultVisualizers = function(scene, dataSource) {
+ var dynamicObjects = dataSource.getDynamicObjectCollection();
+ return [new DynamicBillboardVisualizer(scene, dynamicObjects),
+ new GeometryVisualizer(EllipseGeometryUpdater, scene, dynamicObjects),
+ new GeometryVisualizer(EllipsoidGeometryUpdater, scene, dynamicObjects),
+ new GeometryVisualizer(PolygonGeometryUpdater, scene, dynamicObjects),
+ new GeometryVisualizer(PolylineGeometryUpdater, scene, dynamicObjects),
+ new DynamicConeVisualizerUsingCustomSensor(scene, dynamicObjects),
+ new DynamicLabelVisualizer(scene, dynamicObjects),
+ new DynamicPointVisualizer(scene, dynamicObjects),
+ new DynamicVectorVisualizer(scene, dynamicObjects),
+ new DynamicPyramidVisualizer(scene, dynamicObjects),
+ new DynamicPathVisualizer(scene, dynamicObjects)];
+ };
/**
* Visualizes a collection of {@link DataSource} instances.
@@ -53,9 +58,9 @@ define([
*
* @param {Scene} scene The scene in which to display the data.
* @param {DataSourceCollection} dataSourceCollection The data sources to display.
- * @param {Array} [visualizerTypes] The array of visualizer constructor functions that will be created for each data source. If undefined, All standard visualizers will be used.
+ * @param {Visualizer[]} [visualizersCallback] A function which takes a scene and dataSource and returns the array of visualizers used for visualization. If left undefined, all standard visualizers are used.
*/
- var DataSourceDisplay = function(scene, dataSourceCollection, visualizerTypes) {
+ var DataSourceDisplay = function(scene, dataSourceCollection, visualizersCallback) {
//>>includeStart('debug', pragmas.debug);
if (!defined(scene)) {
throw new DeveloperError('scene is required.');
@@ -73,9 +78,9 @@ define([
this._scene = scene;
this._timeVaryingSources = [];
this._staticSourcesToUpdate = [];
- this._visualizersTypes = defaultValue(visualizerTypes, defaultVisualizerTypes).slice(0);
+ this._visualizersCallback = defaultValue(visualizersCallback, createDefaultVisualizers);
- for ( var i = 0, len = dataSourceCollection.getLength(); i < len; i++) {
+ for (var i = 0, len = dataSourceCollection.getLength(); i < len; i++) {
this._onDataSourceAdded(dataSourceCollection, dataSourceCollection.get(i));
}
};
@@ -88,14 +93,6 @@ define([
return this._scene;
};
- /**
- * Gets the types of visualizers being used for display.
- * @returns {Array} A copy of the visualizer types being used for display.
- */
- DataSourceDisplay.prototype.getVisualizerTypes = function() {
- return this._visualizersTypes.slice(0);
- };
-
/**
* Gets the collection of data sources to be displayed.
* @returns {DataSourceCollection} The collection of data sources.
@@ -139,7 +136,7 @@ define([
this._eventHelper.removeAll();
var dataSourceCollection = this._dataSourceCollection;
- for ( var i = 0, length = dataSourceCollection.getLength(); i < length; ++i) {
+ for (var i = 0, length = dataSourceCollection.getLength(); i < length; ++i) {
this._onDataSourceRemoved(this._dataSourceCollection, dataSourceCollection.get(i));
}
@@ -160,34 +157,36 @@ define([
}
//>>includeEnd('debug');
- var timeVaryingSources = this._timeVaryingSources;
var i;
+ var x;
+ var visualizers;
+ var vLength;
+
+ var timeVaryingSources = this._timeVaryingSources;
var length = timeVaryingSources.length;
for (i = 0; i < length; i++) {
- timeVaryingSources[i]._visualizerCollection.update(time);
+ visualizers = timeVaryingSources[i]._visualizers;
+ vLength = visualizers.length;
+ for (x = 0; x < vLength; x++) {
+ visualizers[x].update(time);
+ }
}
var staticSourcesToUpdate = this._staticSourcesToUpdate;
length = staticSourcesToUpdate.length;
- if (length > 0) {
- for (i = 0; i < length; i++) {
- staticSourcesToUpdate[i]._visualizerCollection.update(time);
+ for (i = 0; i < length; i++) {
+ visualizers = staticSourcesToUpdate[i]._visualizers;
+ vLength = visualizers.length;
+ for (x = 0; x < vLength; x++) {
+ visualizers[x].update(time);
}
- staticSourcesToUpdate.length = 0;
}
+ staticSourcesToUpdate.length = 0;
};
DataSourceDisplay.prototype._onDataSourceAdded = function(dataSourceCollection, dataSource) {
- var visualizerTypes = this._visualizersTypes;
- var length = visualizerTypes.length;
- var visualizers = new Array(length);
- var scene = this._scene;
- for ( var i = 0; i < length; i++) {
- visualizers[i] = new visualizerTypes[i](scene);
- }
-
- var vCollection = new VisualizerCollection(visualizers, dataSource.getDynamicObjectCollection());
- dataSource._visualizerCollection = vCollection;
+ var visualizers = this._visualizersCallback(this._scene, dataSource);
+ dataSource._visualizers = visualizers;
dataSource.getChangedEvent().addEventListener(this._onDataSourceChanged, this);
this._onDataSourceChanged(dataSource);
};
@@ -205,8 +204,12 @@ define([
this._staticSourcesToUpdate.splice(staticIndex, 1);
}
- dataSource._visualizerCollection.destroy();
- dataSource._visualizerCollection = undefined;
+ var visualizers = dataSource._visualizers;
+ var length = visualizers.length;
+ for (var i = 0; i < length; i++) {
+ visualizers[i].destroy();
+ dataSource._visualizers = undefined;
+ }
};
DataSourceDisplay.prototype._onDataSourceChanged = function(dataSource) {
diff --git a/Source/DynamicScene/DynamicBillboard.js b/Source/DynamicScene/DynamicBillboard.js
index 699305d629c5..957bb5974856 100644
--- a/Source/DynamicScene/DynamicBillboard.js
+++ b/Source/DynamicScene/DynamicBillboard.js
@@ -22,21 +22,36 @@ define(['../Core/defaultValue',
*/
var DynamicBillboard = function() {
this._image = undefined;
+ this._imageSubscription = undefined;
this._width = undefined;
+ this._widthSubscription = undefined;
this._height = undefined;
+ this._heightSubscription = undefined;
this._scale = undefined;
+ this._scaleSubscription = undefined;
this._rotation = undefined;
+ this._rotationSubscription = undefined;
this._alignedAxis = undefined;
+ this._alignedAxisSubscription = undefined;
this._horizontalOrigin = undefined;
+ this._horizontalOriginSubscription = undefined;
this._verticalOrigin = undefined;
+ this._verticalOriginSubscription = undefined;
this._color = undefined;
+ this._colorSubscription = undefined;
this._eyeOffset = undefined;
+ this._eyeOffsetSubscription = undefined;
this._pixelOffset = undefined;
+ this._pixelOffsetSubscription = undefined;
this._show = undefined;
+ this._showSubscription = undefined;
this._scaleByDistance = undefined;
+ this._scaleByDistanceSubscription = undefined;
this._translucencyByDistance = undefined;
+ this._translucencyByDistanceSubscription = undefined;
this._pixelOffsetScaleByDistance = undefined;
- this._propertyChanged = new Event();
+ this._pixelOffsetScaleByDistanceSubscription = undefined;
+ this._definitionChanged = new Event();
};
defineProperties(DynamicBillboard.prototype, {
@@ -45,9 +60,9 @@ define(['../Core/defaultValue',
* @memberof DynamicBillboard.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
@@ -56,70 +71,70 @@ define(['../Core/defaultValue',
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- image : createDynamicPropertyDescriptor('image', '_image'),
+ image : createDynamicPropertyDescriptor('image'),
/**
* Gets or sets the numeric {@link Property} specifying the billboard's scale.
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- scale : createDynamicPropertyDescriptor('scale', '_scale'),
+ scale : createDynamicPropertyDescriptor('scale'),
/**
* Gets or sets the numeric {@link Property} specifying the billboard's rotation.
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- rotation : createDynamicPropertyDescriptor('rotation', '_rotation'),
+ rotation : createDynamicPropertyDescriptor('rotation'),
/**
* Gets or sets the {@link Cartesian3} {@link Property} specifying the billboard rotation's aligned axis.
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- alignedAxis : createDynamicPropertyDescriptor('alignedAxis', '_alignedAxis'),
+ alignedAxis : createDynamicPropertyDescriptor('alignedAxis'),
/**
* Gets or sets the {@link HorizontalOrigin} {@link Property} specifying the billboard's horizontal origin.
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- horizontalOrigin : createDynamicPropertyDescriptor('horizontalOrigin', '_horizontalOrigin'),
+ horizontalOrigin : createDynamicPropertyDescriptor('horizontalOrigin'),
/**
* Gets or sets the {@link VerticalOrigin} {@link Property} specifying the billboard's vertical origin.
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- verticalOrigin : createDynamicPropertyDescriptor('verticalOrigin', '_verticalOrigin'),
+ verticalOrigin : createDynamicPropertyDescriptor('verticalOrigin'),
/**
* Gets or sets the {@link Color} {@link Property} specifying the billboard's color.
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- color : createDynamicPropertyDescriptor('color', '_color'),
+ color : createDynamicPropertyDescriptor('color'),
/**
* Gets or sets the {@link Cartesian3} {@link Property} specifying the billboard's eye offset.
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- eyeOffset : createDynamicPropertyDescriptor('eyeOffset', '_eyeOffset'),
+ eyeOffset : createDynamicPropertyDescriptor('eyeOffset'),
/**
* Gets or sets the {@link Cartesian2} {@link Property} specifying the billboard's pixel offset.
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- pixelOffset : createDynamicPropertyDescriptor('pixelOffset', '_pixelOffset'),
+ pixelOffset : createDynamicPropertyDescriptor('pixelOffset'),
/**
* Gets or sets the boolean {@link Property} specifying the billboard's visibility.
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- show : createDynamicPropertyDescriptor('show', '_show'),
+ show : createDynamicPropertyDescriptor('show'),
/**
* Gets or sets the numeric {@link Property} specifying the billboard's width in pixels.
@@ -127,7 +142,7 @@ define(['../Core/defaultValue',
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- width : createDynamicPropertyDescriptor('width', '_width'),
+ width : createDynamicPropertyDescriptor('width'),
/**
* Gets or sets the numeric {@link Property} specifying the billboard's height in pixels.
@@ -135,7 +150,7 @@ define(['../Core/defaultValue',
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- height : createDynamicPropertyDescriptor('height', '_height'),
+ height : createDynamicPropertyDescriptor('height'),
/**
* Gets or sets the {@link NearFarScalar} {@link Property} used to scale billboards based on distance.
@@ -143,7 +158,7 @@ define(['../Core/defaultValue',
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- scaleByDistance : createDynamicPropertyDescriptor('scaleByDistance', '_scaleByDistance'),
+ scaleByDistance : createDynamicPropertyDescriptor('scaleByDistance'),
/**
* Gets or sets the {@link NearFarScalar} {@link Property} used to set translucency based on distance.
@@ -151,7 +166,7 @@ define(['../Core/defaultValue',
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- translucencyByDistance : createDynamicPropertyDescriptor('translucencyByDistance', '_translucencyByDistance'),
+ translucencyByDistance : createDynamicPropertyDescriptor('translucencyByDistance'),
/**
* Gets or sets the {@link NearFarScalar} {@link Property} used to set pixel offset scaling based on distance.
@@ -159,8 +174,7 @@ define(['../Core/defaultValue',
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- pixelOffsetScaleByDistance : createDynamicPropertyDescriptor('pixelOffsetScaleByDistance', '_pixelOffsetScaleByDistance')
-
+ pixelOffsetScaleByDistance : createDynamicPropertyDescriptor('pixelOffsetScaleByDistance')
});
/**
diff --git a/Source/DynamicScene/DynamicBillboardVisualizer.js b/Source/DynamicScene/DynamicBillboardVisualizer.js
index 1854aa294635..e1b27ca10f43 100644
--- a/Source/DynamicScene/DynamicBillboardVisualizer.js
+++ b/Source/DynamicScene/DynamicBillboardVisualizer.js
@@ -50,17 +50,13 @@ define([
* @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize.
*
* @see DynamicBillboard
- * @see Scene
* @see DynamicObject
* @see DynamicObjectCollection
* @see CompositeDynamicObjectCollection
- * @see VisualizerCollection
* @see DynamicConeVisualizer
* @see DynamicConeVisualizerUsingCustomSensor
* @see DynamicLabelVisualizer
* @see DynamicPointVisualizer
- * @see DynamicPolygonVisualizer
- * @see DynamicPolylineVisualizer
* @see DynamicPyramidVisualizer
*/
var DynamicBillboardVisualizer = function(scene, dynamicObjectCollection) {
@@ -75,10 +71,10 @@ define([
this._dynamicObjectCollection = undefined;
var billboardCollection = this._billboardCollection = new BillboardCollection();
- var atlas = this._textureAtlas = scene.getContext().createTextureAtlas();
+ var atlas = this._textureAtlas = scene.context.createTextureAtlas();
this._textureAtlasBuilder = new TextureAtlasBuilder(atlas);
billboardCollection.setTextureAtlas(atlas);
- scene.getPrimitives().add(billboardCollection);
+ scene.primitives.add(billboardCollection);
this.setDynamicObjectCollection(dynamicObjectCollection);
};
@@ -128,7 +124,7 @@ define([
DynamicBillboardVisualizer.prototype.update = function(time) {
//>>includeStart('debug', pragmas.debug);
if (!defined(time)) {
- throw new DeveloperError('time is requied.');
+ throw new DeveloperError('time is required.');
}
//>>includeEnd('debug');
@@ -191,7 +187,7 @@ define([
*/
DynamicBillboardVisualizer.prototype.destroy = function() {
this.setDynamicObjectCollection(undefined);
- this._scene.getPrimitives().remove(this._billboardCollection);
+ this._scene.primitives.remove(this._billboardCollection);
return destroyObject(this);
};
@@ -245,7 +241,7 @@ define([
billboard = dynamicBillboardVisualizer._billboardCollection.add();
}
dynamicObject._billboardVisualizerIndex = billboardVisualizerIndex;
- billboard.dynamicObject = dynamicObject;
+ billboard.id = dynamicObject;
billboard._visualizerUrl = undefined;
billboard._visualizerTextureAvailable = false;
diff --git a/Source/DynamicScene/DynamicClock.js b/Source/DynamicScene/DynamicClock.js
index f1d7647b7d1a..6a0c079c1fda 100644
--- a/Source/DynamicScene/DynamicClock.js
+++ b/Source/DynamicScene/DynamicClock.js
@@ -31,7 +31,7 @@ define(['../Core/Clock',
this._clockRange = undefined;
this._clockStep = undefined;
this._multiplier = undefined;
- this._propertyChanged = new Event();
+ this._definitionChanged = new Event();
};
defineProperties(DynamicClock.prototype, {
@@ -40,9 +40,9 @@ define(['../Core/Clock',
* @memberof DynamicClock.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
@@ -51,35 +51,35 @@ define(['../Core/Clock',
* @memberof DynamicClock.prototype
* @type {JulianDate}
*/
- startTime : createDynamicPropertyDescriptor('startTime', '_startTime'),
+ startTime : createDynamicPropertyDescriptor('startTime'),
/**
* Gets or sets the stop time of the clock to use when looping or clamped.
* @memberof DynamicClock.prototype
* @type {JulianDate}
*/
- stopTime : createDynamicPropertyDescriptor('stopTime', '_stopTime'),
+ stopTime : createDynamicPropertyDescriptor('stopTime'),
/**
* Gets or sets the initial time to use when switching to this clock.
* @memberof DynamicClock.prototype
* @type {JulianDate}
*/
- currentTime : createDynamicPropertyDescriptor('currentTime', '_currentTime'),
+ currentTime : createDynamicPropertyDescriptor('currentTime'),
/**
* Gets or sets how the clock should behave when startTime
or stopTime
is reached.
* @memberof DynamicClock.prototype
* @type {ClockRange}
*/
- clockRange : createDynamicPropertyDescriptor('clockRange', '_clockRange'),
+ clockRange : createDynamicPropertyDescriptor('clockRange'),
/**
* Gets or sets if clock advancement is frame dependent or system clock dependent.
* @memberof DynamicClock.prototype
* @type {ClockStep}
*/
- clockStep : createDynamicPropertyDescriptor('clockStep', '_clockStep'),
+ clockStep : createDynamicPropertyDescriptor('clockStep'),
/**
* Gets or sets how much time advances with each tick, negative values allow for advancing backwards.
@@ -89,7 +89,7 @@ define(['../Core/Clock',
* @memberof DynamicClock.prototype
* @type {Number}
*/
- multiplier : createDynamicPropertyDescriptor('multiplier', '_multiplier')
+ multiplier : createDynamicPropertyDescriptor('multiplier')
});
/**
diff --git a/Source/DynamicScene/DynamicCone.js b/Source/DynamicScene/DynamicCone.js
index 40c05626092a..dc346ff945d5 100644
--- a/Source/DynamicScene/DynamicCone.js
+++ b/Source/DynamicScene/DynamicCone.js
@@ -22,19 +22,32 @@ define(['../Core/defaultValue',
*/
var DynamicCone = function() {
this._minimumClockAngle = undefined;
+ this._minimumClockAngleSubscription = undefined;
this._maximumClockAngle = undefined;
+ this._maximumClockAngleSubscription = undefined;
this._innerHalfAngle = undefined;
+ this._innerHalfAngleSubscription = undefined;
this._outerHalfAngle = undefined;
+ this._outerHalfAngleSubscription = undefined;
this._capMaterial = undefined;
+ this._capMaterialSubscription = undefined;
this._innerMaterial = undefined;
+ this._innerMaterialSubscription = undefined;
this._outerMaterial = undefined;
+ this._outerMaterialSubscription = undefined;
this._silhouetteMaterial = undefined;
+ this._silhouetteMaterialSubscription = undefined;
this._intersectionColor = undefined;
+ this._intersectionColorSubscription = undefined;
this._intersectionWidth = undefined;
+ this._intersectionWidthSubscription = undefined;
this._showIntersection = undefined;
+ this._showIntersectionSubscription = undefined;
this._radius = undefined;
+ this._radiusSubscription = undefined;
this._show = undefined;
- this._propertyChanged = new Event();
+ this._showSubscription = undefined;
+ this._definitionChanged = new Event();
};
defineProperties(DynamicCone.prototype, {
@@ -43,9 +56,9 @@ define(['../Core/defaultValue',
* @memberof DynamicCone.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
@@ -54,91 +67,91 @@ define(['../Core/defaultValue',
* @memberof DynamicCone.prototype
* @type {Property}
*/
- minimumClockAngle : createDynamicPropertyDescriptor('minimumClockAngle', '_minimumClockAngle'),
+ minimumClockAngle : createDynamicPropertyDescriptor('minimumClockAngle'),
/**
* Gets or sets the numeric {@link Property} specifying the the cone's maximum clock angle.
* @memberof DynamicCone.prototype
* @type {Property}
*/
- maximumClockAngle : createDynamicPropertyDescriptor('maximumClockAngle', '_maximumClockAngle'),
+ maximumClockAngle : createDynamicPropertyDescriptor('maximumClockAngle'),
/**
* Gets or sets the numeric {@link Property} specifying the the cone's inner half-angle.
* @memberof DynamicCone.prototype
* @type {Property}
*/
- innerHalfAngle : createDynamicPropertyDescriptor('innerHalfAngle', '_innerHalfAngle'),
+ innerHalfAngle : createDynamicPropertyDescriptor('innerHalfAngle'),
/**
* Gets or sets the numeric {@link Property} specifying the the cone's outer half-angle.
* @memberof DynamicCone.prototype
* @type {Property}
*/
- outerHalfAngle : createDynamicPropertyDescriptor('outerHalfAngle', '_outerHalfAngle'),
+ outerHalfAngle : createDynamicPropertyDescriptor('outerHalfAngle'),
/**
* Gets or sets the {@link MaterialProperty} specifying the the cone's cap material.
* @memberof DynamicCone.prototype
* @type {MaterialProperty}
*/
- capMaterial : createDynamicPropertyDescriptor('capMaterial', '_capMaterial'),
+ capMaterial : createDynamicPropertyDescriptor('capMaterial'),
/**
* Gets or sets the {@link MaterialProperty} specifying the the cone's inner material.
* @memberof DynamicCone.prototype
* @type {MaterialProperty}
*/
- innerMaterial : createDynamicPropertyDescriptor('innerMaterial', '_innerMaterial'),
+ innerMaterial : createDynamicPropertyDescriptor('innerMaterial'),
/**
* Gets or sets the {@link MaterialProperty} specifying the the cone's outer material.
* @memberof DynamicCone.prototype
* @type {MaterialProperty}
*/
- outerMaterial : createDynamicPropertyDescriptor('outerMaterial', '_outerMaterial'),
+ outerMaterial : createDynamicPropertyDescriptor('outerMaterial'),
/**
* Gets or sets the {@link MaterialProperty} specifying the the cone's silhouette material.
* @memberof DynamicCone.prototype
* @type {MaterialProperty}
*/
- silhouetteMaterial : createDynamicPropertyDescriptor('silhouetteMaterial', '_silhouetteMaterial'),
+ silhouetteMaterial : createDynamicPropertyDescriptor('silhouetteMaterial'),
/**
* Gets or sets the {@link Color} {@link Property} specifying the color of the line formed by the intersection of the cone and other central bodies.
* @memberof DynamicCone.prototype
* @type {Property}
*/
- intersectionColor : createDynamicPropertyDescriptor('intersectionColor', '_intersectionColor'),
+ intersectionColor : createDynamicPropertyDescriptor('intersectionColor'),
/**
* Gets or sets the numeric {@link Property} specifying the width of the line formed by the intersection of the cone and other central bodies.
* @memberof DynamicCone.prototype
* @type {Property}
*/
- intersectionWidth : createDynamicPropertyDescriptor('intersectionWidth', '_intersectionWidth'),
+ intersectionWidth : createDynamicPropertyDescriptor('intersectionWidth'),
/**
* Gets or sets the boolean {@link Property} specifying the visibility of the line formed by the intersection of the cone and other central bodies.
* @memberof DynamicCone.prototype
* @type {Property}
*/
- showIntersection : createDynamicPropertyDescriptor('showIntersection', '_showIntersection'),
+ showIntersection : createDynamicPropertyDescriptor('showIntersection'),
/**
* Gets or sets the numeric {@link Property} specifying the radius of the cone's projection.
* @memberof DynamicCone.prototype
* @type {Property}
*/
- radius : createDynamicPropertyDescriptor('radius', '_radius'),
+ radius : createDynamicPropertyDescriptor('radius'),
/**
* Gets or sets the boolean {@link Property} specifying the visibility of the cone.
* @memberof DynamicCone.prototype
* @type {Property}
*/
- show : createDynamicPropertyDescriptor('show', '_show')
+ show : createDynamicPropertyDescriptor('show')
});
/**
diff --git a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js
index 6aa61260c8b6..2a090057f9b5 100644
--- a/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js
+++ b/Source/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js
@@ -86,17 +86,13 @@ define([
* @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize.
*
* @see DynamicCone
- * @see Scene
* @see DynamicObject
* @see DynamicObjectCollection
* @see CompositeDynamicObjectCollection
- * @see VisualizerCollection
* @see DynamicBillboardVisualizer
* @see DynamicConeVisualizer
* @see DynamicLabelVisualizer
* @see DynamicPointVisualizer
- * @see DynamicPolygonVisualizer
- * @see DynamicPolylineVisualizer
* @see DynamicPyramidVisualizer
*/
var DynamicConeVisualizerUsingCustomSensor = function(scene, dynamicObjectCollection) {
@@ -108,7 +104,7 @@ define([
this._scene = scene;
this._unusedIndexes = [];
- this._primitives = scene.getPrimitives();
+ this._primitives = scene.primitives;
this._coneCollection = [];
this._dynamicObjectCollection = undefined;
this.setDynamicObjectCollection(dynamicObjectCollection);
@@ -160,7 +156,7 @@ define([
DynamicConeVisualizerUsingCustomSensor.prototype.update = function(time) {
//>>includeStart('debug', pragmas.debug);
if (!defined(time)) {
- throw new DeveloperError('time is requied.');
+ throw new DeveloperError('time is required.');
}
//>>includeEnd('debug');
@@ -280,7 +276,7 @@ define([
dynamicConeVisualizerUsingCustomSensor._primitives.add(cone);
}
dynamicObject._coneVisualizerIndex = coneVisualizerIndex;
- cone.dynamicObject = dynamicObject;
+ cone.id = dynamicObject;
// CZML_TODO Determine official defaults
cone.material = Material.fromType(Material.ColorType);
diff --git a/Source/DynamicScene/DynamicDirectionsProperty.js b/Source/DynamicScene/DynamicDirectionsProperty.js
deleted file mode 100644
index 6ef7b2654e13..000000000000
--- a/Source/DynamicScene/DynamicDirectionsProperty.js
+++ /dev/null
@@ -1,103 +0,0 @@
-/*global define*/
-define([
- '../Core/defined',
- '../Core/TimeInterval',
- '../Core/TimeIntervalCollection',
- '../Core/Cartesian3',
- '../Core/Spherical',
- '../Core/Iso8601'
- ], function(
- defined,
- TimeInterval,
- TimeIntervalCollection,
- Cartesian3,
- Spherical,
- Iso8601) {
- "use strict";
-
- function ValueHolder(czmlInterval) {
- var i;
- var len;
- var values = [];
- var tmp = czmlInterval.unitSpherical;
- if (defined(tmp)) {
- for (i = 0, len = tmp.length; i < len; i += 2) {
- values.push(new Spherical(tmp[i], tmp[i + 1]));
- }
- this.spherical = values;
- }
-
- tmp = czmlInterval.unitCartesian;
- if (defined(tmp)) {
- for (i = 0, len = tmp.length; i < len; i += 3) {
- values.push(new Cartesian3(tmp[i], tmp[i + 1], tmp[i + 2], true));
- }
- this.cartesian = values;
- }
- }
-
- ValueHolder.prototype.getValue = function() {
- var sphericals = this.spherical;
- if (!defined(sphericals)) {
- sphericals = [];
- this.spherical = sphericals;
- var cartesians = this.cartesian;
- for ( var i = 0, len = cartesians.length; i < len; i++) {
- sphericals.push(Spherical.fromCartesian3(cartesians[i]));
- }
- }
- return sphericals;
- };
-
- /**
- * @private
- */
- var DynamicDirectionsProperty = function() {
- this._propertyIntervals = new TimeIntervalCollection();
- };
-
- DynamicDirectionsProperty.prototype.processCzmlIntervals = function(czmlIntervals, constrainedInterval, dynamicObjectCollection) {
- if (Array.isArray(czmlIntervals)) {
- for ( var i = 0, len = czmlIntervals.length; i < len; i++) {
- addCzmlInterval(this, czmlIntervals[i], constrainedInterval, dynamicObjectCollection);
- }
- } else {
- addCzmlInterval(this, czmlIntervals, constrainedInterval, dynamicObjectCollection);
- }
- };
-
- DynamicDirectionsProperty.prototype.getValue = function(time) {
- var interval = this._propertyIntervals.findIntervalContainingDate(time);
- if (!defined(interval)) {
- return undefined;
- }
- return interval.data.getValue();
- };
-
- function addCzmlInterval(dynamicDirectionsProperty, czmlInterval, constrainedInterval, dynamicObjectCollection) {
- var iso8601Interval = czmlInterval.interval;
- if (!defined(iso8601Interval)) {
- iso8601Interval = Iso8601.MAXIMUM_INTERVAL.clone();
- } else {
- iso8601Interval = TimeInterval.fromIso8601(iso8601Interval);
- }
-
- if (defined(constrainedInterval)) {
- iso8601Interval = iso8601Interval.intersect(constrainedInterval);
- }
-
- //See if we already have data at that interval.
- var thisIntervals = dynamicDirectionsProperty._propertyIntervals;
- var existingInterval = thisIntervals.findInterval(iso8601Interval.start, iso8601Interval.stop);
-
- //If not, create it.
- if (!defined(existingInterval)) {
- existingInterval = iso8601Interval;
- thisIntervals.addInterval(existingInterval);
- }
-
- existingInterval.data = new ValueHolder(czmlInterval);
- }
-
- return DynamicDirectionsProperty;
-});
diff --git a/Source/DynamicScene/DynamicEllipse.js b/Source/DynamicScene/DynamicEllipse.js
index 463fcb9642c7..ed257175a50b 100644
--- a/Source/DynamicScene/DynamicEllipse.js
+++ b/Source/DynamicScene/DynamicEllipse.js
@@ -28,14 +28,30 @@ define(['../Core/Cartesian3',
*/
var DynamicEllipse = function() {
this._semiMajorAxis = undefined;
+ this._semiMajorAxisSubscription = undefined;
this._semiMinorAxis = undefined;
+ this._semiMinorAxisSubscription = undefined;
this._rotation = undefined;
- this._lastPosition = undefined;
- this._lastSemiMajorAxis = undefined;
- this._lastSemiMinorAxis = undefined;
- this._lastRotation = undefined;
- this._cachedVertexPositions = undefined;
- this._propertyChanged = new Event();
+ this._rotationSubscription = undefined;
+ this._show = undefined;
+ this._showSubscription = undefined;
+ this._material = undefined;
+ this._materialSubscription = undefined;
+ this._height = undefined;
+ this._heightSubscription = undefined;
+ this._extrudedHeight = undefined;
+ this._extrudedHeightSubscription = undefined;
+ this._granularity = undefined;
+ this._granularitySubscription = undefined;
+ this._stRotation = undefined;
+ this._stRotationSubscription = undefined;
+ this._outline = undefined;
+ this._outlineSubscription = undefined;
+ this._outlineColor = undefined;
+ this._outlineColorSubscription = undefined;
+ this._numberOfVerticalLines = undefined;
+ this._numberOfVerticalLinesSubscription = undefined;
+ this._definitionChanged = new Event();
};
defineProperties(DynamicEllipse.prototype, {
@@ -44,9 +60,9 @@ define(['../Core/Cartesian3',
* @memberof DynamicEllipse.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
@@ -55,21 +71,97 @@ define(['../Core/Cartesian3',
* @memberof DynamicEllipse.prototype
* @type {Property}
*/
- semiMajorAxis : createDynamicPropertyDescriptor('semiMajorAxis', '_semiMajorAxis'),
+ semiMajorAxis : createDynamicPropertyDescriptor('semiMajorAxis'),
/**
* Gets or sets the numeric {@link Property} specifying the ellipse's semi-minor-axis.
* @memberof DynamicEllipse.prototype
* @type {Property}
*/
- semiMinorAxis : createDynamicPropertyDescriptor('semiMinorAxis', '_semiMinorAxis'),
+ semiMinorAxis : createDynamicPropertyDescriptor('semiMinorAxis'),
/**
* Gets or sets the numeric {@link Property} specifying the ellipse's rotation.
* @memberof DynamicEllipse.prototype
* @type {Property}
*/
- rotation : createDynamicPropertyDescriptor('rotation', '_rotation')
+ rotation : createDynamicPropertyDescriptor('rotation'),
+
+ /**
+ * Gets or sets the boolean {@link Property} specifying the polygon's visibility.
+ * @memberof DynamicEllipse.prototype
+ * @type {Property}
+ */
+ show : createDynamicPropertyDescriptor('show'),
+
+ /**
+ * Gets or sets the {@link MaterialProperty} specifying the appearance of the polygon.
+ * @memberof DynamicEllipse.prototype
+ * @type {MaterialProperty}
+ */
+ material : createDynamicPropertyDescriptor('material'),
+
+ /**
+ * Gets or sets the Number {@link Property} specifying the height of the polygon.
+ * If undefined, the polygon will be on the surface.
+ * @memberof DynamicEllipse.prototype
+ * @type {Property}
+ */
+ height : createDynamicPropertyDescriptor('height'),
+
+ /**
+ * Gets or sets the Number {@link Property} specifying the extruded height of the polygon.
+ * Setting this property creates a polygon shaped volume starting at height and ending
+ * at the extruded height.
+ * @memberof DynamicEllipse.prototype
+ * @type {Property}
+ */
+ extrudedHeight : createDynamicPropertyDescriptor('extrudedHeight'),
+
+ /**
+ * Gets or sets the Number {@link Property} specifying the sampling distance, in radians,
+ * between each latitude and longitude point.
+ * @memberof DynamicEllipse.prototype
+ * @type {Property}
+ */
+ granularity : createDynamicPropertyDescriptor('granularity'),
+
+ /**
+ * Gets or sets the Number {@link Property} specifying the rotation of the texture coordinates,
+ * in radians. A positive rotation is counter-clockwise.
+ * @memberof DynamicEllipse.prototype
+ * @type {Property}
+ */
+ stRotation : createDynamicPropertyDescriptor('stRotation'),
+
+ /**
+ * Gets or sets the Boolean {@link Property} specifying whether the ellipse should be filled.
+ * @memberof DynamicEllipse.prototype
+ * @type {Property}
+ */
+ fill : createDynamicPropertyDescriptor('fill'),
+
+ /**
+ * Gets or sets the Boolean {@link Property} specifying whether the ellipse should be outlined.
+ * @memberof DynamicEllipse.prototype
+ * @type {Property}
+ */
+ outline : createDynamicPropertyDescriptor('outline'),
+
+ /**
+ * Gets or sets the Color {@link Property} specifying whether the color of the outline.
+ * @memberof DynamicEllipse.prototype
+ * @type {Property}
+ */
+ outlineColor : createDynamicPropertyDescriptor('outlineColor'),
+
+ /**
+ * Gets or sets the Number {@link Property} specifying the number of vertical lines
+ * to use when outlining the ellipse.
+ * @memberof DynamicEllipse.prototype
+ * @type {Property}
+ */
+ numberOfVerticalLines : createDynamicPropertyDescriptor('numberOfVerticalLines')
});
/**
@@ -86,6 +178,16 @@ define(['../Core/Cartesian3',
result.rotation = this.rotation;
result.semiMajorAxis = this.semiMajorAxis;
result.semiMinorAxis = this.semiMinorAxis;
+ result.show = this.show;
+ result.material = this.material;
+ result.height = this.height;
+ result.extrudedHeight = this.extrudedHeight;
+ result.granularity = this.granularity;
+ result.stRotation = this.stRotation;
+ result.fill = this.fill;
+ result.outline = this.outline;
+ result.outlineColor = this.outlineColor;
+ result.numberOfVerticalLines = this.numberOfVerticalLines;
return result;
};
@@ -106,60 +208,16 @@ define(['../Core/Cartesian3',
this.rotation = defaultValue(this.rotation, source.rotation);
this.semiMajorAxis = defaultValue(this.semiMajorAxis, source.semiMajorAxis);
this.semiMinorAxis = defaultValue(this.semiMinorAxis, source.semiMinorAxis);
- };
-
- /**
- * Gets an array of vertex positions for the ellipse at the provided time.
- *
- * @param {JulianDate} time The desired time.
- * @param {Ellipsoid} ellipsoid The ellipsoid on which the ellipse will be on.
- * @param {Cartesian3} position The position of the ellipsoid.
- * @returns An array of vertex positions.
- */
- DynamicEllipse.prototype.getValue = function(time, position) {
- var semiMajorAxisProperty = this._semiMajorAxis;
- var semiMinorAxisProperty = this._semiMinorAxis;
-
- if (!defined(position) || //
- !defined(semiMajorAxisProperty) || //
- !defined(semiMinorAxisProperty)) {
- return undefined;
- }
-
- var semiMajorAxis = semiMajorAxisProperty.getValue(time);
- var semiMinorAxis = semiMinorAxisProperty.getValue(time);
-
- var rotation = 0.0;
- var rotationProperty = this._rotation;
- if (defined(rotationProperty)) {
- rotation = rotationProperty.getValue(time);
- }
-
- if (!defined(semiMajorAxis) || //
- !defined(semiMinorAxis) || //
- semiMajorAxis === 0.0 || //
- semiMinorAxis === 0.0) {
- return undefined;
- }
-
- var lastPosition = this._lastPosition;
- var lastSemiMajorAxis = this._lastSemiMajorAxis;
- var lastSemiMinorAxis = this._lastSemiMinorAxis;
- var lastRotation = this._lastRotation;
- if (rotation !== lastRotation || //
- lastSemiMajorAxis !== semiMajorAxis || //
- lastSemiMinorAxis !== semiMinorAxis || //
- !Cartesian3.equals(lastPosition, position)) {
-
- //CZML_TODO The surface reference should come from CZML and not be hard-coded to Ellipsoid.WGS84.
- this._cachedVertexPositions = Shapes.computeEllipseBoundary(Ellipsoid.WGS84, position, semiMajorAxis, semiMinorAxis, rotation);
- this._lastPosition = Cartesian3.clone(position, this._lastPosition);
- this._lastRotation = rotation;
- this._lastSemiMajorAxis = semiMajorAxis;
- this._lastSemiMinorAxis = semiMinorAxis;
- }
-
- return this._cachedVertexPositions;
+ this.show = defaultValue(this.show, source.show);
+ this.material = defaultValue(this.material, source.material);
+ this.height = defaultValue(this.height, source.height);
+ this.extrudedHeight = defaultValue(this.extrudedHeight, source.extrudedHeight);
+ this.granularity = defaultValue(this.granularity, source.granularity);
+ this.stRotation = defaultValue(this.stRotation, source.stRotation);
+ this.fill = defaultValue(this.fill, source.fill);
+ this.outline = defaultValue(this.outline, source.outline);
+ this.outlineColor = defaultValue(this.outlineColor, source.outlineColor);
+ this.numberOfVerticalLines = defaultValue(this.numberOfVerticalLines, source.numberOfVerticalLines);
};
return DynamicEllipse;
diff --git a/Source/DynamicScene/DynamicEllipsoid.js b/Source/DynamicScene/DynamicEllipsoid.js
index a4c536c3f493..918dff78b367 100644
--- a/Source/DynamicScene/DynamicEllipsoid.js
+++ b/Source/DynamicScene/DynamicEllipsoid.js
@@ -22,9 +22,18 @@ define(['../Core/defaultValue',
*/
var DynamicEllipsoid = function() {
this._show = undefined;
+ this._showSubscription = undefined;
this._radii = undefined;
+ this._radiiSubscription = undefined;
this._material = undefined;
- this._propertyChanged = new Event();
+ this._materialSubscription = undefined;
+ this._stackPartitions = undefined;
+ this._stackPartitionsSubscription = undefined;
+ this._slicePartitions = undefined;
+ this._slicePartitionsSubscription = undefined;
+ this._subdivisions = undefined;
+ this._subdivisionsSubscription = undefined;
+ this._definitionChanged = new Event();
};
defineProperties(DynamicEllipsoid.prototype, {
@@ -33,9 +42,9 @@ define(['../Core/defaultValue',
* @memberof DynamicEllipsoid.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
@@ -44,21 +53,63 @@ define(['../Core/defaultValue',
* @memberof DynamicEllipsoid.prototype
* @type {Property}
*/
- show : createDynamicPropertyDescriptor('show', '_show'),
+ show : createDynamicPropertyDescriptor('show'),
/**
* Gets or sets the {@link Cartesian3} {@link Property} specifying the radii of the ellipsoid.
* @memberof DynamicEllipsoid.prototype
* @type {Property}
*/
- radii : createDynamicPropertyDescriptor('radii', '_radii'),
+ radii : createDynamicPropertyDescriptor('radii'),
/**
* Gets or sets the {@link MaterialProperty} specifying the appearance of the ellipsoid.
* @memberof DynamicEllipsoid.prototype
* @type {MaterialProperty}
*/
- material : createDynamicPropertyDescriptor('material', '_material')
+ material : createDynamicPropertyDescriptor('material'),
+
+ /**
+ * Gets or sets the Boolean {@link Property} specifying whether the ellipsoid should be filled.
+ * @memberof DynamicEllipsoid.prototype
+ * @type {Property}
+ */
+ fill : createDynamicPropertyDescriptor('fill'),
+
+ /**
+ * Gets or sets the Boolean {@link Property} specifying whether the ellipsoid should be outlined.
+ * @memberof DynamicEllipsoid.prototype
+ * @type {Property}
+ */
+ outline : createDynamicPropertyDescriptor('outline'),
+
+ /**
+ * Gets or sets the Color {@link Property} specifying whether the color of the outline.
+ * @memberof DynamicEllipsoid.prototype
+ * @type {Property}
+ */
+ outlineColor : createDynamicPropertyDescriptor('outlineColor'),
+
+ /**
+ * Gets or sets the Number {@link Property} specifying the number of times to partition the ellipsoid into stacks.
+ * @memberof DynamicEllipsoid.prototype
+ * @type {Property}
+ */
+ stackPartitions : createDynamicPropertyDescriptor('stackPartitions'),
+
+ /**
+ * Gets or sets the Number {@link Property} specifying the number of times to partition the ellipsoid into radial slices.
+ * @memberof DynamicEllipsoid.prototype
+ * @type {Property}
+ */
+ slicePartitions : createDynamicPropertyDescriptor('slicePartitions'),
+
+ /**
+ * Gets or sets the Number {@link Property} specifying the number of points per line, determining the granularity of the curvature .
+ * @memberof DynamicEllipsoid.prototype
+ * @type {Property}
+ */
+ subdivisions : createDynamicPropertyDescriptor('subdivisions')
});
/**
@@ -75,6 +126,13 @@ define(['../Core/defaultValue',
result.show = this.show;
result.radii = this.radii;
result.material = this.material;
+ result.fill = this.fill;
+ result.outline = this.outline;
+ result.outlineColor = this.outlineColor;
+ result.stackPartitions = this.stackPartitions;
+ result.slicePartitions = this.slicePartitions;
+ result.subdivisions = this.subdivisions;
+
return result;
};
@@ -95,6 +153,12 @@ define(['../Core/defaultValue',
this.show = defaultValue(this.show, source.show);
this.radii = defaultValue(this.radii, source.radii);
this.material = defaultValue(this.material, source.material);
+ this.fill = defaultValue(this.fill, source.fill);
+ this.outline = defaultValue(this.outline, source.outline);
+ this.outlineColor = defaultValue(this.outlineColor, source.outlineColor);
+ this.stackPartitions = defaultValue(this.stackPartitions, source.stackPartitions);
+ this.slicePartitions = defaultValue(this.slicePartitions, source.slicePartitions);
+ this.subdivisions = defaultValue(this.subdivisions, source.subdivisions);
};
return DynamicEllipsoid;
diff --git a/Source/DynamicScene/DynamicEllipsoidVisualizer.js b/Source/DynamicScene/DynamicEllipsoidVisualizer.js
deleted file mode 100644
index 8a39146fa751..000000000000
--- a/Source/DynamicScene/DynamicEllipsoidVisualizer.js
+++ /dev/null
@@ -1,281 +0,0 @@
-/*global define*/
-define([
- '../Core/defaultValue',
- '../Core/defined',
- '../Core/DeveloperError',
- '../Core/destroyObject',
- '../Core/Cartesian3',
- '../Core/Matrix3',
- '../Core/Matrix4',
- '../Core/Quaternion',
- '../Scene/EllipsoidPrimitive',
- '../Scene/Material',
- './MaterialProperty'
- ], function(
- defaultValue,
- defined,
- DeveloperError,
- destroyObject,
- Cartesian3,
- Matrix3,
- Matrix4,
- Quaternion,
- EllipsoidPrimitive,
- Material,
- MaterialProperty) {
- "use strict";
-
- var matrix3Scratch = new Matrix3();
-
- /**
- * A DynamicObject visualizer which maps the DynamicEllipsoid instance
- * in DynamicObject.ellipsoid to a Ellipsoid primitive.
- * @alias DynamicEllipsoidVisualizer
- * @constructor
- *
- * @param {Scene} scene The scene the primitives will be rendered in.
- * @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize.
- *
- * @see DynamicEllipsoid
- * @see Scene
- * @see DynamicObject
- * @see DynamicObjectCollection
- * @see CompositeDynamicObjectCollection
- * @see VisualizerCollection
- * @see DynamicBillboardVisualizer
- * @see DynamicConeVisualizer
- * @see DynamicConeVisualizerUsingCustomSensorr
- * @see DynamicLabelVisualizer
- * @see DynamicPointVisualizer
- * @see DynamicPolygonVisualizer
- * @see DynamicPolylineVisualizer
- */
- var DynamicEllipsoidVisualizer = function(scene, dynamicObjectCollection) {
- //>>includeStart('debug', pragmas.debug);
- if (!defined(scene)) {
- throw new DeveloperError('scene is required.');
- }
- //>>includeEnd('debug');
-
- this._scene = scene;
- this._unusedIndexes = [];
- this._primitives = scene.getPrimitives();
- this._ellipsoidCollection = [];
- this._dynamicObjectCollection = undefined;
- this.setDynamicObjectCollection(dynamicObjectCollection);
- };
-
- /**
- * Returns the scene being used by this visualizer.
- *
- * @returns {Scene} The scene being used by this visualizer.
- */
- DynamicEllipsoidVisualizer.prototype.getScene = function() {
- return this._scene;
- };
-
- /**
- * Gets the DynamicObjectCollection being visualized.
- *
- * @returns {DynamicObjectCollection} The DynamicObjectCollection being visualized.
- */
- DynamicEllipsoidVisualizer.prototype.getDynamicObjectCollection = function() {
- return this._dynamicObjectCollection;
- };
-
- /**
- * Sets the DynamicObjectCollection to visualize.
- *
- * @param dynamicObjectCollection The DynamicObjectCollection to visualizer.
- */
- DynamicEllipsoidVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) {
- var oldCollection = this._dynamicObjectCollection;
- if (oldCollection !== dynamicObjectCollection) {
- if (defined(oldCollection)) {
- oldCollection.collectionChanged.removeEventListener(DynamicEllipsoidVisualizer.prototype._onObjectsRemoved, this);
- this.removeAllPrimitives();
- }
- this._dynamicObjectCollection = dynamicObjectCollection;
- if (defined(dynamicObjectCollection)) {
- dynamicObjectCollection.collectionChanged.addEventListener(DynamicEllipsoidVisualizer.prototype._onObjectsRemoved, this);
- }
- }
- };
-
- /**
- * Updates all of the primitives created by this visualizer to match their
- * DynamicObject counterpart at the given time.
- *
- * @param {JulianDate} time The time to update to.
- */
- DynamicEllipsoidVisualizer.prototype.update = function(time) {
- //>>includeStart('debug', pragmas.debug);
- if (!defined(time)) {
- throw new DeveloperError('time is requied.');
- }
- //>>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]);
- }
- }
- };
-
- /**
- * Removes all primitives from the scene.
- */
- DynamicEllipsoidVisualizer.prototype.removeAllPrimitives = function() {
- var i, len;
- for (i = 0, len = this._ellipsoidCollection.length; i < len; i++) {
- this._primitives.remove(this._ellipsoidCollection[i]);
- }
-
- if (defined(this._dynamicObjectCollection)) {
- var dynamicObjects = this._dynamicObjectCollection.getObjects();
- for (i = dynamicObjects.length - 1; i > -1; i--) {
- dynamicObjects[i]._ellipsoidVisualizerIndex = undefined;
- }
- }
-
- this._unusedIndexes = [];
- this._ellipsoidCollection = [];
- };
-
- /**
- * Returns true if this object was destroyed; otherwise, false.
- * isDestroyed
will result in a {@link DeveloperError} exception.
- *
- * @memberof DynamicEllipsoidVisualizer
- *
- * @returns {Boolean} True if this object was destroyed; otherwise, false.
- *
- * @see DynamicEllipsoidVisualizer#destroy
- */
- DynamicEllipsoidVisualizer.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.
- * isDestroyed
will result in a {@link DeveloperError} exception. Therefore,
- * assign the return value (undefined
) to the object as done in the example.
- *
- * @memberof DynamicEllipsoidVisualizer
- *
- * @returns {undefined}
- *
- * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
- *
- * @see DynamicEllipsoidVisualizer#isDestroyed
- *
- * @example
- * visualizer = visualizer && visualizer.destroy();
- */
- DynamicEllipsoidVisualizer.prototype.destroy = function() {
- this.setDynamicObjectCollection(undefined);
- return destroyObject(this);
- };
-
- var position;
- var orientation;
- function updateObject(dynamicEllipsoidVisualizer, time, dynamicObject) {
- var dynamicEllipsoid = dynamicObject._ellipsoid;
- if (!defined(dynamicEllipsoid)) {
- return;
- }
-
- var radiiProperty = dynamicEllipsoid._radii;
- if (!defined(radiiProperty)) {
- return;
- }
-
- var positionProperty = dynamicObject._position;
- if (!defined(positionProperty)) {
- return;
- }
-
- var orientationProperty = dynamicObject._orientation;
- if (!defined(orientationProperty)) {
- return;
- }
-
- var ellipsoid;
- var showProperty = dynamicEllipsoid._show;
- var ellipsoidVisualizerIndex = dynamicObject._ellipsoidVisualizerIndex;
- var show = dynamicObject.isAvailable(time) && (!defined(showProperty) || showProperty.getValue(time));
-
- if (!show) {
- //don't bother creating or updating anything else
- if (defined(ellipsoidVisualizerIndex)) {
- ellipsoid = dynamicEllipsoidVisualizer._ellipsoidCollection[ellipsoidVisualizerIndex];
- ellipsoid.show = false;
- dynamicObject._ellipsoidVisualizerIndex = undefined;
- dynamicEllipsoidVisualizer._unusedIndexes.push(ellipsoidVisualizerIndex);
- }
- return;
- }
-
- if (!defined(ellipsoidVisualizerIndex)) {
- var unusedIndexes = dynamicEllipsoidVisualizer._unusedIndexes;
- var length = unusedIndexes.length;
- if (length > 0) {
- ellipsoidVisualizerIndex = unusedIndexes.pop();
- ellipsoid = dynamicEllipsoidVisualizer._ellipsoidCollection[ellipsoidVisualizerIndex];
- } else {
- ellipsoidVisualizerIndex = dynamicEllipsoidVisualizer._ellipsoidCollection.length;
- ellipsoid = new EllipsoidPrimitive();
-
- dynamicEllipsoidVisualizer._ellipsoidCollection.push(ellipsoid);
- dynamicEllipsoidVisualizer._primitives.add(ellipsoid);
- }
- dynamicObject._ellipsoidVisualizerIndex = ellipsoidVisualizerIndex;
- ellipsoid.dynamicObject = dynamicObject;
-
- ellipsoid.material = Material.fromType(Material.ColorType);
- } else {
- ellipsoid = dynamicEllipsoidVisualizer._ellipsoidCollection[ellipsoidVisualizerIndex];
- }
-
- ellipsoid.show = true;
-
- ellipsoid.radii = radiiProperty.getValue(time, ellipsoid.radii);
-
- position = defaultValue(positionProperty.getValue(time, position), ellipsoid._visualizerPosition);
- orientation = defaultValue(orientationProperty.getValue(time, orientation), ellipsoid._visualizerOrientation);
-
- if (defined(position) &&
- defined(orientation) &&
- (!Cartesian3.equals(position, ellipsoid._visualizerPosition) ||
- !Quaternion.equals(orientation, ellipsoid._visualizerOrientation))) {
- Matrix4.fromRotationTranslation(Matrix3.fromQuaternion(orientation, matrix3Scratch), position, ellipsoid.modelMatrix);
- ellipsoid._visualizerPosition = Cartesian3.clone(position, ellipsoid._visualizerPosition);
- ellipsoid._visualizerOrientation = Quaternion.clone(orientation, ellipsoid._visualizerOrientation);
- }
-
- ellipsoid.material = MaterialProperty.getValue(time, dynamicEllipsoid._material, ellipsoid.material);
- }
-
- DynamicEllipsoidVisualizer.prototype._onObjectsRemoved = function(dynamicObjectCollection, added, dynamicObjects) {
- var thisEllipsoidCollection = this._ellipsoidCollection;
- var thisUnusedIndexes = this._unusedIndexes;
- for ( var i = dynamicObjects.length - 1; i > -1; i--) {
- var dynamicObject = dynamicObjects[i];
- var ellipsoidVisualizerIndex = dynamicObject._ellipsoidVisualizerIndex;
- if (defined(ellipsoidVisualizerIndex)) {
- var ellipsoid = thisEllipsoidCollection[ellipsoidVisualizerIndex];
- ellipsoid.show = false;
- thisUnusedIndexes.push(ellipsoidVisualizerIndex);
- dynamicObject._ellipsoidVisualizerIndex = undefined;
- }
- }
- };
-
- return DynamicEllipsoidVisualizer;
-});
diff --git a/Source/DynamicScene/DynamicGeometryUpdater.js b/Source/DynamicScene/DynamicGeometryUpdater.js
new file mode 100644
index 000000000000..6b3d456498c9
--- /dev/null
+++ b/Source/DynamicScene/DynamicGeometryUpdater.js
@@ -0,0 +1,48 @@
+/*global define*/
+define(['../Core/DeveloperError'
+ ], function(
+ DeveloperError) {
+ "use strict";
+
+ /**
+ * Defines the interface for a dynamic geometry updater. A DynamicGeometryUpdater
+ * is responsible for handling visualization of a specific type of geometry
+ * that needs to be recomputed based on simulation time.
+ * This object is never used directly by client code, but is instead created by
+ * {@link GeometryUpdater} implementations which contain dynamic geometry.
+ *
+ * This type defines an interface and cannot be instantiated directly.
+ *
+ * @alias DynamicGeometryUpdater
+ * @constructor
+ */
+ var DynamicGeometryUpdater = function() {
+ DeveloperError.throwInstantiationError();
+ };
+
+ /**
+ * Updates the geometry to the specified time.
+ * @memberof DynamicGeometryUpdater
+ *
+ * @param {JulianDate} time The current time.
+ */
+ DynamicGeometryUpdater.prototype.update = DeveloperError.throwInstantiationError;
+
+ /**
+ * Returns true if this object was destroyed; otherwise, false.
+ * @memberof DynamicGeometryUpdater
+ *
+ * @returns {Boolean} True if this object was destroyed; otherwise, false.
+ */
+ DynamicGeometryUpdater.prototype.isDestroyed = DeveloperError.throwInstantiationError;
+
+ /**
+ * Destroys and resources used by the object. Once an object is destroyed, it should not be used.
+ * @memberof DynamicGeometryUpdater
+ *
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
+ */
+ DynamicGeometryUpdater.prototype.destroy = DeveloperError.throwInstantiationError;
+
+ return DynamicGeometryUpdater;
+});
\ No newline at end of file
diff --git a/Source/DynamicScene/DynamicLabel.js b/Source/DynamicScene/DynamicLabel.js
index fcb2d4bf802d..01b3a1b5c429 100644
--- a/Source/DynamicScene/DynamicLabel.js
+++ b/Source/DynamicScene/DynamicLabel.js
@@ -21,20 +21,34 @@ define(['../Core/defaultValue',
*/
var DynamicLabel = function() {
this._text = undefined;
+ this._textSubscription = undefined;
this._font = undefined;
+ this._fontSubscription = undefined;
this._style = undefined;
+ this._styleSubscription = undefined;
this._fillColor = undefined;
+ this._fillColorSubscription = undefined;
this._outlineColor = undefined;
+ this._outlineColorSubscription = undefined;
this._outlineWidth = undefined;
+ this._outlineWidthSubscription = undefined;
this._horizontalOrigin = undefined;
+ this._horizontalOriginSubscription = undefined;
this._verticalOrigin = undefined;
+ this._verticalOriginSubscription = undefined;
this._eyeOffset = undefined;
+ this._eyeOffsetSubscription = undefined;
this._pixelOffset = undefined;
+ this._pixelOffsetSubscription = undefined;
this._scale = undefined;
+ this._scaleSubscription = undefined;
this._show = undefined;
+ this._showSubscription = undefined;
this._translucencyByDistance = undefined;
+ this._translucencyByDistanceSubscription = undefined;
this._pixelOffsetScaleByDistance = undefined;
- this._propertyChanged = new Event();
+ this._pixelOffsetScaleByDistanceSubscription = undefined;
+ this._definitionChanged = new Event();
};
defineProperties(DynamicLabel.prototype, {
@@ -43,9 +57,9 @@ define(['../Core/defaultValue',
* @memberof DynamicLabel.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
@@ -54,84 +68,84 @@ define(['../Core/defaultValue',
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- text : createDynamicPropertyDescriptor('text', '_text'),
+ text : createDynamicPropertyDescriptor('text'),
/**
* Gets or sets the string {@link Property} specifying the the label's font.
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- font : createDynamicPropertyDescriptor('font', '_font'),
+ font : createDynamicPropertyDescriptor('font'),
/**
* Gets or sets the {@link LabelStyle} {@link Property} specifying the the label's style.
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- style : createDynamicPropertyDescriptor('style', '_style'),
+ style : createDynamicPropertyDescriptor('style'),
/**
* Gets or sets the {@link Color} {@link Property} specifying the the label's fill color.
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- fillColor : createDynamicPropertyDescriptor('fillColor', '_fillColor'),
+ fillColor : createDynamicPropertyDescriptor('fillColor'),
/**
* Gets or sets the {@link Color} {@link Property} specifying the the label's outline color.
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- outlineColor : createDynamicPropertyDescriptor('outlineColor', '_outlineColor'),
+ outlineColor : createDynamicPropertyDescriptor('outlineColor'),
/**
* Gets or sets the numeric {@link Property} specifying the the label outline's width.
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- outlineWidth : createDynamicPropertyDescriptor('outlineWidth', '_outlineWidth'),
+ outlineWidth : createDynamicPropertyDescriptor('outlineWidth'),
/**
* Gets or sets the {@link HorizontalOrigin} {@link Property} specifying the label's horizontal origin.
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- horizontalOrigin : createDynamicPropertyDescriptor('horizontalOrigin', '_horizontalOrigin'),
+ horizontalOrigin : createDynamicPropertyDescriptor('horizontalOrigin'),
/**
* Gets or sets the {@link VerticalOrigin} {@link Property} specifying the label's vertical origin.
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- verticalOrigin : createDynamicPropertyDescriptor('verticalOrigin', '_verticalOrigin'),
+ verticalOrigin : createDynamicPropertyDescriptor('verticalOrigin'),
/**
* Gets or sets the {@link Cartesian3} {@link Property} specifying the label's eye offset.
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- eyeOffset : createDynamicPropertyDescriptor('eyeOffset', '_eyeOffset'),
+ eyeOffset : createDynamicPropertyDescriptor('eyeOffset'),
/**
* Gets or sets the {@link Cartesian2} {@link Property} specifying the label's pixel offset.
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- pixelOffset : createDynamicPropertyDescriptor('pixelOffset', '_pixelOffset'),
+ pixelOffset : createDynamicPropertyDescriptor('pixelOffset'),
/**
* Gets or sets the numeric {@link Property} specifying the label's scale.
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- scale : createDynamicPropertyDescriptor('scale', '_scale'),
+ scale : createDynamicPropertyDescriptor('scale'),
/**
* Gets or sets the boolean {@link Property} specifying the label's visibility.
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- show : createDynamicPropertyDescriptor('show', '_show'),
+ show : createDynamicPropertyDescriptor('show'),
/**
* Gets or sets the {@link NearFarScalar} {@link Property} used to set translucency based on distance.
@@ -139,7 +153,7 @@ define(['../Core/defaultValue',
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- translucencyByDistance : createDynamicPropertyDescriptor('translucencyByDistance', '_translucencyByDistance'),
+ translucencyByDistance : createDynamicPropertyDescriptor('translucencyByDistance'),
/**
* Gets or sets the {@link NearFarScalar} {@link Property} used to set pixel offset scaling based on distance.
@@ -147,7 +161,7 @@ define(['../Core/defaultValue',
* @memberof DynamicLabel.prototype
* @type {Property}
*/
- pixelOffsetScaleByDistance : createDynamicPropertyDescriptor('pixelOffsetScaleByDistance', '_pixelOffsetScaleByDistance')
+ pixelOffsetScaleByDistance : createDynamicPropertyDescriptor('pixelOffsetScaleByDistance')
});
diff --git a/Source/DynamicScene/DynamicLabelVisualizer.js b/Source/DynamicScene/DynamicLabelVisualizer.js
index e2446bc36632..ea5edc73381c 100644
--- a/Source/DynamicScene/DynamicLabelVisualizer.js
+++ b/Source/DynamicScene/DynamicLabelVisualizer.js
@@ -37,13 +37,10 @@ define([
* @see DynamicObject
* @see DynamicObjectCollection
* @see CompositeDynamicObjectCollection
- * @see VisualizerCollection
* @see DynamicBillboardVisualizer
* @see DynamicConeVisualizer
- * @see DynamicConeVisualizerUsingCustomSensorr
+ * @see DynamicConeVisualizerUsingCustomSensor
* @see DynamicPointVisualizer
- * @see DynamicPolygonVisualizer
- * @see DynamicPolylineVisualizer
* @see DynamicPyramidVisualizer
*/
var DynamicLabelVisualizer = function(scene, dynamicObjectCollection) {
@@ -58,7 +55,7 @@ define([
this._dynamicObjectCollection = undefined;
var labelCollection = this._labelCollection = new LabelCollection();
- scene.getPrimitives().add(labelCollection);
+ scene.primitives.add(labelCollection);
this.setDynamicObjectCollection(dynamicObjectCollection);
};
@@ -108,7 +105,7 @@ define([
DynamicLabelVisualizer.prototype.update = function(time) {
//>>includeStart('debug', pragmas.debug);
if (!defined(time)) {
- throw new DeveloperError('time is requied.');
+ throw new DeveloperError('time is required.');
}
//>>includeEnd('debug');
@@ -171,7 +168,7 @@ define([
*/
DynamicLabelVisualizer.prototype.destroy = function() {
this.setDynamicObjectCollection(undefined);
- this._scene.getPrimitives().remove(this._labelCollection);
+ this._scene.primitives.remove(this._labelCollection);
return destroyObject(this);
};
@@ -223,7 +220,7 @@ define([
label = dynamicLabelVisualizer._labelCollection.add();
}
dynamicObject._labelVisualizerIndex = labelVisualizerIndex;
- label.dynamicObject = dynamicObject;
+ label.id = dynamicObject;
// CZML_TODO Determine official defaults
label.setText('');
diff --git a/Source/DynamicScene/DynamicObject.js b/Source/DynamicScene/DynamicObject.js
index ad2aa5773754..af5f769e44c3 100644
--- a/Source/DynamicScene/DynamicObject.js
+++ b/Source/DynamicScene/DynamicObject.js
@@ -20,7 +20,7 @@ define(['../Core/createGuid',
createDynamicPropertyDescriptor) {
"use strict";
- var reservedPropertyNames = ['cachedAvailabilityDate', 'cachedAvailabilityValue', 'id', 'propertyChanged', //
+ var reservedPropertyNames = ['cachedAvailabilityDate', 'cachedAvailabilityValue', 'id', 'definitionChanged', //
'propertyNames', 'isAvailable', 'clean', 'merge', 'addProperty', 'removeProperty'];
/**
@@ -45,26 +45,43 @@ define(['../Core/createGuid',
this._id = id;
this._availability = undefined;
+ this._parent = undefined;
+ this._name = undefined;
+ this._definitionChanged = new Event();
+
this._position = undefined;
+ this._positionSubscription = undefined;
this._orientation = undefined;
+ this._orientationSubscription = undefined;
this._billboard = undefined;
+ this._billboardSubscription = undefined;
this._cone = undefined;
+ this._coneSubscription = undefined;
this._ellipsoid = undefined;
+ this._ellipsoidSubscription = undefined;
this._ellipse = undefined;
+ this._ellipseSubscription = undefined;
this._label = undefined;
- this._name = undefined;
- this._parent = undefined;
+ this._labelSubscription = undefined;
this._path = undefined;
+ this._pathSubscription = undefined;
this._point = undefined;
+ this._pointSubscription = undefined;
this._polygon = undefined;
+ this._polygonSubscription = undefined;
this._polyline = undefined;
+ this._polylineSubscription = undefined;
this._pyramid = undefined;
+ this._pyramidSubscription = undefined;
this._vertexPositions = undefined;
+ this._vertexPositionsSubscription = undefined;
this._vector = undefined;
+ this._vectorSubscription = undefined;
this._viewFrom = undefined;
+ this._viewFromSubscription = undefined;
this._description = undefined;
+ this._descriptionSubscription = undefined;
- this._propertyChanged = new Event();
this._propertyNames = ['parent', 'position', 'orientation', 'billboard', //
'cone', 'ellipsoid', 'ellipse', 'label', 'path', 'point', 'polygon', //
'polyline', 'pyramid', 'vertexPositions', 'vector', 'viewFrom', 'description'];
@@ -76,9 +93,9 @@ define(['../Core/createGuid',
* @memberof DynamicObject.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
/**
@@ -116,7 +133,7 @@ define(['../Core/createGuid',
var oldValue = this._name;
if (oldValue !== value) {
this._name = value;
- this._propertyChanged.raiseEvent(this, 'name', value, oldValue);
+ this._definitionChanged.raiseEvent(this, 'name', value, oldValue);
}
}
},
@@ -129,111 +146,111 @@ define(['../Core/createGuid',
* @memberof DynamicObject.prototype
* @type {TimeIntervalCollection}
*/
- availability : createDynamicPropertyDescriptor('availability', '_availability'),
+ availability : createDynamicPropertyDescriptor('availability'),
/**
* Gets or sets the position.
* @memberof DynamicObject.prototype
* @type {PositionProperty}
*/
- position : createDynamicPropertyDescriptor('position', '_position'),
+ position : createDynamicPropertyDescriptor('position'),
/**
* Gets or sets the orientation.
* @memberof DynamicObject.prototype
* @type {Property}
*/
- orientation : createDynamicPropertyDescriptor('orientation', '_orientation'),
+ orientation : createDynamicPropertyDescriptor('orientation'),
/**
* Gets or sets the suggested initial offset for viewing this object
* with the camera. The offset is defined in the east-north-up reference frame.
* @memberof DynamicObject.prototype
* @type {Cartesian3}
*/
- viewFrom : createDynamicPropertyDescriptor('viewFrom', '_viewFrom'),
+ viewFrom : createDynamicPropertyDescriptor('viewFrom'),
/**
* Gets or sets the billboard.
* @memberof DynamicObject.prototype
* @type {DynamicBillboard}
*/
- billboard : createDynamicPropertyDescriptor('billboard', '_billboard'),
+ billboard : createDynamicPropertyDescriptor('billboard'),
/**
* Gets or sets the cone.
* @memberof DynamicObject.prototype
* @type {DynamicCone}
*/
- cone : createDynamicPropertyDescriptor('cone', '_cone'),
+ cone : createDynamicPropertyDescriptor('cone'),
/**
* Gets or sets the ellipsoid.
* @memberof DynamicObject.prototype
* @type {DynamicEllipsoid}
*/
- ellipsoid : createDynamicPropertyDescriptor('ellipsoid', '_ellipsoid'),
+ ellipsoid : createDynamicPropertyDescriptor('ellipsoid'),
/**
* Gets or sets the ellipse.
* @memberof DynamicObject.prototype
* @type {DynamicEllipse}
*/
- ellipse : createDynamicPropertyDescriptor('ellipse', '_ellipse'),
+ ellipse : createDynamicPropertyDescriptor('ellipse'),
/**
* Gets or sets the label.
* @memberof DynamicObject.prototype
* @type {DynamicLabel}
*/
- label : createDynamicPropertyDescriptor('label', '_label'),
+ label : createDynamicPropertyDescriptor('label'),
/**
* Gets or sets the parent object.
* @memberof DynamicObject.prototype
* @type {DynamicObject}
*/
- parent : createDynamicPropertyDescriptor('parent', '_parent'),
+ parent : createDynamicPropertyDescriptor('parent'),
/**
* Gets or sets the path.
* @memberof DynamicObject.prototype
* @type {DynamicPath}
*/
- path : createDynamicPropertyDescriptor('path', '_path'),
+ path : createDynamicPropertyDescriptor('path'),
/**
* Gets or sets the point graphic.
* @memberof DynamicObject.prototype
* @type {DynamicPoint}
*/
- point : createDynamicPropertyDescriptor('point', '_point'),
+ point : createDynamicPropertyDescriptor('point'),
/**
* Gets or sets the polygon.
* @memberof DynamicObject.prototype
* @type {DynamicPolygon}
*/
- polygon : createDynamicPropertyDescriptor('polygon', '_polygon'),
+ polygon : createDynamicPropertyDescriptor('polygon'),
/**
* Gets or sets the polyline.
* @memberof DynamicObject.prototype
* @type {DynamicPolyline}
*/
- polyline : createDynamicPropertyDescriptor('polyline', '_polyline'),
+ polyline : createDynamicPropertyDescriptor('polyline'),
/**
* Gets or sets the pyramid.
* @memberof DynamicObject.prototype
* @type {DynamicPyramid}
*/
- pyramid : createDynamicPropertyDescriptor('pyramid', '_pyramid'),
+ pyramid : createDynamicPropertyDescriptor('pyramid'),
/**
* Gets or sets the vertex positions.
* @memberof DynamicObject.prototype
* @type {Property}
*/
- vertexPositions : createDynamicPropertyDescriptor('vertexPositions', '_vertexPositions'),
+ vertexPositions : createDynamicPropertyDescriptor('vertexPositions'),
/**
* Gets or sets the vector.
* @memberof DynamicObject.prototype
* @type {DynamicVector}
*/
- vector : createDynamicPropertyDescriptor('vector', '_vector'),
+ vector : createDynamicPropertyDescriptor('vector'),
/**
* Gets or sets the description.
* @memberof DynamicObject.prototype
* @type {Property}
*/
- description : createDynamicPropertyDescriptor('description', '_description')
+ description : createDynamicPropertyDescriptor('description')
});
/**
@@ -256,7 +273,7 @@ define(['../Core/createGuid',
/**
* Adds a property to this object. Once a property is added, it can be
- * observed with {@link DynamicObject.propertyChanged} and composited
+ * observed with {@link DynamicObject.definitionChanged} and composited
* with {@link CompositeDynamicObjectCollection}
* @memberof DynamicObject
*
@@ -281,7 +298,7 @@ define(['../Core/createGuid',
//>>includeEnd('debug');
propertyNames.push(propertyName);
- Object.defineProperty(this, propertyName, createDynamicPropertyDescriptor(propertyName, '_' + propertyName, true));
+ Object.defineProperty(this, propertyName, createDynamicPropertyDescriptor(propertyName, true));
};
/**
diff --git a/Source/DynamicScene/DynamicObjectCollection.js b/Source/DynamicScene/DynamicObjectCollection.js
index ffa3def97903..86b35e2c0926 100644
--- a/Source/DynamicScene/DynamicObjectCollection.js
+++ b/Source/DynamicScene/DynamicObjectCollection.js
@@ -1,5 +1,6 @@
/*global define*/
-define(['../Core/createGuid',
+define(['../Core/AssociativeArray',
+ '../Core/createGuid',
'../Core/defined',
'../Core/defineProperties',
'../Core/Event',
@@ -9,6 +10,7 @@ define(['../Core/createGuid',
'../Core/RuntimeError',
'./DynamicObject'
], function(
+ AssociativeArray,
createGuid,
defined,
defineProperties,
@@ -22,14 +24,12 @@ define(['../Core/createGuid',
function fireChangedEvent(collection) {
if (collection._suspendCount === 0) {
- var added = collection._added;
- var removed = collection._removed;
+ var added = collection._addedObjects;
+ var removed = collection._removedObjects;
if (added.length !== 0 || removed.length !== 0) {
- collection._collectionChanged.raiseEvent(collection, added, removed);
- added.length = 0;
- removed.length = 0;
- collection._addedHash = {};
- collection._removedHash = {};
+ collection._collectionChanged.raiseEvent(collection, added.values, removed.values);
+ added.removeAll();
+ removed.removeAll();
}
}
}
@@ -40,12 +40,9 @@ define(['../Core/createGuid',
* @constructor
*/
var DynamicObjectCollection = function() {
- this._array = [];
- this._hash = {};
- this._added = [];
- this._addedHash = {};
- this._removed = [];
- this._removedHash = {};
+ this._objects = new AssociativeArray();
+ this._addedObjects = new AssociativeArray();
+ this._removedObjects = new AssociativeArray();
this._suspendCount = 0;
this._collectionChanged = new Event();
this._id = createGuid();
@@ -134,7 +131,7 @@ define(['../Core/createGuid',
DynamicObjectCollection.prototype.computeAvailability = function() {
var startTime = Iso8601.MAXIMUM_VALUE;
var stopTime = Iso8601.MINIMUM_VALUE;
- var dynamicObjects = this._array;
+ var dynamicObjects = this._objects.values;
for ( var i = 0, len = dynamicObjects.length; i < len; i++) {
var object = dynamicObjects[i];
var availability = object.availability;
@@ -174,26 +171,16 @@ define(['../Core/createGuid',
//>>includeEnd('debug');
var id = dynamicObject.id;
- var hash = this._hash;
- if (defined(hash[id])) {
+ var objects = this._objects;
+ if (defined(objects.get(id))) {
throw new RuntimeError('An object with id ' + id + ' already exists in this collection.');
}
- hash[id] = dynamicObject;
- this._array.push(dynamicObject);
+ objects.set(id, dynamicObject);
- var removed = this._removed;
- var index = -1;
- var removedObject = this._removedHash[id];
- if (defined(removedObject)) {
- index = removed.indexOf(removedObject);
- }
- if (index !== -1) {
- removed.splice(index, 1);
- this._removedHash[id] = undefined;
- } else {
- this._added.push(dynamicObject);
- this._addedHash[id] = dynamicObject;
+ var removedObjects = this._removedObjects;
+ if (!this._removedObjects.remove(id)) {
+ this._addedObjects.set(id, dynamicObject);
}
fireChangedEvent(this);
};
@@ -229,30 +216,18 @@ define(['../Core/createGuid',
}
//>>includeEnd('debug');
- var hash = this._hash;
- var array = this._array;
- var dynamicObject = hash[id];
- var result = defined(dynamicObject);
- if (result) {
- hash[id] = undefined;
- array.splice(array.indexOf(dynamicObject), 1);
+ var objects = this._objects;
+ var dynamicObject = objects.get(id);
+ if (!this._objects.remove(id)) {
+ return false;
+ }
- var added = this._added;
- var index = -1;
- var addedObject = this._addedHash[id];
- if (defined(addedObject)) {
- index = added.indexOf(addedObject);
- }
- if (index !== -1) {
- added.splice(index, 1);
- this._addedHash[id] = undefined;
- } else {
- this._removed.push(dynamicObject);
- this._removedHash[id] = dynamicObject;
- }
- fireChangedEvent(this);
+ if (!this._addedObjects.remove(id)) {
+ this._removedObjects.set(id, dynamicObject);
}
- return result;
+ fireChangedEvent(this);
+
+ return true;
};
/**
@@ -262,29 +237,24 @@ define(['../Core/createGuid',
DynamicObjectCollection.prototype.removeAll = function() {
//The event should only contain items added before events were suspended
//and the contents of the collection.
- var array = this._array;
- var arrayLength = array.length;
+ var objects = this._objects;
+ var objectsLength = objects.length;
+ var array = objects.values;
- var removed = this._removed;
- var removedHash = this._removedHash;
+ var addedObjects = this._addedObjects;
+ var removed = this._removedObjects;
- var addedHash = this._addedHash;
-
- for ( var i = 0; i < arrayLength; i++) {
+ for (var i = 0; i < objectsLength; i++) {
var existingItem = array[i];
var existingItemId = existingItem.id;
- var addedItem = addedHash[existingItemId];
+ var addedItem = addedObjects.get(existingItemId);
if (!defined(addedItem)) {
- removed.push(existingItem);
- removedHash[existingItemId] = existingItem;
+ removed.set(existingItemId, existingItem);
}
}
- this._addedHash = {};
- this._added.length = 0;
- array.length = 0;
- this._hash = {};
-
+ objects.removeAll();
+ addedObjects.removeAll();
fireChangedEvent(this);
};
@@ -302,7 +272,7 @@ define(['../Core/createGuid',
}
//>>includeEnd('debug');
- return this._hash[id];
+ return this._objects.get(id);
};
/**
@@ -313,7 +283,7 @@ define(['../Core/createGuid',
* @returns {Array} the array of DynamicObject instances in the collection.
*/
DynamicObjectCollection.prototype.getObjects = function() {
- return this._array;
+ return this._objects.values;
};
/**
@@ -330,7 +300,7 @@ define(['../Core/createGuid',
}
//>>includeEnd('debug');
- var dynamicObject = this._hash[id];
+ var dynamicObject = this._objects.get(id);
if (!defined(dynamicObject)) {
dynamicObject = new DynamicObject(id);
this.add(dynamicObject);
diff --git a/Source/DynamicScene/DynamicObjectView.js b/Source/DynamicScene/DynamicObjectView.js
index ebc7362e6289..88aedc638ee9 100644
--- a/Source/DynamicScene/DynamicObjectView.js
+++ b/Source/DynamicScene/DynamicObjectView.js
@@ -187,8 +187,6 @@ define([
controller.setEllipsoid(Ellipsoid.UNIT_SPHERE);
controller.columbusViewMode = CameraColumbusViewMode.LOCKED;
- camera.controller.constrainedAxis = Cartesian3.UNIT_Z;
-
var position = camera.position;
Cartesian3.clone(position, that._lastOffset);
that._lastDistance = Cartesian3.magnitude(position);
@@ -200,7 +198,6 @@ define([
function update3DController(that, camera, objectChanged, offset) {
var scene = that.scene;
- camera.controller.constrainedAxis = Cartesian3.UNIT_Z;
if (objectChanged) {
camera.controller.lookAt(offset, Cartesian3.ZERO, Cartesian3.UNIT_Z);
@@ -319,7 +316,7 @@ define([
if (scene !== this._lastScene) {
this._lastScene = scene;
- this._screenSpaceCameraController = scene.getScreenSpaceCameraController();
+ this._screenSpaceCameraController = scene.screenSpaceCameraController;
}
var positionProperty = dynamicObject.position;
@@ -357,11 +354,11 @@ define([
var mode = scene.mode;
if (mode === SceneMode.SCENE2D) {
- update2D(this, scene.getCamera(), objectChanged, offset, positionProperty, time, ellipsoid, scene.scene2D.projection);
+ update2D(this, scene.camera, objectChanged, offset, positionProperty, time, ellipsoid, scene.scene2D.projection);
} else if (mode === SceneMode.SCENE3D) {
- update3D(this, scene.getCamera(), objectChanged, offset, positionProperty, time, ellipsoid);
+ update3D(this, scene.camera, objectChanged, offset, positionProperty, time, ellipsoid);
} else if (mode === SceneMode.COLUMBUS_VIEW) {
- updateColumbus(this, scene.getCamera(), objectChanged, offset, positionProperty, time, ellipsoid, scene.scene2D.projection);
+ updateColumbus(this, scene.camera, objectChanged, offset, positionProperty, time, ellipsoid, scene.scene2D.projection);
}
};
diff --git a/Source/DynamicScene/DynamicPath.js b/Source/DynamicScene/DynamicPath.js
index 42d3de21209d..8d317e393767 100644
--- a/Source/DynamicScene/DynamicPath.js
+++ b/Source/DynamicScene/DynamicPath.js
@@ -21,14 +21,23 @@ define(['../Core/defaultValue',
*/
var DynamicPath = function() {
this._color = undefined;
+ this._colorSubscription = undefined;
this._outlineColor = undefined;
+ this._outlineColorSubscription = undefined;
this._outlineWidth = undefined;
+ this._outlineWidthSubscription = undefined;
this._show = undefined;
+ this._showSubscription = undefined;
this._width = undefined;
+ this._widthSubscription = undefined;
this._resolution = undefined;
+ this._resolutionSubscription = undefined;
this._leadTime = undefined;
+ this._leadTimeSubscription = undefined;
this._trailTime = undefined;
- this._propertyChanged = new Event();
+ this._trailTimeSubscription = undefined;
+
+ this._definitionChanged = new Event();
};
defineProperties(DynamicPath.prototype, {
@@ -37,9 +46,9 @@ define(['../Core/defaultValue',
* @memberof DynamicPath.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
@@ -48,56 +57,56 @@ define(['../Core/defaultValue',
* @memberof DynamicPath.prototype
* @type {Property}
*/
- color : createDynamicPropertyDescriptor('color', '_color'),
+ color : createDynamicPropertyDescriptor('color'),
/**
* Gets or sets the {@link Color} {@link Property} specifying the the path's outline color.
* @memberof DynamicPath.prototype
* @type {Property}
*/
- outlineColor : createDynamicPropertyDescriptor('outlineColor', '_outlineColor'),
+ outlineColor : createDynamicPropertyDescriptor('outlineColor'),
/**
* Gets or sets the numeric {@link Property} specifying the the path's outline width.
* @memberof DynamicPath.prototype
* @type {Property}
*/
- outlineWidth : createDynamicPropertyDescriptor('outlineWidth', '_outlineWidth'),
+ outlineWidth : createDynamicPropertyDescriptor('outlineWidth'),
/**
* Gets or sets the boolean {@link Property} specifying the path's visibility.
* @memberof DynamicPath.prototype
* @type {Property}
*/
- show : createDynamicPropertyDescriptor('show', '_show'),
+ show : createDynamicPropertyDescriptor('show'),
/**
* Gets or sets the numeric {@link Property} specifying the the path's width.
* @memberof DynamicPath.prototype
* @type {Property}
*/
- width : createDynamicPropertyDescriptor('width', '_width'),
+ width : createDynamicPropertyDescriptor('width'),
/**
* Gets or sets the numeric {@link Property} specifying the maximum step size, in seconds, to take when sampling the position.
* @memberof DynamicPath.prototype
* @type {Property}
*/
- resolution : createDynamicPropertyDescriptor('resolution', '_resolution'),
+ resolution : createDynamicPropertyDescriptor('resolution'),
/**
* Gets or sets the numeric {@link Property} specifying the number of seconds in front of the object to show.
* @memberof DynamicPath.prototype
* @type {Property}
*/
- leadTime : createDynamicPropertyDescriptor('leadTime', '_leadTime'),
+ leadTime : createDynamicPropertyDescriptor('leadTime'),
/**
* Gets or sets the numeric {@link Property} specifying the number of seconds behind the object to show.
* @memberof DynamicPath.prototype
* @type {Property}
*/
- trailTime : createDynamicPropertyDescriptor('trailTime', '_trailTime')
+ trailTime : createDynamicPropertyDescriptor('trailTime')
});
/**
diff --git a/Source/DynamicScene/DynamicPathVisualizer.js b/Source/DynamicScene/DynamicPathVisualizer.js
index 024e5269f30c..da5e77a16a09 100644
--- a/Source/DynamicScene/DynamicPathVisualizer.js
+++ b/Source/DynamicScene/DynamicPathVisualizer.js
@@ -203,7 +203,7 @@ define([
this._polylineCollection = new PolylineCollection();
this._scene = scene;
this._referenceFrame = referenceFrame;
- scene.getPrimitives().add(this._polylineCollection);
+ scene.primitives.add(this._polylineCollection);
};
PolylineUpdater.prototype.update = function(time) {
@@ -310,7 +310,7 @@ define([
polyline = this._polylineCollection.add();
}
dynamicObject._pathVisualizerIndex = pathVisualizerIndex;
- polyline.dynamicObject = dynamicObject;
+ polyline.id = dynamicObject;
// CZML_TODO Determine official defaults
polyline.setWidth(1);
@@ -373,7 +373,7 @@ define([
};
PolylineUpdater.prototype.destroy = function() {
- this._scene.getPrimitives().remove(this._polylineCollection);
+ this._scene.primitives.remove(this._polylineCollection);
return destroyObject(this);
};
@@ -388,17 +388,13 @@ define([
*
* @see DynamicPath
* @see Polyline
- * @see Scene
* @see DynamicObject
- * @see DynamicObjectCollection
* @see CompositeDynamicObjectCollection
- * @see VisualizerCollection
* @see DynamicBillboardVisualizer
* @see DynamicConeVisualizer
- * @see DynamicConeVisualizerUsingCustomSensorr
+ * @see DynamicConeVisualizerUsingCustomSensor
* @see DynamicLabelVisualizer
* @see DynamicPointVisualizer
- * @see DynamicPolygonVisualizer
* @see DynamicPyramidVisualizer
*/
var DynamicPathVisualizer = function(scene, dynamicObjectCollection) {
@@ -460,7 +456,7 @@ define([
DynamicPathVisualizer.prototype.update = function(time) {
//>>includeStart('debug', pragmas.debug);
if (!defined(time)) {
- throw new DeveloperError('time is requied.');
+ throw new DeveloperError('time is required.');
}
//>>includeEnd('debug');
diff --git a/Source/DynamicScene/DynamicPoint.js b/Source/DynamicScene/DynamicPoint.js
index ffa8ccb028eb..5753e8e8af9f 100644
--- a/Source/DynamicScene/DynamicPoint.js
+++ b/Source/DynamicScene/DynamicPoint.js
@@ -21,12 +21,18 @@ define(['../Core/defaultValue',
*/
var DynamicPoint = function() {
this._color = undefined;
+ this._colorSubscription = undefined;
this._pixelSize = undefined;
+ this._pixelSizeSubscription = undefined;
this._outlineColor = undefined;
+ this._outlineColorSubscription = undefined;
this._outlineWidth = undefined;
+ this._outlineWidthSubscription = undefined;
this._show = undefined;
+ this._showSubscription = undefined;
this._scaleByDistance = undefined;
- this._propertyChanged = new Event();
+ this._scaleByDistanceSubscription = undefined;
+ this._definitionChanged = new Event();
};
defineProperties(DynamicPoint.prototype, {
@@ -35,9 +41,9 @@ define(['../Core/defaultValue',
* @memberof DynamicPoint.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
@@ -46,35 +52,35 @@ define(['../Core/defaultValue',
* @memberof DynamicPoint.prototype
* @type {Property}
*/
- color : createDynamicPropertyDescriptor('color', '_color'),
+ color : createDynamicPropertyDescriptor('color'),
/**
* Gets or sets the numeric {@link Property} specifying the point's size in pixels.
* @memberof DynamicPoint.prototype
* @type {Property}
*/
- pixelSize : createDynamicPropertyDescriptor('pixelSize', '_pixelSize'),
+ pixelSize : createDynamicPropertyDescriptor('pixelSize'),
/**
* Gets or sets the {@link Color} {@link Property} specifying the the point's outline color.
* @memberof DynamicPoint.prototype
* @type {Property}
*/
- outlineColor : createDynamicPropertyDescriptor('outlineColor', '_outlineColor'),
+ outlineColor : createDynamicPropertyDescriptor('outlineColor'),
/**
* Gets or sets the numeric {@link Property} specifying the the point's outline width.
* @memberof DynamicPoint.prototype
* @type {Property}
*/
- outlineWidth : createDynamicPropertyDescriptor('outlineWidth', '_outlineWidth'),
+ outlineWidth : createDynamicPropertyDescriptor('outlineWidth'),
/**
* Gets or sets the boolean {@link Property} specifying the point's visibility.
* @memberof DynamicPoint.prototype
* @type {Property}
*/
- show : createDynamicPropertyDescriptor('show', '_show'),
+ show : createDynamicPropertyDescriptor('show'),
/**
* Gets or sets the {@link NearFarScalar} {@link Property} used to scale billboards based on distance.
@@ -82,7 +88,7 @@ define(['../Core/defaultValue',
* @memberof DynamicBillboard.prototype
* @type {Property}
*/
- scaleByDistance : createDynamicPropertyDescriptor('scaleByDistance', '_scaleByDistance')
+ scaleByDistance : createDynamicPropertyDescriptor('scaleByDistance')
});
/**
diff --git a/Source/DynamicScene/DynamicPointVisualizer.js b/Source/DynamicScene/DynamicPointVisualizer.js
index d64e427c9c14..9e788032c3b2 100644
--- a/Source/DynamicScene/DynamicPointVisualizer.js
+++ b/Source/DynamicScene/DynamicPointVisualizer.js
@@ -31,13 +31,10 @@ define([
* @see DynamicObject
* @see DynamicObjectCollection
* @see CompositeDynamicObjectCollection
- * @see VisualizerCollection
* @see DynamicBillboardVisualizer
* @see DynamicConeVisualizer
- * @see DynamicConeVisualizerUsingCustomSensorr
+ * @see DynamicConeVisualizerUsingCustomSensor
* @see DynamicLabelVisualizer
- * @see DynamicPolygonVisualizer
- * @see DynamicPolylineVisualizer
* @see DynamicPyramidVisualizer
*/
var DynamicPointVisualizer = function(scene, dynamicObjectCollection) {
@@ -51,10 +48,10 @@ define([
this._unusedIndexes = [];
this._dynamicObjectCollection = undefined;
var billboardCollection = this._billboardCollection = new BillboardCollection();
- var atlas = this._textureAtlas = scene.getContext().createTextureAtlas();
+ var atlas = this._textureAtlas = scene.context.createTextureAtlas();
this._textureAtlasBuilder = new TextureAtlasBuilder(atlas);
billboardCollection.setTextureAtlas(atlas);
- scene.getPrimitives().add(billboardCollection);
+ scene.primitives.add(billboardCollection);
this.setDynamicObjectCollection(dynamicObjectCollection);
};
@@ -104,7 +101,7 @@ define([
DynamicPointVisualizer.prototype.update = function(time) {
//>>includeStart('debug', pragmas.debug);
if (!defined(time)) {
- throw new DeveloperError('time is requied.');
+ throw new DeveloperError('time is required.');
}
//>>includeEnd('debug');
@@ -167,7 +164,7 @@ define([
*/
DynamicPointVisualizer.prototype.destroy = function() {
this.setDynamicObjectCollection(undefined);
- this._scene.getPrimitives().remove(this._billboardCollection);
+ this._scene.primitives.remove(this._billboardCollection);
return destroyObject(this);
};
@@ -215,7 +212,7 @@ define([
billboard = dynamicPointVisualizer._billboardCollection.add();
}
dynamicObject._pointVisualizerIndex = pointVisualizerIndex;
- billboard.dynamicObject = dynamicObject;
+ billboard.id = dynamicObject;
// CZML_TODO Determine official defaults
billboard._visualizerColor = Color.clone(Color.WHITE, billboard._visualizerColor);
diff --git a/Source/DynamicScene/DynamicPolygon.js b/Source/DynamicScene/DynamicPolygon.js
index 48c8f1322626..35578b68f0a9 100644
--- a/Source/DynamicScene/DynamicPolygon.js
+++ b/Source/DynamicScene/DynamicPolygon.js
@@ -22,8 +22,20 @@ define(['../Core/defaultValue',
*/
var DynamicPolygon = function() {
this._show = undefined;
+ this._showSubscription = undefined;
this._material = undefined;
- this._propertyChanged = new Event();
+ this._materialSubscription = undefined;
+ this._height = undefined;
+ this._heightSubscription = undefined;
+ this._extrudedHeight = undefined;
+ this._extrudedHeightSubscription = undefined;
+ this._granularity = undefined;
+ this._granularitySubscription = undefined;
+ this._stRotation = undefined;
+ this._stRotationSubscription = undefined;
+ this._perPositionHeight = undefined;
+ this._perPositionHeightSubscription = undefined;
+ this._definitionChanged = new Event();
};
defineProperties(DynamicPolygon.prototype, {
@@ -32,9 +44,9 @@ define(['../Core/defaultValue',
* @memberof DynamicPolygon.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
@@ -43,14 +55,75 @@ define(['../Core/defaultValue',
* @memberof DynamicPolygon.prototype
* @type {Property}
*/
- show : createDynamicPropertyDescriptor('show', '_show'),
+ show : createDynamicPropertyDescriptor('show'),
/**
* Gets or sets the {@link MaterialProperty} specifying the appearance of the polygon.
* @memberof DynamicPolygon.prototype
* @type {MaterialProperty}
*/
- material : createDynamicPropertyDescriptor('material', '_material')
+ material : createDynamicPropertyDescriptor('material'),
+
+ /**
+ * Gets or sets the Number {@link Property} specifying the height of the polygon.
+ * If undefined, the polygon will be on the surface.
+ * @memberof DynamicPolygon.prototype
+ * @type {Property}
+ */
+ height : createDynamicPropertyDescriptor('height'),
+
+ /**
+ * Gets or sets the Number {@link Property} specifying the extruded height of the polygon.
+ * Setting this property creates a polygon shaped volume starting at height and ending
+ * at the extruded height.
+ * @memberof DynamicPolygon.prototype
+ * @type {Property}
+ */
+ extrudedHeight : createDynamicPropertyDescriptor('extrudedHeight'),
+
+ /**
+ * Gets or sets the Number {@link Property} specifying the sampling distance, in radians,
+ * between each latitude and longitude point.
+ * @memberof DynamicPolygon.prototype
+ * @type {Property}
+ */
+ granularity : createDynamicPropertyDescriptor('granularity'),
+
+ /**
+ * Gets or sets the Number {@link Property} specifying the rotation of the texture coordinates,
+ * in radians. A positive rotation is counter-clockwise.
+ * @memberof DynamicPolygon.prototype
+ * @type {Property}
+ */
+ stRotation : createDynamicPropertyDescriptor('stRotation'),
+
+ /**
+ * Gets or sets the Boolean {@link Property} specifying whether the polygon should be filled.
+ * @memberof DynamicPolygon.prototype
+ * @type {Property}
+ */
+ fill : createDynamicPropertyDescriptor('fill'),
+
+ /**
+ * Gets or sets the Boolean {@link Property} specifying whether the polygon should be outlined.
+ * @memberof DynamicPolygon.prototype
+ * @type {Property}
+ */
+ outline : createDynamicPropertyDescriptor('outline'),
+
+ /**
+ * Gets or sets the Color {@link Property} specifying whether the color of the outline.
+ * @memberof DynamicPolygon.prototype
+ * @type {Property}
+ */
+ outlineColor : createDynamicPropertyDescriptor('outlineColor'),
+
+ /**
+ * Gets or sets the Boolean {@link Property} specifying whether the polygon uses per-position heights.
+ * @memberof DynamicPolygon.prototype
+ * @type {Property}
+ */
+ perPositionHeight : createDynamicPropertyDescriptor('perPositionHeight')
});
/**
@@ -66,6 +139,14 @@ define(['../Core/defaultValue',
}
result.show = this.show;
result.material = this.material;
+ result.height = this.height;
+ result.extrudedHeight = this.extrudedHeight;
+ result.granularity = this.granularity;
+ result.stRotation = this.stRotation;
+ result.fill = this.fill;
+ result.outline = this.outline;
+ result.outlineColor = this.outlineColor;
+ result.perPositionHeight = this.perPositionHeight;
return result;
};
@@ -85,6 +166,14 @@ define(['../Core/defaultValue',
this.show = defaultValue(this.show, source.show);
this.material = defaultValue(this.material, source.material);
+ this.height = defaultValue(this.height, source.height);
+ this.extrudedHeight = defaultValue(this.extrudedHeight, source.extrudedHeight);
+ this.granularity = defaultValue(this.granularity, source.granularity);
+ this.stRotation = defaultValue(this.stRotation, source.stRotation);
+ this.fill = defaultValue(this.fill, source.fill);
+ this.outline = defaultValue(this.outline, source.outline);
+ this.outlineColor = defaultValue(this.outlineColor, source.outlineColor);
+ this.perPositionHeight = defaultValue(this.perPositionHeight, source.perPositionHeight);
};
return DynamicPolygon;
diff --git a/Source/DynamicScene/DynamicPolygonVisualizer.js b/Source/DynamicScene/DynamicPolygonVisualizer.js
deleted file mode 100644
index f1268a8385a3..000000000000
--- a/Source/DynamicScene/DynamicPolygonVisualizer.js
+++ /dev/null
@@ -1,261 +0,0 @@
-/*global define*/
-define([
- '../Core/Cartesian3',
- '../Core/defined',
- '../Core/DeveloperError',
- '../Core/destroyObject',
- '../Scene/Polygon',
- '../Scene/Material',
- './MaterialProperty'
- ], function(
- Cartesian3,
- defined,
- DeveloperError,
- destroyObject,
- Polygon,
- Material,
- MaterialProperty) {
- "use strict";
-
- /**
- * A DynamicObject visualizer which maps the DynamicPolygon instance
- * in DynamicObject.polygon to a Polygon primitive.
- * @alias DynamicPolygonVisualizer
- * @constructor
- *
- * @param {Scene} scene The scene the primitives will be rendered in.
- * @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize.
- *
- * @see DynamicPolygon
- * @see Scene
- * @see DynamicObject
- * @see DynamicObjectCollection
- * @see CompositeDynamicObjectCollection
- * @see VisualizerCollection
- * @see DynamicBillboardVisualizer
- * @see DynamicConeVisualizer
- * @see DynamicConeVisualizerUsingCustomSensorr
- * @see DynamicLabelVisualizer
- * @see DynamicPointVisualizer
- * @see DynamicPolylineVisualizer
- * @see DynamicPyramidVisualizer
- */
- var DynamicPolygonVisualizer = function(scene, dynamicObjectCollection) {
- //>>includeStart('debug', pragmas.debug);
- if (!defined(scene)) {
- throw new DeveloperError('scene is required.');
- }
- //>>includeEnd('debug');
-
- this._scene = scene;
- this._unusedIndexes = [];
- this._primitives = scene.getPrimitives();
- this._polygonCollection = [];
- this._dynamicObjectCollection = undefined;
- this.setDynamicObjectCollection(dynamicObjectCollection);
- };
-
- /**
- * Returns the scene being used by this visualizer.
- *
- * @returns {Scene} The scene being used by this visualizer.
- */
- DynamicPolygonVisualizer.prototype.getScene = function() {
- return this._scene;
- };
-
- /**
- * Gets the DynamicObjectCollection being visualized.
- *
- * @returns {DynamicObjectCollection} The DynamicObjectCollection being visualized.
- */
- DynamicPolygonVisualizer.prototype.getDynamicObjectCollection = function() {
- return this._dynamicObjectCollection;
- };
-
- /**
- * Sets the DynamicObjectCollection to visualize.
- *
- * @param dynamicObjectCollection The DynamicObjectCollection to visualizer.
- */
- DynamicPolygonVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) {
- var oldCollection = this._dynamicObjectCollection;
- if (oldCollection !== dynamicObjectCollection) {
- if (defined(oldCollection)) {
- oldCollection.collectionChanged.removeEventListener(DynamicPolygonVisualizer.prototype._onObjectsRemoved, this);
- this.removeAllPrimitives();
- }
- this._dynamicObjectCollection = dynamicObjectCollection;
- if (defined(dynamicObjectCollection)) {
- dynamicObjectCollection.collectionChanged.addEventListener(DynamicPolygonVisualizer.prototype._onObjectsRemoved, this);
- }
- }
- };
-
- /**
- * Updates all of the primitives created by this visualizer to match their
- * DynamicObject counterpart at the given time.
- *
- * @param {JulianDate} time The time to update to.
- */
- DynamicPolygonVisualizer.prototype.update = function(time) {
- //>>includeStart('debug', pragmas.debug);
- if (!defined(time)) {
- throw new DeveloperError('time is requied.');
- }
- //>>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]);
- }
- }
- };
-
- /**
- * Removes all primitives from the scene.
- */
- DynamicPolygonVisualizer.prototype.removeAllPrimitives = function() {
- var i, len;
- for (i = 0, len = this._polygonCollection.length; i < len; i++) {
- this._primitives.remove(this._polygonCollection[i]);
- }
-
- if (defined(this._dynamicObjectCollection)) {
- var dynamicObjects = this._dynamicObjectCollection.getObjects();
- for (i = dynamicObjects.length - 1; i > -1; i--) {
- dynamicObjects[i]._polygonVisualizerIndex = undefined;
- }
- }
-
- this._unusedIndexes = [];
- this._polygonCollection = [];
- };
-
- /**
- * Returns true if this object was destroyed; otherwise, false.
- * isDestroyed
will result in a {@link DeveloperError} exception.
- *
- * @memberof DynamicPolygonVisualizer
- *
- * @returns {Boolean} True if this object was destroyed; otherwise, false.
- *
- * @see DynamicPolygonVisualizer#destroy
- */
- DynamicPolygonVisualizer.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.
- * isDestroyed
will result in a {@link DeveloperError} exception. Therefore,
- * assign the return value (undefined
) to the object as done in the example.
- *
- * @memberof DynamicPolygonVisualizer
- *
- * @returns {undefined}
- *
- * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
- *
- * @see DynamicPolygonVisualizer#isDestroyed
- *
- * @example
- * visualizer = visualizer && visualizer.destroy();
- */
- DynamicPolygonVisualizer.prototype.destroy = function() {
- this.setDynamicObjectCollection(undefined);
- return destroyObject(this);
- };
-
- var cachedPosition = new Cartesian3();
- function updateObject(dynamicPolygonVisualizer, time, dynamicObject) {
- var dynamicPolygon = dynamicObject._polygon;
- if (!defined(dynamicPolygon)) {
- return;
- }
-
- var polygon;
- var showProperty = dynamicPolygon._show;
- var ellipseProperty = dynamicObject._ellipse;
- var positionProperty = dynamicObject._position;
- var vertexPositionsProperty = dynamicObject._vertexPositions;
- var polygonVisualizerIndex = dynamicObject._polygonVisualizerIndex;
- var show = dynamicObject.isAvailable(time) && (!defined(showProperty) || showProperty.getValue(time));
- var hasVertexPostions = defined(vertexPositionsProperty);
- if (!show || //
- (!hasVertexPostions && //
- (!defined(ellipseProperty) || !defined(positionProperty)))) {
- //Remove the existing primitive if we have one
- if (defined(polygonVisualizerIndex)) {
- polygon = dynamicPolygonVisualizer._polygonCollection[polygonVisualizerIndex];
- polygon.show = false;
- dynamicObject._polygonVisualizerIndex = undefined;
- dynamicPolygonVisualizer._unusedIndexes.push(polygonVisualizerIndex);
- }
- return;
- }
-
- if (!defined(polygonVisualizerIndex)) {
- var unusedIndexes = dynamicPolygonVisualizer._unusedIndexes;
- var length = unusedIndexes.length;
- if (length > 0) {
- polygonVisualizerIndex = unusedIndexes.pop();
- polygon = dynamicPolygonVisualizer._polygonCollection[polygonVisualizerIndex];
- } else {
- polygonVisualizerIndex = dynamicPolygonVisualizer._polygonCollection.length;
- polygon = new Polygon();
- polygon.asynchronous = false;
- dynamicPolygonVisualizer._polygonCollection.push(polygon);
- dynamicPolygonVisualizer._primitives.add(polygon);
- }
- dynamicObject._polygonVisualizerIndex = polygonVisualizerIndex;
- polygon.dynamicObject = dynamicObject;
-
- // CZML_TODO Determine official defaults
- polygon.material = Material.fromType(Material.ColorType);
- } else {
- polygon = dynamicPolygonVisualizer._polygonCollection[polygonVisualizerIndex];
- }
-
- polygon.show = true;
-
- var vertexPositions;
- if (hasVertexPostions) {
- vertexPositions = vertexPositionsProperty.getValue(time);
- } else {
- vertexPositions = ellipseProperty.getValue(time, positionProperty.getValue(time, cachedPosition));
- }
-
- if (polygon._visualizerPositions !== vertexPositions && //
- defined(vertexPositions) && //
- vertexPositions.length > 3) {
- polygon.setPositions(vertexPositions);
- polygon._visualizerPositions = vertexPositions;
- }
-
- polygon.material = MaterialProperty.getValue(time, dynamicPolygon._material, polygon.material);
- }
-
- DynamicPolygonVisualizer.prototype._onObjectsRemoved = function(dynamicObjectCollection, added, dynamicObjects) {
- var thisPolygonCollection = this._polygonCollection;
- var thisUnusedIndexes = this._unusedIndexes;
- for ( var i = dynamicObjects.length - 1; i > -1; i--) {
- var dynamicObject = dynamicObjects[i];
- var polygonVisualizerIndex = dynamicObject._polygonVisualizerIndex;
- if (defined(polygonVisualizerIndex)) {
- var polygon = thisPolygonCollection[polygonVisualizerIndex];
- polygon.show = false;
- thisUnusedIndexes.push(polygonVisualizerIndex);
- dynamicObject._polygonVisualizerIndex = undefined;
- }
- }
- };
-
- return DynamicPolygonVisualizer;
-});
\ No newline at end of file
diff --git a/Source/DynamicScene/DynamicPolyline.js b/Source/DynamicScene/DynamicPolyline.js
index da9ac3192442..ab73c8d16bee 100644
--- a/Source/DynamicScene/DynamicPolyline.js
+++ b/Source/DynamicScene/DynamicPolyline.js
@@ -21,9 +21,12 @@ define(['../Core/defaultValue',
*/
var DynamicPolyline = function() {
this._show = undefined;
+ this._showSubscription = undefined;
this._material = undefined;
+ this._materialSubscription = undefined;
this._width = undefined;
- this._propertyChanged = new Event();
+ this._widthSubscription = undefined;
+ this._definitionChanged = new Event();
};
defineProperties(DynamicPolyline.prototype, {
@@ -32,9 +35,9 @@ define(['../Core/defaultValue',
* @memberof DynamicPolyline.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
@@ -43,21 +46,21 @@ define(['../Core/defaultValue',
* @memberof DynamicPolyline.prototype
* @type {Property}
*/
- show : createDynamicPropertyDescriptor('show', '_show'),
+ show : createDynamicPropertyDescriptor('show'),
/**
* Gets or sets the {@link MaterialProperty} specifying the appearance of the polyline.
* @memberof DynamicPolyline.prototype
* @type {MaterialProperty}
*/
- material : createDynamicPropertyDescriptor('material', '_material'),
+ material : createDynamicPropertyDescriptor('material'),
/**
* Gets or sets the numeric {@link Property} specifying the the line's width.
* @memberof DynamicPolyline.prototype
* @type {Property}
*/
- width : createDynamicPropertyDescriptor('width', '_width')
+ width : createDynamicPropertyDescriptor('width')
});
/**
diff --git a/Source/DynamicScene/DynamicPolylineVisualizer.js b/Source/DynamicScene/DynamicPolylineVisualizer.js
deleted file mode 100644
index b73a0983aae5..000000000000
--- a/Source/DynamicScene/DynamicPolylineVisualizer.js
+++ /dev/null
@@ -1,272 +0,0 @@
-/*global define*/
-define([
- '../Core/DeveloperError',
- '../Core/defined',
- '../Core/destroyObject',
- '../Core/Cartesian3',
- './MaterialProperty',
- '../Scene/Material',
- '../Scene/PolylineCollection'
- ], function(
- DeveloperError,
- defined,
- destroyObject,
- Cartesian3,
- MaterialProperty,
- Material,
- PolylineCollection) {
- "use strict";
-
- /**
- * A DynamicObject visualizer which maps the DynamicPolyline instance
- * in DynamicObject.polyline to a Polyline primitive.
- * @alias DynamicPolylineVisualizer
- * @constructor
- *
- * @param {Scene} scene The scene the primitives will be rendered in.
- * @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize.
- *
- * @see DynamicPolyline
- * @see Scene
- * @see DynamicObject
- * @see DynamicObjectCollection
- * @see CompositeDynamicObjectCollection
- * @see VisualizerCollection
- * @see DynamicBillboardVisualizer
- * @see DynamicConeVisualizer
- * @see DynamicConeVisualizerUsingCustomSensorr
- * @see DynamicLabelVisualizer
- * @see DynamicPointVisualizer
- * @see DynamicPolygonVisualizer
- * @see DynamicPyramidVisualizer
- */
- var DynamicPolylineVisualizer = function(scene, dynamicObjectCollection) {
- //>>includeStart('debug', pragmas.debug);
- if (!defined(scene)) {
- throw new DeveloperError('scene is required.');
- }
- //>>includeEnd('debug');
-
- this._scene = scene;
- this._unusedIndexes = [];
- this._primitives = scene.getPrimitives();
- var polylineCollection = this._polylineCollection = new PolylineCollection();
- scene.getPrimitives().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.
- */
- DynamicPolylineVisualizer.prototype.getScene = function() {
- return this._scene;
- };
-
- /**
- * Gets the DynamicObjectCollection being visualized.
- *
- * @returns {DynamicObjectCollection} The DynamicObjectCollection being visualized.
- */
- DynamicPolylineVisualizer.prototype.getDynamicObjectCollection = function() {
- return this._dynamicObjectCollection;
- };
-
- /**
- * Sets the DynamicObjectCollection to visualize.
- *
- * @param dynamicObjectCollection The DynamicObjectCollection to visualizer.
- */
- DynamicPolylineVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) {
- var oldCollection = this._dynamicObjectCollection;
- if (oldCollection !== dynamicObjectCollection) {
- if (defined(oldCollection)) {
- oldCollection.collectionChanged.removeEventListener(DynamicPolylineVisualizer.prototype._onObjectsRemoved, this);
- this.removeAllPrimitives();
- }
- this._dynamicObjectCollection = dynamicObjectCollection;
- if (defined(dynamicObjectCollection)) {
- dynamicObjectCollection.collectionChanged.addEventListener(DynamicPolylineVisualizer.prototype._onObjectsRemoved, this);
- }
- }
- };
-
- /**
- * Updates all of the primitives created by this visualizer to match their
- * DynamicObject counterpart at the given time.
- *
- * @param {JulianDate} time The time to update to.
- */
- DynamicPolylineVisualizer.prototype.update = function(time) {
- //>>includeStart('debug', pragmas.debug);
- if (!defined(time)) {
- throw new DeveloperError('time is requied.');
- }
- //>>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]);
- }
- }
- };
-
- /**
- * Removes all primitives from the scene.
- */
- DynamicPolylineVisualizer.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]._polylineVisualizerIndex = undefined;
- }
- }
-
- this._unusedIndexes = [];
- };
-
- /**
- * Returns true if this object was destroyed; otherwise, false.
- * isDestroyed
will result in a {@link DeveloperError} exception.
- *
- * @memberof DynamicPolylineVisualizer
- *
- * @returns {Boolean} True if this object was destroyed; otherwise, false.
- *
- * @see DynamicPolylineVisualizer#destroy
- */
- DynamicPolylineVisualizer.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.
- * isDestroyed
will result in a {@link DeveloperError} exception. Therefore,
- * assign the return value (undefined
) to the object as done in the example.
- *
- * @memberof DynamicPolylineVisualizer
- *
- * @returns {undefined}
- *
- * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
- *
- * @see DynamicPolylineVisualizer#isDestroyed
- *
- * @example
- * visualizer = visualizer && visualizer.destroy();
- */
- DynamicPolylineVisualizer.prototype.destroy = function() {
- this.setDynamicObjectCollection(undefined);
- this._scene.getPrimitives().remove(this._polylineCollection);
- return destroyObject(this);
- };
-
- var cachedPosition = new Cartesian3();
- function updateObject(dynamicPolylineVisualizer, time, dynamicObject) {
- var dynamicPolyline = dynamicObject._polyline;
- if (!defined(dynamicPolyline)) {
- return;
- }
-
- var polyline;
- var showProperty = dynamicPolyline._show;
- var ellipseProperty = dynamicObject._ellipse;
- var positionProperty = dynamicObject._position;
- var vertexPositionsProperty = dynamicObject._vertexPositions;
- var polylineVisualizerIndex = dynamicObject._polylineVisualizerIndex;
- var show = dynamicObject.isAvailable(time) && (!defined(showProperty) || showProperty.getValue(time));
- var context = dynamicPolylineVisualizer._scene.getContext();
-
- if (!show || //
- (!defined(vertexPositionsProperty) && //
- (!defined(ellipseProperty) || !defined(positionProperty)))) {
- //Remove the existing primitive if we have one
- if (defined(polylineVisualizerIndex)) {
- polyline = dynamicPolylineVisualizer._polylineCollection.get(polylineVisualizerIndex);
- polyline.setShow(false);
- dynamicObject._polylineVisualizerIndex = undefined;
- dynamicPolylineVisualizer._unusedIndexes.push(polylineVisualizerIndex);
- }
- return;
- }
-
- if (!defined(polylineVisualizerIndex)) {
- var unusedIndexes = dynamicPolylineVisualizer._unusedIndexes;
- var length = unusedIndexes.length;
- if (length > 0) {
- polylineVisualizerIndex = unusedIndexes.pop();
- polyline = dynamicPolylineVisualizer._polylineCollection.get(polylineVisualizerIndex);
- } else {
- polylineVisualizerIndex = dynamicPolylineVisualizer._polylineCollection.getLength();
- polyline = dynamicPolylineVisualizer._polylineCollection.add();
- }
- dynamicObject._polylineVisualizerIndex = polylineVisualizerIndex;
- polyline.dynamicObject = dynamicObject;
-
- // CZML_TODO Determine official defaults
- polyline.setWidth(1);
- var material = polyline.getMaterial();
- if (!defined(material) || (material.type !== Material.PolylineOutlineType)) {
- material = Material.fromType(Material.PolylineOutlineType);
- polyline.setMaterial(material);
- }
- } else {
- polyline = dynamicPolylineVisualizer._polylineCollection.get(polylineVisualizerIndex);
- }
-
- polyline.setShow(true);
-
- var vertexPositions;
- if (defined(ellipseProperty)) {
- vertexPositions = ellipseProperty.getValue(time, positionProperty.getValue(time, cachedPosition));
- } else {
- vertexPositions = vertexPositionsProperty.getValue(time);
- }
-
- if (defined(vertexPositions) && polyline._visualizerPositions !== vertexPositions) {
- polyline.setPositions(vertexPositions);
- polyline._visualizerPositions = vertexPositions;
- }
-
- var property = dynamicPolyline._material;
- if (defined(property)) {
- polyline.setMaterial(MaterialProperty.getValue(time, property, polyline.getMaterial()));
- }
-
- property = dynamicPolyline._width;
- if (defined(property)) {
- var width = property.getValue(time);
- if (defined(width)) {
- polyline.setWidth(width);
- }
- }
- }
-
- DynamicPolylineVisualizer.prototype._onObjectsRemoved = function(dynamicObjectCollection, added, dynamicObjects) {
- var thisPolylineCollection = this._polylineCollection;
- var thisUnusedIndexes = this._unusedIndexes;
- for ( var i = dynamicObjects.length - 1; i > -1; i--) {
- var dynamicObject = dynamicObjects[i];
- var polylineVisualizerIndex = dynamicObject._polylineVisualizerIndex;
- if (defined(polylineVisualizerIndex)) {
- var polyline = thisPolylineCollection.get(polylineVisualizerIndex);
- polyline.setShow(false);
- thisUnusedIndexes.push(polylineVisualizerIndex);
- dynamicObject._polylineVisualizerIndex = undefined;
- }
- }
- };
-
- return DynamicPolylineVisualizer;
-});
diff --git a/Source/DynamicScene/DynamicPyramid.js b/Source/DynamicScene/DynamicPyramid.js
index 3bdd255fefd7..26f24db969df 100644
--- a/Source/DynamicScene/DynamicPyramid.js
+++ b/Source/DynamicScene/DynamicPyramid.js
@@ -22,13 +22,20 @@ define(['../Core/defaultValue',
*/
var DynamicPyramid = function() {
this._show = undefined;
+ this._showSubscription = undefined;
this._directions = undefined;
+ this._directionsSubscription = undefined;
this._radius = undefined;
+ this._radiusSubscription = undefined;
this._showIntersection = undefined;
+ this._showIntersectionSubscription = undefined;
this._intersectionColor = undefined;
+ this._intersectionColorSubscription = undefined;
this._intersectionWidth = undefined;
+ this._intersectionWidthSubscription = undefined;
this._material = undefined;
- this._propertyChanged = new Event();
+ this._materialSubscription = undefined;
+ this._definitionChanged = new Event();
};
defineProperties(DynamicPyramid.prototype, {
@@ -37,9 +44,9 @@ define(['../Core/defaultValue',
* @memberof DynamicPyramid.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
@@ -48,49 +55,49 @@ define(['../Core/defaultValue',
* @memberof DynamicPyramid.prototype
* @type {Property}
*/
- show : createDynamicPropertyDescriptor('show', '_show'),
+ show : createDynamicPropertyDescriptor('show'),
/**
* A {@link Property} which returns an array of {@link Spherical} instances representing the pyramid's projection.
* @memberof DynamicPyramid.prototype
* @type {Property}
*/
- directions : createDynamicPropertyDescriptor('directions', '_directions'),
+ directions : createDynamicPropertyDescriptor('directions'),
/**
* Gets or sets the numeric {@link Property} specifying the radius of the pyramid's projection.
* @memberof DynamicPyramid.prototype
* @type {Property}
*/
- radius : createDynamicPropertyDescriptor('radius', '_radius'),
+ radius : createDynamicPropertyDescriptor('radius'),
/**
* Gets or sets the boolean {@link Property} specifying the visibility of the line formed by the intersection of the pyramid and other central bodies.
* @memberof DynamicPyramid.prototype
* @type {Property}
*/
- showIntersection : createDynamicPropertyDescriptor('showIntersection', '_showIntersection'),
+ showIntersection : createDynamicPropertyDescriptor('showIntersection'),
/**
* Gets or sets the {@link Color} {@link Property} specifying the color of the line formed by the intersection of the pyramid and other central bodies.
* @memberof DynamicPyramid.prototype
* @type {Property}
*/
- intersectionColor : createDynamicPropertyDescriptor('intersectionColor', '_intersectionColor'),
+ intersectionColor : createDynamicPropertyDescriptor('intersectionColor'),
/**
* Gets or sets the numeric {@link Property} specifying the width of the line formed by the intersection of the pyramid and other central bodies.
* @memberof DynamicPyramid.prototype
* @type {Property}
*/
- intersectionWidth : createDynamicPropertyDescriptor('intersectionWidth', '_intersectionWidth'),
+ intersectionWidth : createDynamicPropertyDescriptor('intersectionWidth'),
/**
* Gets or sets the {@link MaterialProperty} specifying the the pyramid's appearance.
* @memberof DynamicPyramid.prototype
* @type {MaterialProperty}
*/
- material : createDynamicPropertyDescriptor('material', '_material')
+ material : createDynamicPropertyDescriptor('material')
});
/**
diff --git a/Source/DynamicScene/DynamicPyramidVisualizer.js b/Source/DynamicScene/DynamicPyramidVisualizer.js
index 97503bfe711b..9890a7e7257d 100644
--- a/Source/DynamicScene/DynamicPyramidVisualizer.js
+++ b/Source/DynamicScene/DynamicPyramidVisualizer.js
@@ -39,18 +39,13 @@ define([
* @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize.
*
* @see DynamicPyramid
- * @see Scene
* @see DynamicObject
- * @see DynamicObjectCollection
* @see CompositeDynamicObjectCollection
- * @see VisualizerCollection
* @see DynamicBillboardVisualizer
* @see DynamicConeVisualizer
- * @see DynamicConeVisualizerUsingCustomSensorr
+ * @see DynamicConeVisualizerUsingCustomSensor
* @see DynamicLabelVisualizer
* @see DynamicPointVisualizer
- * @see DynamicPolygonVisualizer
- * @see DynamicPolylineVisualizer
*/
var DynamicPyramidVisualizer = function(scene, dynamicObjectCollection) {
//>>includeStart('debug', pragmas.debug);
@@ -61,7 +56,7 @@ define([
this._scene = scene;
this._unusedIndexes = [];
- this._primitives = scene.getPrimitives();
+ this._primitives = scene.primitives;
this._pyramidCollection = [];
this._dynamicObjectCollection = undefined;
this.setDynamicObjectCollection(dynamicObjectCollection);
@@ -113,7 +108,7 @@ define([
DynamicPyramidVisualizer.prototype.update = function(time) {
//>>includeStart('debug', pragmas.debug);
if (!defined(time)) {
- throw new DeveloperError('time is requied.');
+ throw new DeveloperError('time is required.');
}
//>>includeEnd('debug');
@@ -238,7 +233,7 @@ define([
dynamicPyramidVisualizer._primitives.add(pyramid);
}
dynamicObject._pyramidVisualizerIndex = pyramidVisualizerIndex;
- pyramid.dynamicObject = dynamicObject;
+ pyramid.id = dynamicObject;
// CZML_TODO Determine official defaults
pyramid.radius = Number.POSITIVE_INFINITY;
diff --git a/Source/DynamicScene/DynamicVector.js b/Source/DynamicScene/DynamicVector.js
index 96c5aaf66406..6220ca66b76c 100644
--- a/Source/DynamicScene/DynamicVector.js
+++ b/Source/DynamicScene/DynamicVector.js
@@ -21,11 +21,16 @@ define(['../Core/defaultValue',
*/
var DynamicVector = function() {
this._color = undefined;
+ this._colorSubscription = undefined;
this._show = undefined;
+ this._showSubscription = undefined;
this._width = undefined;
+ this._widthSubscription = undefined;
this._direction = undefined;
+ this._directionSubscription = undefined;
this._length = undefined;
- this._propertyChanged = new Event();
+ this._lengthSubscription = undefined;
+ this._definitionChanged = new Event();
};
defineProperties(DynamicVector.prototype, {
@@ -34,9 +39,9 @@ define(['../Core/defaultValue',
* @memberof DynamicVector.prototype
* @type {Event}
*/
- propertyChanged : {
+ definitionChanged : {
get : function() {
- return this._propertyChanged;
+ return this._definitionChanged;
}
},
@@ -45,35 +50,35 @@ define(['../Core/defaultValue',
* @memberof DynamicVector.prototype
* @type {Property}
*/
- color : createDynamicPropertyDescriptor('color', '_color'),
+ color : createDynamicPropertyDescriptor('color'),
/**
* Gets or sets the boolean {@link Property} specifying the vector's visibility.
* @memberof DynamicVector.prototype
* @type {Property}
*/
- show : createDynamicPropertyDescriptor('show', '_show'),
+ show : createDynamicPropertyDescriptor('show'),
/**
* Gets or sets the numeric {@link Property} specifying the the vector's width.
* @memberof DynamicVector.prototype
* @type {Property}
*/
- width : createDynamicPropertyDescriptor('width', '_width'),
+ width : createDynamicPropertyDescriptor('width'),
/**
* Gets or sets the {@link Cartesian3} {@link Property} specifying the the vector's direction.
* @memberof DynamicVector.prototype
* @type {Property}
*/
- direction : createDynamicPropertyDescriptor('direction', '_direction'),
+ direction : createDynamicPropertyDescriptor('direction'),
/**
* Gets or sets the numeric {@link Property} specifying the the vector's graphical length in meters.
* @memberof DynamicVector.prototype
* @type {Property}
*/
- length : createDynamicPropertyDescriptor('length', '_length')
+ length : createDynamicPropertyDescriptor('length')
});
/**
diff --git a/Source/DynamicScene/DynamicVectorVisualizer.js b/Source/DynamicScene/DynamicVectorVisualizer.js
index 7c17913a4874..19eb8cf729a6 100644
--- a/Source/DynamicScene/DynamicVectorVisualizer.js
+++ b/Source/DynamicScene/DynamicVectorVisualizer.js
@@ -27,17 +27,13 @@ define([
* @param {DynamicObjectCollection} [dynamicObjectCollection] The dynamicObjectCollection to visualize.
*
* @see DynamicPolyline
- * @see Scene
* @see DynamicObject
- * @see DynamicObjectCollection
* @see CompositeDynamicObjectCollection
- * @see VisualizerCollection
* @see DynamicBillboardVisualizer
* @see DynamicConeVisualizer
- * @see DynamicConeVisualizerUsingCustomSensorr
+ * @see DynamicConeVisualizerUsingCustomSensor
* @see DynamicLabelVisualizer
* @see DynamicPointVisualizer
- * @see DynamicPolygonVisualizer
* @see DynamicPyramidVisualizer
*/
var DynamicVectorVisualizer = function(scene, dynamicObjectCollection) {
@@ -49,9 +45,9 @@ define([
this._scene = scene;
this._unusedIndexes = [];
- this._primitives = scene.getPrimitives();
+ this._primitives = scene.primitives;
var polylineCollection = this._polylineCollection = new PolylineCollection();
- scene.getPrimitives().add(polylineCollection);
+ scene.primitives.add(polylineCollection);
this._dynamicObjectCollection = undefined;
this.setDynamicObjectCollection(dynamicObjectCollection);
};
@@ -102,7 +98,7 @@ define([
DynamicVectorVisualizer.prototype.update = function(time) {
//>>includeStart('debug', pragmas.debug);
if (!defined(time)) {
- throw new DeveloperError('time is requied.');
+ throw new DeveloperError('time is required.');
}
//>>includeEnd('debug');
@@ -168,7 +164,7 @@ define([
*/
DynamicVectorVisualizer.prototype.destroy = function() {
this.setDynamicObjectCollection(undefined);
- this._scene.getPrimitives().remove(this._polylineCollection);
+ this._scene.primitives.remove(this._polylineCollection);
return destroyObject(this);
};
@@ -209,7 +205,7 @@ define([
polyline._visualizerPositions = [new Cartesian3(), new Cartesian3()];
}
dynamicObject._vectorVisualizerIndex = vectorVisualizerIndex;
- polyline.dynamicObject = dynamicObject;
+ polyline.id = dynamicObject;
// CZML_TODO Determine official defaults
polyline.setWidth(1);
diff --git a/Source/DynamicScene/DynamicVertexPositionsProperty.js b/Source/DynamicScene/DynamicVertexPositionsProperty.js
deleted file mode 100644
index aa00b6be88ee..000000000000
--- a/Source/DynamicScene/DynamicVertexPositionsProperty.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/*global define*/
-define([
- '../Core/defined',
- '../Core/TimeInterval',
- '../Core/TimeIntervalCollection',
- '../Core/Cartesian3',
- '../Core/Cartographic',
- '../Core/Iso8601',
- '../Core/Ellipsoid',
- './ReferenceProperty'
- ], function(
- defined,
- TimeInterval,
- TimeIntervalCollection,
- Cartesian3,
- Cartographic,
- Iso8601,
- Ellipsoid,
- ReferenceProperty) {
- "use strict";
-
- var wgs84 = Ellipsoid.WGS84;
-
- function ValueHolder(czmlInterval) {
- var i, len, values = [], tmp;
-
- tmp = czmlInterval.cartesian;
- if (defined(tmp)) {
- for (i = 0, len = tmp.length; i < len; i += 3) {
- values.push(new Cartesian3(tmp[i], tmp[i + 1], tmp[i + 2]));
- }
- this.cartesian = values;
- } else {
- tmp = czmlInterval.cartographicRadians;
- if (defined(tmp)) {
- for (i = 0, len = tmp.length; i < len; i += 3) {
- values.push(new Cartographic(tmp[i], tmp[i + 1], tmp[i + 2]));
- }
- this.cartographic = values;
- } else {
- tmp = czmlInterval.cartographicDegrees;
- if (defined(tmp)) {
- for (i = 0, len = tmp.length; i < len; i += 3) {
- values.push(Cartographic.fromDegrees(tmp[i], tmp[i + 1], tmp[i + 2]));
- }
- this.cartographic = values;
- }
- }
- }
- }
-
- ValueHolder.prototype.getValue = function() {
- if (!defined(this.cartesian)) {
- this.cartesian = wgs84.cartographicArrayToCartesianArray(this.cartographic);
- }
- return this.cartesian;
- };
-
- /**
- * @private
- */
- var DynamicVertexPositionsProperty = function() {
- this._propertyIntervals = new TimeIntervalCollection();
- };
-
- DynamicVertexPositionsProperty.prototype.processCzmlIntervals = function(czmlIntervals, constrainedInterval, dynamicObjectCollection) {
- if (Array.isArray(czmlIntervals)) {
- for ( var i = 0, len = czmlIntervals.length; i < len; i++) {
- this._addCzmlInterval(czmlIntervals[i], constrainedInterval, dynamicObjectCollection);
- }
- } else {
- this._addCzmlInterval(czmlIntervals, constrainedInterval, dynamicObjectCollection);
- }
- };
-
- DynamicVertexPositionsProperty.prototype.getValue = function(time) {
- var interval = this._propertyIntervals.findIntervalContainingDate(time);
- if (!defined(interval)) {
- return undefined;
- }
- var interval_data = interval.data;
- if (Array.isArray(interval_data)) {
- var result = [];
- for ( var i = 0, len = interval_data.length; i < len; i++) {
- var value = interval_data[i].getValue(time);
- if (defined(value)) {
- result.push(value);
- }
- }
- return result;
- }
-
- return interval_data.getValue();
- };
-
- DynamicVertexPositionsProperty.prototype._addCzmlInterval = function(czmlInterval, constrainedInterval, dynamicObjectCollection) {
- var iso8601Interval = czmlInterval.interval;
- if (!defined(iso8601Interval)) {
- iso8601Interval = Iso8601.MAXIMUM_INTERVAL.clone();
- } else {
- iso8601Interval = TimeInterval.fromIso8601(iso8601Interval);
- }
-
- if (defined(constrainedInterval)) {
- iso8601Interval = iso8601Interval.intersect(constrainedInterval);
- }
-
- //See if we already have data at that interval.
- var thisIntervals = this._propertyIntervals;
- var existingInterval = thisIntervals.findInterval(iso8601Interval.start, iso8601Interval.stop);
-
- //If not, create it.
- if (!defined(existingInterval)) {
- existingInterval = iso8601Interval;
- thisIntervals.addInterval(existingInterval);
- }
-
- var references = czmlInterval.references;
- if (!defined(references)) {
- existingInterval.data = new ValueHolder(czmlInterval);
- } else {
- var properties = [];
- for ( var i = 0, len = references.length; i < len; i++) {
- properties.push(ReferenceProperty.fromString(dynamicObjectCollection, references[i]));
- }
- existingInterval.data = properties;
- }
- };
-
- return DynamicVertexPositionsProperty;
-});
diff --git a/Source/DynamicScene/EllipseGeometryUpdater.js b/Source/DynamicScene/EllipseGeometryUpdater.js
new file mode 100644
index 000000000000..4473adcb319e
--- /dev/null
+++ b/Source/DynamicScene/EllipseGeometryUpdater.js
@@ -0,0 +1,603 @@
+/*global define*/
+define(['../Core/Color',
+ '../Core/ColorGeometryInstanceAttribute',
+ '../Core/defaultValue',
+ '../Core/defined',
+ '../Core/defineProperties',
+ '../Core/destroyObject',
+ '../Core/DeveloperError',
+ '../Core/EllipseGeometry',
+ '../Core/EllipseOutlineGeometry',
+ '../Core/Event',
+ '../Core/GeometryInstance',
+ '../Core/Iso8601',
+ '../Core/ShowGeometryInstanceAttribute',
+ '../DynamicScene/ColorMaterialProperty',
+ '../DynamicScene/ConstantProperty',
+ '../DynamicScene/MaterialProperty',
+ '../DynamicScene/Property',
+ '../Scene/MaterialAppearance',
+ '../Scene/PerInstanceColorAppearance',
+ '../Scene/Primitive'
+ ], function(
+ Color,
+ ColorGeometryInstanceAttribute,
+ defaultValue,
+ defined,
+ defineProperties,
+ destroyObject,
+ DeveloperError,
+ EllipseGeometry,
+ EllipseOutlineGeometry,
+ Event,
+ GeometryInstance,
+ Iso8601,
+ ShowGeometryInstanceAttribute,
+ ColorMaterialProperty,
+ ConstantProperty,
+ MaterialProperty,
+ Property,
+ MaterialAppearance,
+ PerInstanceColorAppearance,
+ Primitive) {
+ "use strict";
+
+ var defaultMaterial = ColorMaterialProperty.fromColor(Color.WHITE);
+ var defaultShow = new ConstantProperty(true);
+ var defaultFill = new ConstantProperty(true);
+ var defaultOutline = new ConstantProperty(false);
+ var defaultOutlineColor = new ConstantProperty(Color.BLACK);
+
+ var GeometryOptions = function(dynamicObject) {
+ this.id = dynamicObject;
+ this.vertexFormat = undefined;
+ this.center = undefined;
+ this.semiMajorAxis = undefined;
+ this.semiMinorAxis = undefined;
+ this.rotation = undefined;
+ this.height = undefined;
+ this.extrudedHeight = undefined;
+ this.granularity = undefined;
+ this.stRotation = undefined;
+ this.numberOfVerticalLines = undefined;
+ };
+
+ /**
+ * A {@link GeometryUpdater} for ellipses.
+ * Clients do not normally create this class directly, but instead rely on {@link DataSourceDisplay}.
+ * @alias EllipseGeometryUpdater
+ * @constructor
+ *
+ * @param {DynamicObject} dynamicObject The object containing the geometry to be visualized.
+ */
+ var EllipseGeometryUpdater = function(dynamicObject) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(dynamicObject)) {
+ throw new DeveloperError('dynamicObject is required');
+ }
+ //>>includeEnd('debug');
+
+ this._dynamicObject = dynamicObject;
+ this._dynamicObjectSubscription = dynamicObject.definitionChanged.addEventListener(EllipseGeometryUpdater.prototype._onDynamicObjectPropertyChanged, this);
+ this._fillEnabled = false;
+ this._isClosed = false;
+ this._dynamic = false;
+ this._outlineEnabled = false;
+ this._geometryChanged = new Event();
+ this._showProperty = undefined;
+ this._materialProperty = undefined;
+ this._hasConstantOutline = true;
+ this._showOutlineProperty = undefined;
+ this._outlineColorProperty = undefined;
+ this._options = new GeometryOptions(dynamicObject);
+ this._onDynamicObjectPropertyChanged(dynamicObject, 'ellipse', dynamicObject.ellipse, undefined);
+ };
+
+ defineProperties(EllipseGeometryUpdater, {
+ /**
+ * Gets the type of Appearance to use for simple color-based geometry.
+ * @memberof EllipseGeometryUpdater
+ * @type {Appearance}
+ */
+ perInstanceColorAppearanceType : {
+ value : PerInstanceColorAppearance
+ },
+ /**
+ * Gets the type of Appearance to use for material-based geometry.
+ * @memberof EllipseGeometryUpdater
+ * @type {Appearance}
+ */
+ materialAppearanceType : {
+ value : MaterialAppearance
+ }
+ });
+
+ defineProperties(EllipseGeometryUpdater.prototype, {
+ /**
+ * Gets the object associated with this geometry.
+ * @memberof EllipseGeometryUpdater.prototype
+ * @type {DynamicObject}
+ */
+ dynamicObject :{
+ get : function() {
+ return this._dynamicObject;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry has a fill component.
+ * @memberof EllipseGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ fillEnabled : {
+ get : function() {
+ return this._fillEnabled;
+ }
+ },
+ /**
+ * Gets a value indicating if fill visibility varies with simulation time.
+ * @memberof EllipseGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ hasConstantFill : {
+ get : function() {
+ return !this._fillEnabled ||
+ (!defined(this._dynamicObject.availability) &&
+ Property.isConstant(this._showProperty) &&
+ Property.isConstant(this._fillProperty));
+ }
+ },
+ /**
+ * Gets the material property used to fill the geometry.
+ * @memberof EllipseGeometryUpdater.prototype
+ * @type {MaterialProperty}
+ */
+ fillMaterialProperty : {
+ get : function() {
+ return this._materialProperty;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry has an outline component.
+ * @memberof EllipseGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ outlineEnabled : {
+ get : function() {
+ return this._outlineEnabled;
+ }
+ },
+ /**
+ * Gets a value indicating if outline visibility varies with simulation time.
+ * @memberof EllipseGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ hasConstantOutline : {
+ get : function() {
+ return !this._outlineEnabled ||
+ (!defined(this._dynamicObject.availability) &&
+ Property.isConstant(this._showProperty) &&
+ Property.isConstant(this._showOutlineProperty));
+ }
+ },
+ /**
+ * Gets the {@link Color} property for the geometry outline.
+ * @memberof EllipseGeometryUpdater.prototype
+ * @type {Property}
+ */
+ outlineColorProperty : {
+ get : function() {
+ return this._outlineColorProperty;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry is time-varying.
+ * If true, all visualization is delegated to the {@link DynamicGeometryUpdater}
+ * returned by GeometryUpdater#createDynamicUpdater.
+ *
+ * @memberof EllipseGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ isDynamic : {
+ get : function() {
+ return this._dynamic;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry is closed.
+ * This property is only valid for static geometry.
+ * @memberof EllipseGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ isClosed : {
+ get : function() {
+ return this._isClosed;
+ }
+ },
+ /**
+ * Gets an event that is raised whenever the public properties
+ * of this updater change.
+ * @memberof EllipseGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ geometryChanged : {
+ get : function() {
+ return this._geometryChanged;
+ }
+ }
+ });
+
+ /**
+ * Checks if the geometry is outlined at the provided time.
+ * @memberof EllipseGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time for which to retrieve visibility.
+ * @returns {Boolean} true if geometry is outlined at the provided time, false otherwise.
+ */
+ EllipseGeometryUpdater.prototype.isOutlineVisible = function(time) {
+ var dynamicObject = this._dynamicObject;
+ return this._outlineEnabled && dynamicObject.isAvailable(time) && this._showProperty.getValue(time) && this._showOutlineProperty.getValue(time);
+ };
+
+ /**
+ * Checks if the geometry is filled at the provided time.
+ * @memberof EllipseGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time for which to retrieve visibility.
+ * @returns {Boolean} true if geometry is filled at the provided time, false otherwise.
+ */
+ EllipseGeometryUpdater.prototype.isFilled = function(time) {
+ var dynamicObject = this._dynamicObject;
+ return this._fillEnabled && dynamicObject.isAvailable(time) && this._showProperty.getValue(time) && this._fillProperty.getValue(time);
+ };
+
+ /**
+ * Creates the geometry instance which represents the fill of the geometry.
+ * @memberof EllipseGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time to use when retrieving initial attribute values.
+ * @returns {GeometryInstance} The geometry instance representing the filled portion of the geometry.
+ *
+ * @exception {DeveloperError} This instance does not represent a filled geometry.
+ */
+ EllipseGeometryUpdater.prototype.createFillGeometryInstance = function(time) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+
+ if (!this._fillEnabled) {
+ throw new DeveloperError('This instance does not represent a filled geometry.');
+ }
+ //>>includeEnd('debug');
+
+ var dynamicObject = this._dynamicObject;
+ var isAvailable = dynamicObject.isAvailable(time);
+
+ var attributes;
+
+ var color;
+ var show = new ShowGeometryInstanceAttribute(isAvailable && this._showProperty.getValue(time) && this._fillProperty.getValue(time));
+ if (this._materialProperty instanceof ColorMaterialProperty) {
+ var currentColor = Color.WHITE;
+ if (defined(this._materialProperty.color) && (this._materialProperty.color.isConstant || isAvailable)) {
+ currentColor = this._materialProperty.color.getValue(time);
+ }
+ color = ColorGeometryInstanceAttribute.fromColor(currentColor);
+ attributes = {
+ show : show,
+ color : color
+ };
+ } else {
+ attributes = {
+ show : show
+ };
+ }
+
+ return new GeometryInstance({
+ id : dynamicObject,
+ geometry : new EllipseGeometry(this._options),
+ attributes : attributes
+ });
+ };
+
+ /**
+ * Creates the geometry instance which represents the outline of the geometry.
+ * @memberof EllipseGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time to use when retrieving initial attribute values.
+ * @returns {GeometryInstance} The geometry instance representing the outline portion of the geometry.
+ *
+ * @exception {DeveloperError} This instance does not represent an outlined geometry.
+ */
+ EllipseGeometryUpdater.prototype.createOutlineGeometryInstance = function(time) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+
+ if (!this._outlineEnabled) {
+ throw new DeveloperError('This instance does not represent an outlined geometry.');
+ }
+ //>>includeEnd('debug');
+
+ var dynamicObject = this._dynamicObject;
+ var isAvailable = dynamicObject.isAvailable(time);
+
+ return new GeometryInstance({
+ id : dynamicObject,
+ geometry : new EllipseOutlineGeometry(this._options),
+ attributes : {
+ show : new ShowGeometryInstanceAttribute(isAvailable && this._showProperty.getValue(time) && this._showOutlineProperty.getValue(time)),
+ color : ColorGeometryInstanceAttribute.fromColor(isAvailable ? this._outlineColorProperty.getValue(time) : Color.BLACK)
+ }
+ });
+ };
+
+ /**
+ * Returns true if this object was destroyed; otherwise, false.
+ * @memberof EllipseGeometryUpdater
+ * @function
+ *
+ * @returns {Boolean} True if this object was destroyed; otherwise, false.
+ */
+ EllipseGeometryUpdater.prototype.isDestroyed = function() {
+ return false;
+ };
+
+ /**
+ * Destroys and resources used by the object. Once an object is destroyed, it should not be used.
+ * @memberof EllipseGeometryUpdater
+ * @function
+ *
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
+ */
+ EllipseGeometryUpdater.prototype.destroy = function() {
+ this._dynamicObjectSubscription();
+ destroyObject(this);
+ };
+
+ EllipseGeometryUpdater.prototype._onDynamicObjectPropertyChanged = function(dynamicObject, propertyName, newValue, oldValue) {
+ if (!(propertyName === 'availability' || propertyName === 'position' || propertyName === 'ellipse')) {
+ return;
+ }
+
+ var ellipse = this._dynamicObject.ellipse;
+
+ if (!defined(ellipse)) {
+ if (this._fillEnabled || this._outlineEnabled) {
+ this._fillEnabled = false;
+ this._outlineEnabled = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ return;
+ }
+
+ var fillProperty = ellipse.fill;
+ var fillEnabled = defined(fillProperty) && fillProperty.isConstant ? fillProperty.getValue(Iso8601.MINIMUM_VALUE) : true;
+
+ var outlineProperty = ellipse.outline;
+ var outlineEnabled = defined(outlineProperty);
+ if (outlineEnabled && outlineProperty.isConstant) {
+ outlineEnabled = outlineProperty.getValue(Iso8601.MINIMUM_VALUE);
+ }
+
+ if (!fillEnabled && !outlineEnabled) {
+ if (this._fillEnabled || this._outlineEnabled) {
+ this._fillEnabled = false;
+ this._outlineEnabled = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ return;
+ }
+
+ var position = this._dynamicObject.position;
+ var semiMajorAxis = ellipse.semiMajorAxis;
+ var semiMinorAxis = ellipse.semiMinorAxis;
+
+ var show = ellipse.show;
+ if ((defined(show) && show.isConstant && !show.getValue(Iso8601.MINIMUM_VALUE)) || //
+ (!defined(position) || !defined(semiMajorAxis) || !defined(semiMinorAxis))) {
+ if (this._fillEnabled || this._outlineEnabled) {
+ this._fillEnabled = false;
+ this._outlineEnabled = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ return;
+ }
+
+ var material = defaultValue(ellipse.material, defaultMaterial);
+ var isColorMaterial = material instanceof ColorMaterialProperty;
+ this._materialProperty = material;
+ this._fillProperty = defaultValue(fillProperty, defaultFill);
+ this._showProperty = defaultValue(show, defaultShow);
+ this._showOutlineProperty = defaultValue(ellipse.outline, defaultOutline);
+ this._outlineColorProperty = outlineEnabled ? defaultValue(ellipse.outlineColor, defaultOutlineColor) : undefined;
+
+ var rotation = ellipse.rotation;
+ var height = ellipse.height;
+ var extrudedHeight = ellipse.extrudedHeight;
+ var granularity = ellipse.granularity;
+ var stRotation = ellipse.stRotation;
+ var numberOfVerticalLines = ellipse.numberOfVerticalLines;
+
+ this._isClosed = defined(extrudedHeight);
+ this._fillEnabled = fillEnabled;
+ this._outlineEnabled = outlineEnabled;
+
+ if (!position.isConstant || //
+ !semiMajorAxis.isConstant || //
+ !semiMinorAxis.isConstant || //
+ !Property.isConstant(rotation) || //
+ !Property.isConstant(height) || //
+ !Property.isConstant(extrudedHeight) || //
+ !Property.isConstant(granularity) || //
+ !Property.isConstant(stRotation) || //
+ !Property.isConstant(numberOfVerticalLines)) {
+ if (!this._dynamic) {
+ this._dynamic = true;
+ this._geometryChanged.raiseEvent(this);
+ }
+ } else {
+ var options = this._options;
+ options.vertexFormat = isColorMaterial ? PerInstanceColorAppearance.VERTEX_FORMAT : MaterialAppearance.VERTEX_FORMAT;
+ options.center = position.getValue(Iso8601.MINIMUM_VALUE, options.center);
+ options.semiMajorAxis = semiMajorAxis.getValue(Iso8601.MINIMUM_VALUE, options.semiMajorAxis);
+ options.semiMinorAxis = semiMinorAxis.getValue(Iso8601.MINIMUM_VALUE, options.semiMinorAxis);
+ options.rotation = defined(rotation) ? rotation.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ options.height = defined(height) ? height.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ options.extrudedHeight = defined(extrudedHeight) ? extrudedHeight.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ options.granularity = defined(granularity) ? granularity.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ options.stRotation = defined(stRotation) ? stRotation.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ options.numberOfVerticalLines = defined(numberOfVerticalLines) ? numberOfVerticalLines.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ this._dynamic = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ };
+
+ /**
+ * Creates the dynamic updater to be used when GeometryUpdater#isDynamic is true.
+ * @memberof EllipseGeometryUpdater
+ * @function
+ *
+ * @param {CompositePrimitive} primitives The primitive collection to use.
+ * @returns {DynamicGeometryUpdater} The dynamic updater used to update the geometry each frame.
+ *
+ * @exception {DeveloperError} This instance does not represent dynamic geometry.
+ */
+ EllipseGeometryUpdater.prototype.createDynamicUpdater = function(primitives) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!this._dynamic) {
+ throw new DeveloperError('This instance does not represent dynamic geometry.');
+ }
+
+ if (!defined(primitives)) {
+ throw new DeveloperError('primitives is required.');
+ }
+ //>>includeEnd('debug');
+
+ return new DynamicGeometryUpdater(primitives, this);
+ };
+
+ /**
+ * @private
+ */
+ var DynamicGeometryUpdater = function(primitives, geometryUpdater) {
+ this._primitives = primitives;
+ this._primitive = undefined;
+ this._outlinePrimitive = undefined;
+ this._geometryUpdater = geometryUpdater;
+ this._options = new GeometryOptions(geometryUpdater._dynamicObject);
+ };
+
+ DynamicGeometryUpdater.prototype.update = function(time) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+ //>>includeEnd('debug');
+
+ var geometryUpdater = this._geometryUpdater;
+
+ if (defined(this._primitive)) {
+ this._primitives.remove(this._primitive);
+ }
+
+ if (defined(this._outlinePrimitive)) {
+ this._primitives.remove(this._outlinePrimitive);
+ }
+
+ var dynamicObject = geometryUpdater._dynamicObject;
+ var ellipse = dynamicObject.ellipse;
+ var show = ellipse.show;
+
+ if (!dynamicObject.isAvailable(time) || (defined(show) && !show.getValue(time))) {
+ return;
+ }
+
+ var options = this._options;
+
+ var position = dynamicObject.position;
+ var semiMajorAxis = ellipse.semiMajorAxis;
+ var semiMinorAxis = ellipse.semiMinorAxis;
+ var rotation = ellipse.rotation;
+ var height = ellipse.height;
+ var extrudedHeight = ellipse.extrudedHeight;
+ var granularity = ellipse.granularity;
+ var stRotation = ellipse.stRotation;
+ var numberOfVerticalLines = ellipse.numberOfVerticalLines;
+
+ options.center = position.getValue(time, options.center);
+ options.semiMajorAxis = semiMajorAxis.getValue(time, options.semiMajorAxis);
+ options.semiMinorAxis = semiMinorAxis.getValue(time, options.semiMinorAxis);
+ options.rotation = defined(rotation) ? rotation.getValue(time, options) : undefined;
+ options.height = defined(height) ? height.getValue(time, options) : undefined;
+ options.extrudedHeight = defined(extrudedHeight) ? extrudedHeight.getValue(time, options) : undefined;
+ options.granularity = defined(granularity) ? granularity.getValue(time) : undefined;
+ options.stRotation = defined(stRotation) ? stRotation.getValue(time) : undefined;
+
+ if (!defined(ellipse.fill) || ellipse.fill.getValue(time)) {
+ this._material = MaterialProperty.getValue(time, geometryUpdater.fillMaterialProperty, this._material);
+ var material = this._material;
+ var appearance = new MaterialAppearance({
+ material : material,
+ faceForward : true,
+ translucent : material.isTranslucent(),
+ closed : defined(options.extrudedHeight)
+ });
+ options.vertexFormat = appearance.vertexFormat;
+
+ this._primitive = new Primitive({
+ geometryInstances : new GeometryInstance({
+ id : dynamicObject,
+ geometry : new EllipseGeometry(options)
+ }),
+ appearance : appearance,
+ asynchronous : false
+ });
+ this._primitives.add(this._primitive);
+ }
+
+ if (defined(ellipse.outline) && ellipse.outline.getValue(time)) {
+ options.vertexFormat = PerInstanceColorAppearance.VERTEX_FORMAT;
+ options.numberOfVerticalLines = defined(numberOfVerticalLines) ? numberOfVerticalLines.getValue(time) : undefined;
+
+ var outlineColor = defined(ellipse.outlineColor) ? ellipse.outlineColor.getValue(time) : Color.BLACK;
+ this._outlinePrimitive = new Primitive({
+ geometryInstances : new GeometryInstance({
+ id : dynamicObject,
+ geometry : new EllipseOutlineGeometry(options),
+ attributes : {
+ color : ColorGeometryInstanceAttribute.fromColor(outlineColor)
+ }
+ }),
+ appearance : new PerInstanceColorAppearance({
+ flat : true,
+ translucent : outlineColor.alpha !== 1.0
+ }),
+ asynchronous : false
+ });
+ this._primitives.add(this._outlinePrimitive);
+ }
+ };
+
+ DynamicGeometryUpdater.prototype.isDestroyed = function() {
+ return false;
+ };
+
+ DynamicGeometryUpdater.prototype.destroy = function() {
+ if (defined(this._primitive)) {
+ this._primitives.remove(this._primitive);
+ }
+
+ if (defined(this._outlinePrimitive)) {
+ this._primitives.remove(this._outlinePrimitive);
+ }
+ destroyObject(this);
+ };
+
+ return EllipseGeometryUpdater;
+});
\ No newline at end of file
diff --git a/Source/DynamicScene/EllipsoidGeometryUpdater.js b/Source/DynamicScene/EllipsoidGeometryUpdater.js
new file mode 100644
index 000000000000..5b4e7378786c
--- /dev/null
+++ b/Source/DynamicScene/EllipsoidGeometryUpdater.js
@@ -0,0 +1,673 @@
+/*global define*/
+define(['../Core/Cartesian3',
+ '../Core/Color',
+ '../Core/ColorGeometryInstanceAttribute',
+ '../Core/defaultValue',
+ '../Core/defined',
+ '../Core/defineProperties',
+ '../Core/destroyObject',
+ '../Core/DeveloperError',
+ '../Core/EllipsoidGeometry',
+ '../Core/EllipsoidOutlineGeometry',
+ '../Core/Event',
+ '../Core/GeometryInstance',
+ '../Core/Iso8601',
+ '../Core/Matrix3',
+ '../Core/Matrix4',
+ '../Core/ShowGeometryInstanceAttribute',
+ '../DynamicScene/ColorMaterialProperty',
+ '../DynamicScene/ConstantProperty',
+ '../DynamicScene/MaterialProperty',
+ '../DynamicScene/Property',
+ '../Scene/MaterialAppearance',
+ '../Scene/PerInstanceColorAppearance',
+ '../Scene/Primitive',
+ '../Scene/PrimitiveState',
+ '../Scene/SceneMode'
+ ], function(
+ Cartesian3,
+ Color,
+ ColorGeometryInstanceAttribute,
+ defaultValue,
+ defined,
+ defineProperties,
+ destroyObject,
+ DeveloperError,
+ EllipsoidGeometry,
+ EllipsoidOutlineGeometry,
+ Event,
+ GeometryInstance,
+ Iso8601,
+ Matrix3,
+ Matrix4,
+ ShowGeometryInstanceAttribute,
+ ColorMaterialProperty,
+ ConstantProperty,
+ MaterialProperty,
+ Property,
+ MaterialAppearance,
+ PerInstanceColorAppearance,
+ Primitive,
+ PrimitiveState,
+ SceneMode) {
+ "use strict";
+
+ var defaultMaterial = ColorMaterialProperty.fromColor(Color.WHITE);
+ var defaultShow = new ConstantProperty(true);
+ var defaultFill = new ConstantProperty(true);
+ var defaultOutline = new ConstantProperty(false);
+ var defaultOutlineColor = new ConstantProperty(Color.BLACK);
+
+ var positionScratch;
+ var orientationScratch;
+ var radiiScratch;
+ var matrix3Scratch;
+ var unitSphere = new Cartesian3(1, 1, 1);
+
+ var GeometryOptions = function(dynamicObject) {
+ this.id = dynamicObject;
+ this.vertexFormat = undefined;
+ this.radii = undefined;
+ this.stackPartitions = undefined;
+ this.slicePartitions = undefined;
+ this.subdivisions = undefined;
+ };
+
+ /**
+ * A {@link GeometryUpdater} for ellipsoids.
+ * Clients do not normally create this class directly, but instead rely on {@link DataSourceDisplay}.
+ * @alias EllipsoidGeometryUpdater
+ * @constructor
+ *
+ * @param {DynamicObject} dynamicObject The object containing the geometry to be visualized.
+ * @param {Scene} scene The scene where visualization is taking place.
+ */
+ var EllipsoidGeometryUpdater = function(dynamicObject, scene) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(dynamicObject)) {
+ throw new DeveloperError('dynamicObject is required');
+ }
+ if (!defined(scene)) {
+ throw new DeveloperError('scene is required');
+ }
+ //>>includeEnd('debug');
+
+ this._scene = scene;
+ this._dynamicObject = dynamicObject;
+ this._dynamicObjectSubscription = dynamicObject.definitionChanged.addEventListener(EllipsoidGeometryUpdater.prototype._onDynamicObjectPropertyChanged, this);
+ this._fillEnabled = false;
+ this._dynamic = false;
+ this._outlineEnabled = false;
+ this._geometryChanged = new Event();
+ this._showProperty = undefined;
+ this._materialProperty = undefined;
+ this._hasConstantOutline = true;
+ this._showOutlineProperty = undefined;
+ this._outlineColorProperty = undefined;
+ this._options = new GeometryOptions(dynamicObject);
+ this._onDynamicObjectPropertyChanged(dynamicObject, 'ellipsoid', dynamicObject.ellipsoid, undefined);
+ };
+
+ defineProperties(EllipsoidGeometryUpdater, {
+ /**
+ * Gets the type of Appearance to use for simple color-based geometry.
+ * @memberof EllipsoidGeometryUpdater
+ * @type {Appearance}
+ */
+ perInstanceColorAppearanceType : {
+ value : PerInstanceColorAppearance
+ },
+ /**
+ * Gets the type of Appearance to use for material-based geometry.
+ * @memberof EllipsoidGeometryUpdater
+ * @type {Appearance}
+ */
+ materialAppearanceType : {
+ value : MaterialAppearance
+ }
+ });
+
+ defineProperties(EllipsoidGeometryUpdater.prototype, {
+ /**
+ * Gets the object associated with this geometry.
+ * @memberof EllipsoidGeometryUpdater.prototype
+ * @type {DynamicObject}
+ */
+ dynamicObject : {
+ get : function() {
+ return this._dynamicObject;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry has a fill component.
+ * @memberof EllipsoidGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ fillEnabled : {
+ get : function() {
+ return this._fillEnabled;
+ }
+ },
+ /**
+ * Gets a value indicating if fill visibility varies with simulation time.
+ * @memberof EllipsoidGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ hasConstantFill : {
+ get : function() {
+ return !this._fillEnabled ||
+ (!defined(this._dynamicObject.availability) &&
+ Property.isConstant(this._showProperty) &&
+ Property.isConstant(this._fillProperty));
+ }
+ },
+ /**
+ * Gets the material property used to fill the geometry.
+ * @memberof EllipsoidGeometryUpdater.prototype
+ * @type {MaterialProperty}
+ */
+ fillMaterialProperty : {
+ get : function() {
+ return this._materialProperty;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry has an outline component.
+ * @memberof EllipsoidGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ outlineEnabled : {
+ get : function() {
+ return this._outlineEnabled;
+ }
+ },
+ /**
+ * Gets a value indicating if outline visibility varies with simulation time.
+ * @memberof EllipsoidGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ hasConstantOutline : {
+ get : function() {
+ return !this._outlineEnabled ||
+ (!defined(this._dynamicObject.availability) &&
+ Property.isConstant(this._showProperty) &&
+ Property.isConstant(this._showOutlineProperty));
+ }
+ },
+ /**
+ * Gets the {@link Color} property for the geometry outline.
+ * @memberof EllipsoidGeometryUpdater.prototype
+ * @type {Property}
+ */
+ outlineColorProperty : {
+ get : function() {
+ return this._outlineColorProperty;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry is time-varying.
+ * If true, all visualization is delegated to the {@link DynamicGeometryUpdater}
+ * returned by GeometryUpdater#createDynamicUpdater.
+ *
+ * @memberof EllipsoidGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ isDynamic : {
+ get : function() {
+ return this._dynamic;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry is closed.
+ * This property is only valid for static geometry.
+ * @memberof EllipsoidGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ isClosed : {
+ value : true
+ },
+ /**
+ * Gets an event that is raised whenever the public properties
+ * of this updater change.
+ * @memberof EllipsoidGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ geometryChanged : {
+ get : function() {
+ return this._geometryChanged;
+ }
+ }
+ });
+
+ /**
+ * Checks if the geometry is outlined at the provided time.
+ * @memberof EllipsoidGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time for which to retrieve visibility.
+ * @returns {Boolean} true if geometry is outlined at the provided time, false otherwise.
+ */
+ EllipsoidGeometryUpdater.prototype.isOutlineVisible = function(time) {
+ var dynamicObject = this._dynamicObject;
+ return this._outlineEnabled && dynamicObject.isAvailable(time) && this._showProperty.getValue(time) && this._showOutlineProperty.getValue(time);
+ };
+
+ /**
+ * Checks if the geometry is filled at the provided time.
+ * @memberof EllipsoidGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time for which to retrieve visibility.
+ * @returns {Boolean} true if geometry is filled at the provided time, false otherwise.
+ */
+ EllipsoidGeometryUpdater.prototype.isFilled = function(time) {
+ var dynamicObject = this._dynamicObject;
+ return this._fillEnabled && dynamicObject.isAvailable(time) && this._showProperty.getValue(time) && this._fillProperty.getValue(time);
+ };
+
+ /**
+ * Creates the geometry instance which represents the fill of the geometry.
+ * @memberof EllipsoidGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time to use when retrieving initial attribute values.
+ * @returns {GeometryInstance} The geometry instance representing the filled portion of the geometry.
+ *
+ * @exception {DeveloperError} This instance does not represent a filled geometry.
+ */
+ EllipsoidGeometryUpdater.prototype.createFillGeometryInstance = function(time) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+
+ if (!this._fillEnabled) {
+ throw new DeveloperError('This instance does not represent a filled geometry.');
+ }
+ //>>includeEnd('debug');
+
+ var dynamicObject = this._dynamicObject;
+ var isAvailable = dynamicObject.isAvailable(time);
+
+ var attributes;
+
+ var color;
+ var show = new ShowGeometryInstanceAttribute(isAvailable && this._showProperty.getValue(time) && this._fillProperty.getValue(time));
+ if (this._materialProperty instanceof ColorMaterialProperty) {
+ var currentColor = Color.WHITE;
+ if (defined(this._materialProperty.color) && (this._materialProperty.color.isConstant || isAvailable)) {
+ currentColor = this._materialProperty.color.getValue(time);
+ }
+ color = ColorGeometryInstanceAttribute.fromColor(currentColor);
+ attributes = {
+ show : show,
+ color : color
+ };
+ } else {
+ attributes = {
+ show : show
+ };
+ }
+
+ positionScratch = dynamicObject.position.getValue(Iso8601.MINIMUM_VALUE, positionScratch);
+ orientationScratch = dynamicObject.orientation.getValue(Iso8601.MINIMUM_VALUE, orientationScratch);
+ matrix3Scratch = Matrix3.fromQuaternion(orientationScratch, matrix3Scratch);
+
+ return new GeometryInstance({
+ id : dynamicObject,
+ geometry : new EllipsoidGeometry(this._options),
+ modelMatrix : Matrix4.fromRotationTranslation(matrix3Scratch, positionScratch),
+ attributes : attributes
+ });
+ };
+
+ /**
+ * Creates the geometry instance which represents the outline of the geometry.
+ * @memberof EllipsoidGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time to use when retrieving initial attribute values.
+ * @returns {GeometryInstance} The geometry instance representing the outline portion of the geometry.
+ *
+ * @exception {DeveloperError} This instance does not represent an outlined geometry.
+ */
+ EllipsoidGeometryUpdater.prototype.createOutlineGeometryInstance = function(time) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+
+ if (!this._outlineEnabled) {
+ throw new DeveloperError('This instance does not represent an outlined geometry.');
+ }
+ //>>includeEnd('debug');
+
+ var dynamicObject = this._dynamicObject;
+ var isAvailable = dynamicObject.isAvailable(time);
+
+ positionScratch = dynamicObject.position.getValue(Iso8601.MINIMUM_VALUE, positionScratch);
+ orientationScratch = dynamicObject.orientation.getValue(Iso8601.MINIMUM_VALUE, orientationScratch);
+ matrix3Scratch = Matrix3.fromQuaternion(orientationScratch, matrix3Scratch);
+
+ return new GeometryInstance({
+ id : dynamicObject,
+ geometry : new EllipsoidOutlineGeometry(this._options),
+ modelMatrix : Matrix4.fromRotationTranslation(matrix3Scratch, positionScratch),
+ attributes : {
+ show : new ShowGeometryInstanceAttribute(isAvailable && this._showProperty.getValue(time) && this._showOutlineProperty.getValue(time)),
+ color : ColorGeometryInstanceAttribute.fromColor(isAvailable ? this._outlineColorProperty.getValue(time) : Color.BLACK)
+ }
+ });
+ };
+
+ /**
+ * Returns true if this object was destroyed; otherwise, false.
+ * @memberof EllipsoidGeometryUpdater
+ * @function
+ *
+ * @returns {Boolean} True if this object was destroyed; otherwise, false.
+ */
+ EllipsoidGeometryUpdater.prototype.isDestroyed = function() {
+ return false;
+ };
+
+ /**
+ * Destroys and resources used by the object. Once an object is destroyed, it should not be used.
+ * @memberof EllipsoidGeometryUpdater
+ * @function
+ *
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
+ */
+ EllipsoidGeometryUpdater.prototype.destroy = function() {
+ this._dynamicObjectSubscription();
+ destroyObject(this);
+ };
+
+ EllipsoidGeometryUpdater.prototype._onDynamicObjectPropertyChanged = function(dynamicObject, propertyName, newValue, oldValue) {
+ if (!(propertyName === 'availability' || propertyName === 'position' || propertyName === 'orientation' || propertyName === 'ellipsoid')) {
+ return;
+ }
+
+ var ellipsoid = this._dynamicObject.ellipsoid;
+
+ if (!defined(ellipsoid)) {
+ if (this._fillEnabled || this._outlineEnabled) {
+ this._fillEnabled = false;
+ this._outlineEnabled = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ return;
+ }
+
+ var fillProperty = ellipsoid.fill;
+ var fillEnabled = defined(fillProperty) && fillProperty.isConstant ? fillProperty.getValue(Iso8601.MINIMUM_VALUE) : true;
+
+ var outlineProperty = ellipsoid.outline;
+ var outlineEnabled = defined(outlineProperty);
+ if (outlineEnabled && outlineProperty.isConstant) {
+ outlineEnabled = outlineProperty.getValue(Iso8601.MINIMUM_VALUE);
+ }
+
+ if (!fillEnabled && !outlineEnabled) {
+ if (this._fillEnabled || this._outlineEnabled) {
+ this._fillEnabled = false;
+ this._outlineEnabled = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ return;
+ }
+
+ var position = this._dynamicObject.position;
+ var orientation = this._dynamicObject.orientation;
+ var radii = ellipsoid.radii;
+
+ var show = ellipsoid.show;
+ if ((defined(show) && show.isConstant && !show.getValue(Iso8601.MINIMUM_VALUE)) || //
+ (!defined(position) || !defined(orientation) || !defined(radii))) {
+ if (this._fillEnabled || this._outlineEnabled) {
+ this._fillEnabled = false;
+ this._outlineEnabled = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ return;
+ }
+
+ var material = defaultValue(ellipsoid.material, defaultMaterial);
+ var isColorMaterial = material instanceof ColorMaterialProperty;
+ this._materialProperty = material;
+ this._fillProperty = defaultValue(fillProperty, defaultFill);
+ this._showProperty = defaultValue(show, defaultShow);
+ this._showOutlineProperty = defaultValue(ellipsoid.outline, defaultOutline);
+ this._outlineColorProperty = outlineEnabled ? defaultValue(ellipsoid.outlineColor, defaultOutlineColor) : undefined;
+ this._fillEnabled = fillEnabled;
+ this._outlineEnabled = outlineEnabled;
+
+ var stackPartitions = ellipsoid.stackPartitions;
+ var slicePartitions = ellipsoid.slicePartitions;
+ var subdivisions = ellipsoid.subdivisions;
+
+ if (!position.isConstant || //
+ !orientation.isConstant || //
+ !radii.isConstant || //
+ !Property.isConstant(stackPartitions) || //
+ !Property.isConstant(slicePartitions) || //
+ !Property.isConstant(subdivisions)) {
+ if (!this._dynamic) {
+ this._dynamic = true;
+ this._geometryChanged.raiseEvent(this);
+ }
+ } else {
+ var options = this._options;
+ options.vertexFormat = isColorMaterial ? PerInstanceColorAppearance.VERTEX_FORMAT : MaterialAppearance.VERTEX_FORMAT;
+ options.radii = radii.getValue(Iso8601.MINIMUM_VALUE, options.radii);
+ options.stackPartitions = defined(stackPartitions) ? stackPartitions.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ options.slicePartitions = defined(slicePartitions) ? slicePartitions.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ options.subdivisions = defined(subdivisions) ? subdivisions.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ this._dynamic = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ };
+
+ /**
+ * Creates the dynamic updater to be used when GeometryUpdater#isDynamic is true.
+ * @memberof EllipsoidGeometryUpdater
+ * @function
+ *
+ * @param {CompositePrimitive} primitives The primitive collection to use.
+ * @returns {DynamicGeometryUpdater} The dynamic updater used to update the geometry each frame.
+ *
+ * @exception {DeveloperError} This instance does not represent dynamic geometry.
+ */
+ EllipsoidGeometryUpdater.prototype.createDynamicUpdater = function(primitives) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!this._dynamic) {
+ throw new DeveloperError('This instance does not represent dynamic geometry.');
+ }
+
+ if (!defined(primitives)) {
+ throw new DeveloperError('primitives is required.');
+ }
+ //>>includeEnd('debug');
+
+ return new DynamicGeometryUpdater(primitives, this);
+ };
+
+ /**
+ * @private
+ */
+ var DynamicGeometryUpdater = function(primitives, geometryUpdater) {
+ this._dynamicObject = geometryUpdater._dynamicObject;
+ this._scene = geometryUpdater._scene;
+ this._primitives = primitives;
+ this._primitive = undefined;
+ this._outlinePrimitive = undefined;
+ this._geometryUpdater = geometryUpdater;
+ this._options = new GeometryOptions(geometryUpdater._dynamicObject);
+ this._modelMatrix = new Matrix4();
+ this._material = undefined;
+ this._attributes = undefined;
+ this._outlineAttributes = undefined;
+ this._lastSceneMode = undefined;
+ };
+
+ DynamicGeometryUpdater.prototype.update = function(time) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+ //>>includeEnd('debug');
+
+ var dynamicObject = this._dynamicObject;
+ var ellipsoid = dynamicObject.ellipsoid;
+ var show = ellipsoid.show;
+
+ if (!dynamicObject.isAvailable(time) || (defined(show) && !show.getValue(time))) {
+ if (defined(this._primitive)) {
+ this._primitive.show = false;
+ }
+
+ if (defined(this._outlinePrimitive)) {
+ this._outlinePrimitive.show = false;
+ }
+ return;
+ }
+
+ //Compute attributes and material.
+ var appearance;
+ var showFill = !defined(ellipsoid.fill) || ellipsoid.fill.getValue(time);
+ var showOutline = defined(ellipsoid.outline) && ellipsoid.outline.getValue(time);
+ var outlineColor = defined(ellipsoid.outlineColor) ? ellipsoid.outlineColor.getValue(time) : Color.BLACK;
+ var material = MaterialProperty.getValue(time, defaultValue(ellipsoid.material, defaultMaterial), this._material);
+ this._material = material;
+
+ // Check properties that could trigger a primitive rebuild.
+ var stackPartitionsProperty = ellipsoid.stackPartitions;
+ var slicePartitionsProperty = ellipsoid.slicePartitions;
+ var subdivisionsProperty = ellipsoid.subdivisions;
+ var stackPartitions = defined(stackPartitionsProperty) ? stackPartitionsProperty.getValue(time) : undefined;
+ var slicePartitions = defined(slicePartitionsProperty) ? slicePartitionsProperty.getValue(time) : undefined;
+ var subdivisions = defined(subdivisionsProperty) ? subdivisionsProperty.getValue(time) : undefined;
+
+ var options = this._options;
+
+ //In 3D we use a fast path by modifying Primitive.modelMatrix instead of regenerating the primitive every frame.
+ //Once #1486 is fixed, we can use the fast path in all cases.
+ var sceneMode = this._scene.mode;
+ var in3D = sceneMode === SceneMode.SCENE3D;
+
+ var modelMatrix = this._modelMatrix;
+ var positionProperty = dynamicObject.position;
+ var orientationProperty = dynamicObject.orientation;
+ var radiiProperty = ellipsoid.radii;
+ positionScratch = positionProperty.getValue(time, positionScratch);
+ orientationScratch = orientationProperty.getValue(time, orientationScratch);
+ matrix3Scratch = Matrix3.fromQuaternion(orientationScratch, matrix3Scratch);
+ radiiScratch = radiiProperty.getValue(time, radiiScratch);
+ modelMatrix = Matrix4.fromRotationTranslation(matrix3Scratch, positionScratch, modelMatrix);
+
+ //We only rebuild the primitive if something other than the radii has changed
+ //For the radii, we use unit sphere and then deform it with a scale matrix.
+ var rebuildPrimitives = !in3D || this._lastSceneMode !== sceneMode || !defined(this._primitive) || options.stackPartitions !== stackPartitions || options.slicePartitions !== slicePartitions || options.subdivisions !== subdivisions;
+ if (rebuildPrimitives) {
+ this._removePrimitives();
+ this._lastSceneMode = sceneMode;
+
+ options.stackPartitions = stackPartitions;
+ options.slicePartitions = slicePartitions;
+ options.subdivisions = subdivisions;
+ options.radii = in3D ? unitSphere : radiiScratch;
+
+ this._material = material;
+ material = this._material;
+ appearance = new MaterialAppearance({
+ material : material,
+ faceForward : true,
+ translucent : material.isTranslucent(),
+ closed : true
+ });
+ options.vertexFormat = appearance.vertexFormat;
+
+ this._primitive = new Primitive({
+ geometryInstances : new GeometryInstance({
+ id : dynamicObject,
+ geometry : new EllipsoidGeometry(options),
+ modelMatrix : !in3D ? modelMatrix : undefined
+ }),
+ appearance : appearance,
+ asynchronous : false,
+ attributes : {
+ show : new ShowGeometryInstanceAttribute(showFill)
+ }
+ });
+ this._primitives.add(this._primitive);
+
+ options.vertexFormat = PerInstanceColorAppearance.VERTEX_FORMAT;
+ this._outlinePrimitive = new Primitive({
+ geometryInstances : new GeometryInstance({
+ id : dynamicObject,
+ geometry : new EllipsoidOutlineGeometry(options),
+ modelMatrix : !in3D ? modelMatrix : undefined,
+ attributes : {
+ show : new ShowGeometryInstanceAttribute(showOutline),
+ color : ColorGeometryInstanceAttribute.fromColor(outlineColor)
+ }
+ }),
+ appearance : new PerInstanceColorAppearance({
+ flat : true,
+ translucent : outlineColor.alpha !== 1.0
+ }),
+ asynchronous : false
+ });
+ this._primitives.add(this._outlinePrimitive);
+ } else if (this._primitive._state === PrimitiveState.COMPLETE) {
+ //Update attributes only.
+ var primitive = this._primitive;
+ appearance = primitive.appearance;
+ appearance.material = material;
+
+ var attributes = this._attributes;
+ if (!defined(attributes)) {
+ attributes = primitive.getGeometryInstanceAttributes(dynamicObject);
+ this._attributes = attributes;
+ }
+ attributes.show = ShowGeometryInstanceAttribute.toValue(showFill, attributes.show);
+
+ var outlinePrimitive = this._outlinePrimitive;
+
+ var outlineAttributes = this._outlineAttributes;
+ if (!defined(outlineAttributes)) {
+ outlineAttributes = outlinePrimitive.getGeometryInstanceAttributes(dynamicObject);
+ this._outlineAttributes = outlineAttributes;
+ }
+ outlineAttributes.show = ShowGeometryInstanceAttribute.toValue(showOutline, outlineAttributes.show);
+ outlineAttributes.color = ColorGeometryInstanceAttribute.toValue(outlineColor, outlineAttributes.color);
+ }
+
+ if (in3D) {
+ modelMatrix = Matrix4.multiplyByScale(modelMatrix, radiiScratch, modelMatrix);
+ this._primitive.modelMatrix = modelMatrix;
+ this._outlinePrimitive.modelMatrix = modelMatrix;
+ }
+ };
+
+ DynamicGeometryUpdater.prototype.isDestroyed = function() {
+ return false;
+ };
+
+ DynamicGeometryUpdater.prototype._removePrimitives = function() {
+ if (defined(this._primitive)) {
+ this._primitives.remove(this._primitive);
+ }
+
+ if (defined(this._outlinePrimitive)) {
+ this._primitives.remove(this._outlinePrimitive);
+ }
+ };
+
+ DynamicGeometryUpdater.prototype.destroy = function() {
+ this._removePrimitives();
+ destroyObject(this);
+ };
+
+ return EllipsoidGeometryUpdater;
+});
\ No newline at end of file
diff --git a/Source/DynamicScene/GeoJsonDataSource.js b/Source/DynamicScene/GeoJsonDataSource.js
index 1150c0bbc512..94948b718ebb 100644
--- a/Source/DynamicScene/GeoJsonDataSource.js
+++ b/Source/DynamicScene/GeoJsonDataSource.js
@@ -302,7 +302,7 @@ define([
defaultPolygon.polygon = polygon;
material = new ColorMaterialProperty();
- material.color = new ConstantProperty(new Color(1.0, 1.0, 0.0, 0.1));
+ material.color = new ConstantProperty(new Color(1.0, 1.0, 0.0, 0.2));
polygon.material = material;
this._changed = new Event();
diff --git a/Source/DynamicScene/GeometryUpdater.js b/Source/DynamicScene/GeometryUpdater.js
new file mode 100644
index 000000000000..7974989110bf
--- /dev/null
+++ b/Source/DynamicScene/GeometryUpdater.js
@@ -0,0 +1,213 @@
+/*global define*/
+define(['../Core/defineProperties',
+ '../Core/DeveloperError'
+ ], function(
+ defineProperties,
+ DeveloperError) {
+ "use strict";
+
+ /**
+ * Defines the interface for a geometry updater. A GeometryUpdater maps
+ * geometry defined as part of a {@link DynamicObject} into {@link Geometry}
+ * instances. These instances are then visualized by {@link GeometryVisualizer}.
+ *
+ * This type defines an interface and cannot be instantiated directly.
+ *
+ * @alias GeometryUpdater
+ * @constructor
+ *
+ * @param {DynamicObject} dynamicObject The object containing the geometry to be visualized.
+ * @param {Scene} scene The scene where visualization is taking place.
+ *
+ * @see EllipseGeometryUpdater
+ * @see EllipsoidGeometryUpdater
+ * @see PolygonGeometryUpdater
+ * @see PolylineGeometryUpdater
+ */
+ var GeometryUpdater = function(dynamicObject, scene) {
+ DeveloperError.throwInstantiationError();
+ };
+
+ defineProperties(GeometryUpdater, {
+ /**
+ * Gets the type of Appearance to use for simple color-based geometry.
+ * @memberof GeometryUpdater
+ * @type {Appearance}
+ */
+ perInstanceColorAppearanceType : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets the type of Appearance to use for material-based geometry.
+ * @memberof GeometryUpdater
+ * @type {Appearance}
+ */
+ materialAppearanceType : {
+ get : DeveloperError.throwInstantiationError
+ }
+ });
+
+ defineProperties(GeometryUpdater.prototype, {
+ /**
+ * Gets the object associated with this geometry.
+ * @memberof GeometryUpdater.prototype
+ * @type {DynamicObject}
+ */
+ dynamicObject : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets a value indicating if the geometry has a fill component.
+ * @memberof GeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ fillEnabled : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets a value indicating if fill visibility varies with simulation time.
+ * @memberof GeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ hasConstantFill : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets the material property used to fill the geometry.
+ * @memberof GeometryUpdater.prototype
+ * @type {MaterialProperty}
+ */
+ fillMaterialProperty : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets a value indicating if the geometry has an outline component.
+ * @memberof GeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ outlineEnabled : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets a value indicating if outline visibility varies with simulation time.
+ * @memberof GeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ hasConstantOutline : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets the {@link Color} property for the geometry outline.
+ * @memberof GeometryUpdater.prototype
+ * @type {Property}
+ */
+ outlineColorProperty : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets a value indicating if the geometry is time-varying.
+ * If true, all visualization is delegated to the {@link DynamicGeometryUpdater}
+ * returned by GeometryUpdater#createDynamicUpdater.
+ *
+ * @memberof GeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ isDynamic : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets a value indicating if the geometry is closed.
+ * This property is only valid for static geometry.
+ * @memberof GeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ isClosed : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets an event that is raised whenever the public properties
+ * of this updater change.
+ * @memberof GeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ geometryChanged : {
+ get : DeveloperError.throwInstantiationError
+ }
+ });
+
+ /**
+ * Checks if the geometry is outlined at the provided time.
+ * @memberof GeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time for which to retrieve visibility.
+ * @returns {Boolean} true if geometry is outlined at the provided time, false otherwise.
+ */
+ GeometryUpdater.prototype.isOutlineVisible = DeveloperError.throwInstantiationError;
+
+ /**
+ * Checks if the geometry is filled at the provided time.
+ * @memberof GeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time for which to retrieve visibility.
+ * @returns {Boolean} true if geometry is filled at the provided time, false otherwise.
+ */
+ GeometryUpdater.prototype.isFilled = DeveloperError.throwInstantiationError;
+
+ /**
+ * Creates the geometry instance which represents the fill of the geometry.
+ * @memberof GeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time to use when retrieving initial attribute values.
+ * @returns {GeometryInstance} The geometry instance representing the filled portion of the geometry.
+ *
+ * @exception {DeveloperError} This instance does not represent a filled geometry.
+ */
+ GeometryUpdater.prototype.createFillGeometryInstance = DeveloperError.throwInstantiationError;
+
+ /**
+ * Creates the geometry instance which represents the outline of the geometry.
+ * @memberof GeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time to use when retrieving initial attribute values.
+ * @returns {GeometryInstance} The geometry instance representing the outline portion of the geometry.
+ *
+ * @exception {DeveloperError} This instance does not represent an outlined geometry.
+ */
+ GeometryUpdater.prototype.createOutlineGeometryInstance = DeveloperError.throwInstantiationError;
+
+ /**
+ * Returns true if this object was destroyed; otherwise, false.
+ * @memberof GeometryUpdater
+ * @function
+ *
+ * @returns {Boolean} True if this object was destroyed; otherwise, false.
+ */
+ GeometryUpdater.prototype.isDestroyed = DeveloperError.throwInstantiationError;
+
+ /**
+ * Destroys and resources used by the object. Once an object is destroyed, it should not be used.
+ * @memberof GeometryUpdater
+ * @function
+ *
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
+ */
+ GeometryUpdater.prototype.destroy = DeveloperError.throwInstantiationError;
+
+ /**
+ * Creates the dynamic updater to be used when GeometryUpdater#isDynamic is true.
+ * @memberof GeometryUpdater
+ * @function
+ *
+ * @param {CompositePrimitive} primitives The primitive collection to use.
+ * @returns {DynamicGeometryUpdater} The dynamic updater used to update the geometry each frame.
+ *
+ * @exception {DeveloperError} This instance does not represent dynamic geometry.
+ */
+ GeometryUpdater.prototype.createDynamicUpdater = DeveloperError.throwInstantiationError;
+
+ return GeometryUpdater;
+});
\ No newline at end of file
diff --git a/Source/DynamicScene/GeometryVisualizer.js b/Source/DynamicScene/GeometryVisualizer.js
new file mode 100644
index 000000000000..0ab06db8ff1f
--- /dev/null
+++ b/Source/DynamicScene/GeometryVisualizer.js
@@ -0,0 +1,352 @@
+/*global define*/
+define(['../Core/AssociativeArray',
+ '../Core/defined',
+ '../Core/DeveloperError',
+ '../Core/destroyObject',
+ '../Scene/PerInstanceColorAppearance',
+ '../Scene/PolylineColorAppearance',
+ '../Scene/MaterialAppearance',
+ '../Scene/PolylineMaterialAppearance',
+ './ColorMaterialProperty',
+ './StaticGeometryColorBatch',
+ './StaticGeometryPerMaterialBatch',
+ './StaticOutlineGeometryBatch'
+ ], function(
+ AssociativeArray,
+ defined,
+ DeveloperError,
+ destroyObject,
+ PerInstanceColorAppearance,
+ PolylineColorAppearance,
+ MaterialAppearance,
+ PolylineMaterialAppearance,
+ ColorMaterialProperty,
+ StaticGeometryColorBatch,
+ StaticGeometryPerMaterialBatch,
+ StaticOutlineGeometryBatch) {
+ "use strict";
+
+ var emptyArray = [];
+
+ var DynamicGeometryBatch = function(primitives) {
+ this._primitives = primitives;
+ this._dynamicUpdaters = new AssociativeArray();
+ };
+
+ DynamicGeometryBatch.prototype.add = function(time, updater) {
+ this._dynamicUpdaters.set(updater.dynamicObject.id, updater.createDynamicUpdater(this._primitives));
+ };
+
+ DynamicGeometryBatch.prototype.remove = function(updater) {
+ var id = updater.dynamicObject.id;
+ var dynamicUpdater = this._dynamicUpdaters.get(id);
+ if (defined(dynamicUpdater)) {
+ this._dynamicUpdaters.remove(id);
+ dynamicUpdater.destroy();
+ }
+ };
+
+ DynamicGeometryBatch.prototype.update = function(time) {
+ var geometries = this._dynamicUpdaters.values;
+ for (var i = 0, len = geometries.length; i < len; i++) {
+ geometries[i].update(time);
+ }
+ };
+
+ DynamicGeometryBatch.prototype.removeAllPrimitives = function() {
+ var geometries = this._dynamicUpdaters.values;
+ for (var i = 0, len = geometries.length; i < len; i++) {
+ geometries[i].destroy();
+ }
+ this._dynamicUpdaters.removeAll();
+ };
+
+ /**
+ * A general purpose visualizer for all graphics that can be 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.
+ */
+ var GeometryVisualizer = function(type, scene, dynamicObjectCollection) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(type)) {
+ throw new DeveloperError('type is required.');
+ }
+ if (!defined(scene)) {
+ throw new DeveloperError('scene is required.');
+ }
+ //>>includeEnd('debug');
+
+ this._type = type;
+
+ var primitives = scene.primitives;
+ this._scene = scene;
+ this._primitives = primitives;
+ this._dynamicObjectCollection = undefined;
+ this._addedObjects = new AssociativeArray();
+ this._removedObjects = new AssociativeArray();
+ this._changedObjects = new AssociativeArray();
+
+ this._outlineBatch = new StaticOutlineGeometryBatch(primitives);
+ this._closedColorBatch = new StaticGeometryColorBatch(primitives, type.perInstanceColorAppearanceType, true);
+ this._closedMaterialBatch = new StaticGeometryPerMaterialBatch(primitives, type.materialAppearanceType, true);
+ this._openColorBatch = new StaticGeometryColorBatch(primitives, type.perInstanceColorAppearanceType, false);
+ this._openMaterialBatch = new StaticGeometryPerMaterialBatch(primitives, type.materialAppearanceType, false);
+ this._dynamicBatch = new DynamicGeometryBatch(primitives);
+
+ 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;
+ };
+
+ /**
+ * 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.
+ * @memberof GeometryVisualizer
+ *
+ * @param {JulianDate} time The time to update to.
+ */
+ GeometryVisualizer.prototype.update = function(time) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+ //>>includeEnd('debug');
+
+
+ var addedObjects = this._addedObjects;
+ var added = addedObjects.values;
+ var removedObjects = this._removedObjects;
+ var removed = removedObjects.values;
+ var changedObjects = this._changedObjects;
+ var changed = changedObjects.values;
+
+ var i;
+ var g;
+ var dynamicObject;
+ var id;
+ var updater;
+ var batch;
+
+ for (i = removed.length - 1; i > -1; i--) {
+ dynamicObject = removed[i];
+ id = dynamicObject.id;
+ updater = this._updaters.get(id);
+ removeUpdater(this, updater);
+ updater.destroy();
+ this._updaters.remove(id);
+ this._subscriptions.get(id)();
+ this._subscriptions.remove(id);
+ }
+
+ for (i = added.length - 1; i > -1; i--) {
+ dynamicObject = added[i];
+ id = dynamicObject.id;
+ updater = new this._type(dynamicObject, this._scene);
+ this._updaters.set(id, updater);
+ insertUpdaterIntoBatch(this, time, updater);
+ this._subscriptions.set(id, updater.geometryChanged.addEventListener(GeometryVisualizer._onGeometryChanged, this));
+ }
+
+ for (i = changed.length - 1; i > -1; i--) {
+ dynamicObject = changed[i];
+ id = dynamicObject.id;
+ updater = this._updaters.get(id);
+ removeUpdater(this, updater);
+ insertUpdaterIntoBatch(this, time, updater);
+ }
+
+ addedObjects.removeAll();
+ removedObjects.removeAll();
+ changedObjects.removeAll();
+
+ this._outlineBatch.update(time);
+ this._closedColorBatch.update(time);
+ this._closedMaterialBatch.update(time);
+ this._openColorBatch.update(time);
+ this._openMaterialBatch.update(time);
+ this._dynamicBatch.update(time);
+ };
+
+ /**
+ * Removes all primitives from the scene.
+ * @memberof GeometryVisualizer
+ */
+ GeometryVisualizer.prototype.removeAllPrimitives = function() {
+ this._addedObjects.removeAll();
+ this._removedObjects.removeAll();
+
+ this._outlineBatch.removeAllPrimitives();
+ this._closedColorBatch.removeAllPrimitives();
+ this._closedMaterialBatch.removeAllPrimitives();
+ this._openColorBatch.removeAllPrimitives();
+ this._openMaterialBatch.removeAllPrimitives();
+ this._dynamicBatch.removeAllPrimitives();
+
+ var subscriptions = this._subscriptions.values;
+ var len = subscriptions.length;
+ for (var i = 0; i < len; i++) {
+ subscriptions[i]();
+ }
+ this._subscriptions.removeAll();
+ };
+
+ /**
+ * Returns true if this object was destroyed; otherwise, false.
+ * 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.
+ * 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);
+ };
+
+ /**
+ * @private
+ */
+ GeometryVisualizer._onGeometryChanged = function(updater) {
+ var removedObjects = this._removedObjects;
+ var changedObjects = this._changedObjects;
+
+ var dynamicObject = updater.dynamicObject;
+ var id = dynamicObject.id;
+
+ if (!defined(removedObjects.get(id)) && !defined(this._changedObjects.get(id))) {
+ this._changedObjects.set(id, dynamicObject);
+ }
+ };
+
+ /**
+ * @private
+ */
+ GeometryVisualizer.prototype._onCollectionChanged = function(dynamicObjectCollection, added, removed) {
+ var addedObjects = this._addedObjects;
+ var removedObjects = this._removedObjects;
+ var changedObjects = this._changedObjects;
+
+ var i;
+ var id;
+ var dynamicObject;
+ for (i = removed.length - 1; i > -1; i--) {
+ dynamicObject = removed[i];
+ id = dynamicObject.id;
+ if (!addedObjects.remove(id)) {
+ removedObjects.set(id, dynamicObject);
+ changedObjects.remove(id);
+ }
+ }
+
+ for (i = added.length - 1; i > -1; i--) {
+ dynamicObject = added[i];
+ id = dynamicObject.id;
+ if (removedObjects.remove(id)) {
+ changedObjects.set(id, dynamicObject);
+ } else {
+ addedObjects.set(id, dynamicObject);
+ }
+ }
+ };
+
+ return GeometryVisualizer;
+});
diff --git a/Source/DynamicScene/GridMaterialProperty.js b/Source/DynamicScene/GridMaterialProperty.js
index 3f36779e5110..58c2441d48f7 100644
--- a/Source/DynamicScene/GridMaterialProperty.js
+++ b/Source/DynamicScene/GridMaterialProperty.js
@@ -1,14 +1,19 @@
/*global define*/
-define([
- '../Core/Cartesian2',
+define(['../Core/Cartesian2',
'../Core/Color',
'../Core/defined',
+ '../Core/defineProperties',
+ '../Core/Event',
+ './createDynamicPropertyDescriptor',
'./ConstantProperty',
'./Property'
], function(
Cartesian2,
Color,
defined,
+ defineProperties,
+ Event,
+ createDynamicPropertyDescriptor,
ConstantProperty,
Property) {
"use strict";
@@ -19,34 +24,75 @@ define([
* @constructor
*/
var GridMaterialProperty = function() {
+ this._definitionChanged = new Event();
+ this._color = undefined;
+ this._colorSubscription = undefined;
+ this._cellAlpha = undefined;
+ this._cellAlphaSubscription = undefined;
+ this._lineCount = undefined;
+ this._lineCountSubscription = undefined;
+ this._lineThickness = undefined;
+ this._lineThicknessSubscription = undefined;
+
+ this.color = new ConstantProperty(Color.WHITE);
+ this.cellAlpha = new ConstantProperty(0.1);
+ this.lineCount = new ConstantProperty(new Cartesian2(8, 8));
+ this.lineThickness = new ConstantProperty(new Cartesian2(1.0, 1.0));
+ };
+
+ defineProperties(GridMaterialProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof GridMaterialProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return Property.isConstant(this._color) &&
+ Property.isConstant(this._cellAlpha) &&
+ Property.isConstant(this._lineCount) &&
+ Property.isConstant(this._lineThickness);
+ }
+ },
/**
- * A {@link Color} {@link Property} which determines the grid's color.
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is considered to have changed if a call to getValue would return
+ * a different result for the same time.
+ * @memberof GridMaterialProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
+ /**
+ * Gets or sets the {@link Color} property which determines the grid's color.
+ * @memberof GridMaterialProperty.prototype
* @type {Property}
* @default new ConstantProperty(Color.WHITE)
*/
- this.color = new ConstantProperty(Color.WHITE);
-
+ color : createDynamicPropertyDescriptor('color'),
/**
- * A numeric {@link Property} which determines the grid cells alpha value, when combined with the color alpha.
+ * Gets or sets the numeric property which determines the grid cells alpha value, when combined with the color alpha.
* @type {Property}
* @default new ConstantProperty(0.1)
*/
- this.cellAlpha = new ConstantProperty(0.1);
-
+ cellAlpha : createDynamicPropertyDescriptor('cellAlpha'),
/**
- * A {@link Cartesian2} {@link Property} which determines the number of rows and columns in the grid.
+ * Gets or sets the {@link Cartesian2} property which determines the number of rows and columns in the grid.
* @type {Property}
* @default new ConstantProperty(new Cartesian2(8, 8))
*/
- this.lineCount = new ConstantProperty(new Cartesian2(8, 8));
-
+ lineCount : createDynamicPropertyDescriptor('lineCount'),
/**
- * A {@link Cartesian2} {@link Property} which determines the thickness of rows and columns in the grid.
+ * Gets or sets the {@link Cartesian2} property which determines the thickness of rows and columns in the grid.
* @type {Property}
* @default new ConstantProperty(new Cartesian2(1.0, 1.0))
*/
- this.lineThickness = new ConstantProperty(new Cartesian2(1.0, 1.0));
- };
+ lineThickness : createDynamicPropertyDescriptor('lineThickness')
+ });
/**
* Gets the {@link Material} type at the provided time.
@@ -71,10 +117,10 @@ define([
if (!defined(result)) {
result = {};
}
- result.color = defined(this.color) ? this.color.getValue(time, result.color) : undefined;
- result.cellAlpha = defined(this.cellAlpha) ? this.cellAlpha.getValue(time) : undefined;
- result.lineCount = defined(this.lineCount) ? this.lineCount.getValue(time, result.lineCount) : undefined;
- result.lineThickness = defined(this.lineThickness) ? this.lineThickness.getValue(time, result.lineThickness) : undefined;
+ result.color = defined(this._color) ? this._color.getValue(time, result.color) : undefined;
+ result.cellAlpha = defined(this._cellAlpha) ? this._cellAlpha.getValue(time) : undefined;
+ result.lineCount = defined(this._lineCount) ? this._lineCount.getValue(time, result.lineCount) : undefined;
+ result.lineThickness = defined(this._lineThickness) ? this._lineThickness.getValue(time, result.lineThickness) : undefined;
return result;
};
@@ -88,11 +134,18 @@ define([
*/
GridMaterialProperty.prototype.equals = function(other) {
return this === other || //
- (other instanceof GridMaterialProperty && //
- Property.equals(this.color, other.color) && //
- Property.equals(this.cellAlpha, other.cellAlpha) && //
- Property.equals(this.lineCount, other.lineCount) && //
- Property.equals(this.lineThickness, other.lineThickness));
+ (other instanceof GridMaterialProperty && //
+ Property.equals(this._color, other._color) && //
+ Property.equals(this._cellAlpha, other._cellAlpha) && //
+ Property.equals(this._lineCount, other._lineCount) && //
+ Property.equals(this._lineThickness, other._lineThickness));
+ };
+
+ /**
+ * @private
+ */
+ GridMaterialProperty.prototype._raiseDefinitionChanged = function() {
+ this._definitionChanged.raiseEvent(this);
};
return GridMaterialProperty;
diff --git a/Source/DynamicScene/ImageMaterialProperty.js b/Source/DynamicScene/ImageMaterialProperty.js
index 051964140fb9..f795fdda8c4a 100644
--- a/Source/DynamicScene/ImageMaterialProperty.js
+++ b/Source/DynamicScene/ImageMaterialProperty.js
@@ -2,11 +2,17 @@
define([
'../Core/Cartesian2',
'../Core/defined',
+ '../Core/defineProperties',
+ '../Core/Event',
+ './createDynamicPropertyDescriptor',
'./ConstantProperty',
'./Property'
], function(
Cartesian2,
defined,
+ defineProperties,
+ Event,
+ createDynamicPropertyDescriptor,
ConstantProperty,
Property) {
"use strict";
@@ -17,18 +23,52 @@ define([
* @constructor
*/
var ImageMaterialProperty = function() {
+ this._definitionChanged = new Event();
+ this._image = undefined;
+ this._imageSubscription = undefined;
+ this._repeat = undefined;
+ this._repeatSubscription = undefined;
+ this.repeat = new ConstantProperty(new Cartesian2(1, 1));
+ };
+
+ defineProperties(ImageMaterialProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof ImageMaterialProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return Property.isConstant(this._image) && Property.isConstant(this._repeat);
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is considered to have changed if a call to getValue would return
+ * a different result for the same time.
+ * @memberof ImageMaterialProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
/**
- * A string {@link Property} which is the url of the desired image.
+ * Gets or sets the string property which is the url of the desired image.
+ * @memberof ImageMaterialProperty.prototype
* @type {Property}
*/
- this.image = undefined;
+ image : createDynamicPropertyDescriptor('image'),
/**
- * A {@link Cartesian2} {@link Property} which determines the number of times the image repeats in each direction.
+ * Gets or sets the {@link Cartesian2} property which determines the number of times the image repeats in each direction.
+ * @memberof ImageMaterialProperty.prototype
* @type {Property}
* @default new ConstantProperty(new Cartesian2(1, 1))
*/
- this.repeat = new ConstantProperty(new Cartesian2(1, 1));
- };
+ repeat : createDynamicPropertyDescriptor('repeat')
+ });
/**
* Gets the {@link Material} type at the provided time.
@@ -54,8 +94,8 @@ define([
result = {};
}
- result.image = defined(this.image) ? this.image.getValue(time) : undefined;
- result.repeat = defined(this.repeat) ? this.repeat.getValue(time, result.repeat) : undefined;
+ result.image = defined(this._image) ? this._image.getValue(time) : undefined;
+ result.repeat = defined(this._repeat) ? this._repeat.getValue(time, result.repeat) : undefined;
return result;
};
@@ -70,8 +110,15 @@ define([
ImageMaterialProperty.prototype.equals = function(other) {
return this === other || //
(other instanceof ImageMaterialProperty && //
- Property.equals(this.image, other.image) && //
- Property.equals(this.repeat, other.repeat));
+ Property.equals(this._image, other._image) && //
+ Property.equals(this._repeat, other._repeat));
+ };
+
+ /**
+ * @private
+ */
+ ImageMaterialProperty.prototype._raiseDefinitionChanged = function(){
+ this._definitionChanged.raiseEvent(this);
};
return ImageMaterialProperty;
diff --git a/Source/DynamicScene/MaterialProperty.js b/Source/DynamicScene/MaterialProperty.js
index 8be472558ba8..9673052f4246 100644
--- a/Source/DynamicScene/MaterialProperty.js
+++ b/Source/DynamicScene/MaterialProperty.js
@@ -1,18 +1,15 @@
/*global define*/
-define([
- '../Core/defined',
+define(['../Core/defined',
+ '../Core/defineProperties',
'../Core/DeveloperError',
'../Scene/Material'
], function(
defined,
+ defineProperties,
DeveloperError,
Material) {
"use strict";
- function throwInstantiationError() {
- throw new DeveloperError('This type should not be instantiated directly.');
- }
-
/**
* The interface for all {@link Property} objects that represent {@link Material} uniforms.
* This type defines an interface and cannot be instantiated directly.
@@ -25,7 +22,31 @@ define([
* @see GridMaterialProperty
* @see ImageMaterialProperty
*/
- var MaterialProperty = throwInstantiationError;
+ var MaterialProperty = function() {
+ DeveloperError.throwInstantiationError();
+ };
+
+ defineProperties(MaterialProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof MaterialProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is considered to have changed if a call to getValue would return
+ * a different result for the same time.
+ * @memberof MaterialProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : DeveloperError.throwInstantiationError
+ }
+ });
/**
* Gets the {@link Material} type at the provided time.
@@ -35,7 +56,7 @@ define([
* @param {JulianDate} time The time for which to retrieve the type.
* @type {String} The type of material.
*/
- MaterialProperty.prototype.getType = throwInstantiationError;
+ MaterialProperty.prototype.getType = DeveloperError.throwInstantiationError;
/**
* Gets the value of the property at the provided time.
@@ -46,7 +67,7 @@ define([
* @param {Object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {Object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
- MaterialProperty.prototype.getValue = throwInstantiationError;
+ MaterialProperty.prototype.getValue = DeveloperError.throwInstantiationError;
/**
* Compares this property to the provided property and returns
@@ -56,7 +77,7 @@ define([
* @param {Property} [other] The other property.
* @returns {Boolean} true
if left and right are equal, false
otherwise.
*/
- MaterialProperty.prototype.equals = throwInstantiationError;
+ MaterialProperty.prototype.equals = DeveloperError.throwInstantiationError;
/**
* @private
@@ -75,4 +96,4 @@ define([
};
return MaterialProperty;
-});
\ No newline at end of file
+});
diff --git a/Source/DynamicScene/PolygonGeometryUpdater.js b/Source/DynamicScene/PolygonGeometryUpdater.js
new file mode 100644
index 000000000000..d95d410c6615
--- /dev/null
+++ b/Source/DynamicScene/PolygonGeometryUpdater.js
@@ -0,0 +1,588 @@
+/*global define*/
+define(['../Core/Color',
+ '../Core/ColorGeometryInstanceAttribute',
+ '../Core/defaultValue',
+ '../Core/defined',
+ '../Core/defineProperties',
+ '../Core/destroyObject',
+ '../Core/DeveloperError',
+ '../Core/PolygonGeometry',
+ '../Core/PolygonOutlineGeometry',
+ '../Core/Event',
+ '../Core/GeometryInstance',
+ '../Core/Iso8601',
+ '../Core/ShowGeometryInstanceAttribute',
+ '../DynamicScene/ColorMaterialProperty',
+ '../DynamicScene/ConstantProperty',
+ '../DynamicScene/MaterialProperty',
+ '../DynamicScene/Property',
+ '../Scene/MaterialAppearance',
+ '../Scene/PerInstanceColorAppearance',
+ '../Scene/Primitive'
+ ], function(
+ Color,
+ ColorGeometryInstanceAttribute,
+ defaultValue,
+ defined,
+ defineProperties,
+ destroyObject,
+ DeveloperError,
+ PolygonGeometry,
+ PolygonOutlineGeometry,
+ Event,
+ GeometryInstance,
+ Iso8601,
+ ShowGeometryInstanceAttribute,
+ ColorMaterialProperty,
+ ConstantProperty,
+ MaterialProperty,
+ Property,
+ MaterialAppearance,
+ PerInstanceColorAppearance,
+ Primitive) {
+ "use strict";
+
+ var defaultMaterial = ColorMaterialProperty.fromColor(Color.WHITE);
+ var defaultShow = new ConstantProperty(true);
+ var defaultFill = new ConstantProperty(true);
+ var defaultOutline = new ConstantProperty(false);
+ var defaultOutlineColor = new ConstantProperty(Color.BLACK);
+
+ var GeometryOptions = function(dynamicObject) {
+ this.id = dynamicObject;
+ this.vertexFormat = undefined;
+ this.polygonHierarchy = {
+ positions : undefined
+ };
+ this.perPositionHeight = undefined;
+ this.height = undefined;
+ this.extrudedHeight = undefined;
+ this.granularity = undefined;
+ this.stRotation = undefined;
+ };
+
+ /**
+ * A {@link GeometryUpdater} for polygons.
+ * Clients do not normally create this class directly, but instead rely on {@link DataSourceDisplay}.
+ * @alias PolygonGeometryUpdater
+ * @constructor
+ *
+ * @param {DynamicObject} dynamicObject The object containing the geometry to be visualized.
+ */
+ var PolygonGeometryUpdater = function(dynamicObject) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(dynamicObject)) {
+ throw new DeveloperError('dynamicObject is required');
+ }
+ //>>includeEnd('debug');
+
+ this._dynamicObject = dynamicObject;
+ this._dynamicObjectSubscription = dynamicObject.definitionChanged.addEventListener(PolygonGeometryUpdater.prototype._onDynamicObjectPropertyChanged, this);
+ this._fillEnabled = false;
+ this._isClosed = false;
+ this._dynamic = false;
+ this._outlineEnabled = false;
+ this._geometryChanged = new Event();
+ this._showProperty = undefined;
+ this._materialProperty = undefined;
+ this._hasConstantOutline = true;
+ this._showOutlineProperty = undefined;
+ this._outlineColorProperty = undefined;
+ this._options = new GeometryOptions(dynamicObject);
+ this._onDynamicObjectPropertyChanged(dynamicObject, 'polygon', dynamicObject.polygon, undefined);
+ };
+
+ defineProperties(PolygonGeometryUpdater, {
+ /**
+ * Gets the type of Appearance to use for simple color-based geometry.
+ * @memberof PolygonGeometryUpdater
+ * @type {Appearance}
+ */
+ perInstanceColorAppearanceType : {
+ value : PerInstanceColorAppearance
+ },
+ /**
+ * Gets the type of Appearance to use for material-based geometry.
+ * @memberof PolygonGeometryUpdater
+ * @type {Appearance}
+ */
+ materialAppearanceType : {
+ value : MaterialAppearance
+ }
+ });
+
+ defineProperties(PolygonGeometryUpdater.prototype, {
+ /**
+ * Gets the object associated with this geometry.
+ * @memberof PolygonGeometryUpdater.prototype
+ * @type {DynamicObject}
+ */
+ dynamicObject :{
+ get : function() {
+ return this._dynamicObject;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry has a fill component.
+ * @memberof PolygonGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ fillEnabled : {
+ get : function() {
+ return this._fillEnabled;
+ }
+ },
+ /**
+ * Gets a value indicating if fill visibility varies with simulation time.
+ * @memberof PolygonGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ hasConstantFill : {
+ get : function() {
+ return !this._fillEnabled ||
+ (!defined(this._dynamicObject.availability) &&
+ Property.isConstant(this._showProperty) &&
+ Property.isConstant(this._fillProperty));
+ }
+ },
+ /**
+ * Gets the material property used to fill the geometry.
+ * @memberof PolygonGeometryUpdater.prototype
+ * @type {MaterialProperty}
+ */
+ fillMaterialProperty : {
+ get : function() {
+ return this._materialProperty;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry has an outline component.
+ * @memberof PolygonGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ outlineEnabled : {
+ get : function() {
+ return this._outlineEnabled;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry has an outline component.
+ * @memberof PolygonGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ hasConstantOutline : {
+ get : function() {
+ return !this._outlineEnabled ||
+ (!defined(this._dynamicObject.availability) &&
+ Property.isConstant(this._showProperty) &&
+ Property.isConstant(this._showOutlineProperty));
+ }
+ },
+ /**
+ * Gets the {@link Color} property for the geometry outline.
+ * @memberof PolygonGeometryUpdater.prototype
+ * @type {Property}
+ */
+ outlineColorProperty : {
+ get : function() {
+ return this._outlineColorProperty;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry is time-varying.
+ * If true, all visualization is delegated to the {@link DynamicGeometryUpdater}
+ * returned by GeometryUpdater#createDynamicUpdater.
+ *
+ * @memberof PolygonGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ isDynamic : {
+ get : function() {
+ return this._dynamic;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry is closed.
+ * This property is only valid for static geometry.
+ * @memberof PolygonGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ isClosed : {
+ get : function() {
+ return this._isClosed;
+ }
+ },
+ /**
+ * Gets an event that is raised whenever the public properties
+ * of this updater change.
+ * @memberof PolygonGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ geometryChanged : {
+ get : function() {
+ return this._geometryChanged;
+ }
+ }
+ });
+
+ /**
+ * Checks if the geometry is outlined at the provided time.
+ * @memberof PolygonGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time for which to retrieve visibility.
+ * @returns {Boolean} true if geometry is outlined at the provided time, false otherwise.
+ */
+ PolygonGeometryUpdater.prototype.isOutlineVisible = function(time) {
+ var dynamicObject = this._dynamicObject;
+ return this._outlineEnabled && dynamicObject.isAvailable(time) && this._showProperty.getValue(time) && this._showOutlineProperty.getValue(time);
+ };
+
+ /**
+ * Checks if the geometry is filled at the provided time.
+ * @memberof PolygonGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time for which to retrieve visibility.
+ * @returns {Boolean} true if geometry is filled at the provided time, false otherwise.
+ */
+ PolygonGeometryUpdater.prototype.isFilled = function(time) {
+ var dynamicObject = this._dynamicObject;
+ return this._fillEnabled && dynamicObject.isAvailable(time) && this._showProperty.getValue(time) && this._fillProperty.getValue(time);
+ };
+
+ /**
+ * Creates the geometry instance which represents the fill of the geometry.
+ * @memberof PolygonGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time to use when retrieving initial attribute values.
+ * @returns {GeometryInstance} The geometry instance representing the filled portion of the geometry.
+ *
+ * @exception {DeveloperError} This instance does not represent a filled geometry.
+ */
+ PolygonGeometryUpdater.prototype.createFillGeometryInstance = function(time) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+
+ if (!this._fillEnabled) {
+ throw new DeveloperError('This instance does not represent a filled geometry.');
+ }
+ //>>includeEnd('debug');
+
+ var dynamicObject = this._dynamicObject;
+ var isAvailable = dynamicObject.isAvailable(time);
+
+ var attributes;
+
+ var color;
+ var show = new ShowGeometryInstanceAttribute(isAvailable && this._showProperty.getValue(time) && this._fillProperty.getValue(time));
+ if (this._materialProperty instanceof ColorMaterialProperty) {
+ var currentColor = Color.WHITE;
+ if (defined(this._materialProperty.color) && (this._materialProperty.color.isConstant || isAvailable)) {
+ currentColor = this._materialProperty.color.getValue(time);
+ }
+ color = ColorGeometryInstanceAttribute.fromColor(currentColor);
+ attributes = {
+ show : show,
+ color : color
+ };
+ } else {
+ attributes = {
+ show : show
+ };
+ }
+
+ return new GeometryInstance({
+ id : dynamicObject,
+ geometry : new PolygonGeometry(this._options),
+ attributes : attributes
+ });
+ };
+
+ /**
+ * Creates the geometry instance which represents the outline of the geometry.
+ * @memberof PolygonGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time to use when retrieving initial attribute values.
+ * @returns {GeometryInstance} The geometry instance representing the outline portion of the geometry.
+ *
+ * @exception {DeveloperError} This instance does not represent an outlined geometry.
+ */
+ PolygonGeometryUpdater.prototype.createOutlineGeometryInstance = function(time) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+
+ if (!this._outlineEnabled) {
+ throw new DeveloperError('This instance does not represent an outlined geometry.');
+ }
+ //>>includeEnd('debug');
+
+ var dynamicObject = this._dynamicObject;
+ var isAvailable = dynamicObject.isAvailable(time);
+
+ return new GeometryInstance({
+ id : dynamicObject,
+ geometry : new PolygonOutlineGeometry(this._options),
+ attributes : {
+ show : new ShowGeometryInstanceAttribute(isAvailable && this._showProperty.getValue(time) && this._showOutlineProperty.getValue(time)),
+ color : ColorGeometryInstanceAttribute.fromColor(isAvailable ? this._outlineColorProperty.getValue(time) : Color.BLACK)
+ }
+ });
+ };
+
+ /**
+ * Returns true if this object was destroyed; otherwise, false.
+ * @memberof PolygonGeometryUpdater
+ * @function
+ *
+ * @returns {Boolean} True if this object was destroyed; otherwise, false.
+ */
+ PolygonGeometryUpdater.prototype.isDestroyed = function() {
+ return false;
+ };
+
+ /**
+ * Destroys and resources used by the object. Once an object is destroyed, it should not be used.
+ * @memberof PolygonGeometryUpdater
+ * @function
+ *
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
+ */
+ PolygonGeometryUpdater.prototype.destroy = function() {
+ this._dynamicObjectSubscription();
+ destroyObject(this);
+ };
+
+ PolygonGeometryUpdater.prototype._onDynamicObjectPropertyChanged = function(dynamicObject, propertyName, newValue, oldValue) {
+ if (!(propertyName === 'availability' || propertyName === 'vertexPositions' || propertyName === 'polygon')) {
+ return;
+ }
+
+ var polygon = this._dynamicObject.polygon;
+
+ if (!defined(polygon)) {
+ if (this._fillEnabled || this._outlineEnabled) {
+ this._fillEnabled = false;
+ this._outlineEnabled = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ return;
+ }
+
+ var fillProperty = polygon.fill;
+ var fillEnabled = defined(fillProperty) && fillProperty.isConstant ? fillProperty.getValue(Iso8601.MINIMUM_VALUE) : true;
+
+ var outlineProperty = polygon.outline;
+ var outlineEnabled = defined(outlineProperty);
+ if (outlineEnabled && outlineProperty.isConstant) {
+ outlineEnabled = outlineProperty.getValue(Iso8601.MINIMUM_VALUE);
+ }
+
+ if (!fillEnabled && !outlineEnabled) {
+ if (this._fillEnabled || this._outlineEnabled) {
+ this._fillEnabled = false;
+ this._outlineEnabled = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ return;
+ }
+
+ var vertexPositions = this._dynamicObject.vertexPositions;
+
+ var show = polygon.show;
+ if ((defined(show) && show.isConstant && !show.getValue(Iso8601.MINIMUM_VALUE)) || //
+ (!defined(vertexPositions))) {
+ if (this._fillEnabled || this._outlineEnabled) {
+ this._fillEnabled = false;
+ this._outlineEnabled = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ return;
+ }
+
+ var material = defaultValue(polygon.material, defaultMaterial);
+ var isColorMaterial = material instanceof ColorMaterialProperty;
+ this._materialProperty = material;
+ this._fillProperty = defaultValue(fillProperty, defaultFill);
+ this._showProperty = defaultValue(show, defaultShow);
+ this._showOutlineProperty = defaultValue(polygon.outline, defaultOutline);
+ this._outlineColorProperty = outlineEnabled ? defaultValue(polygon.outlineColor, defaultOutlineColor) : undefined;
+
+ var height = polygon.height;
+ var extrudedHeight = polygon.extrudedHeight;
+ var granularity = polygon.granularity;
+ var stRotation = polygon.stRotation;
+ var perPositionHeight = polygon.perPositionHeight;
+
+ this._isClosed = defined(extrudedHeight);
+ this._fillEnabled = fillEnabled;
+ this._outlineEnabled = outlineEnabled;
+
+ if (!vertexPositions.isConstant || //
+ !Property.isConstant(height) || //
+ !Property.isConstant(extrudedHeight) || //
+ !Property.isConstant(granularity) || //
+ !Property.isConstant(stRotation) || //
+ !Property.isConstant(perPositionHeight)) {
+ if (!this._dynamic) {
+ this._dynamic = true;
+ this._geometryChanged.raiseEvent(this);
+ }
+ } else {
+ var options = this._options;
+ options.vertexFormat = isColorMaterial ? PerInstanceColorAppearance.VERTEX_FORMAT : MaterialAppearance.VERTEX_FORMAT;
+ options.polygonHierarchy.positions = vertexPositions.getValue(Iso8601.MINIMUM_VALUE, options.polygonHierarchy.positions);
+ options.height = defined(height) ? height.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ options.extrudedHeight = defined(extrudedHeight) ? extrudedHeight.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ options.granularity = defined(granularity) ? granularity.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ options.stRotation = defined(stRotation) ? stRotation.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ options.perPositionHeight = defined(perPositionHeight) ? perPositionHeight.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ this._dynamic = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ };
+
+ /**
+ * Creates the dynamic updater to be used when GeometryUpdater#isDynamic is true.
+ * @memberof PolygonGeometryUpdater
+ * @function
+ *
+ * @param {CompositePrimitive} primitives The primitive collection to use.
+ * @returns {DynamicGeometryUpdater} The dynamic updater used to update the geometry each frame.
+ *
+ * @exception {DeveloperError} This instance does not represent dynamic geometry.
+ */
+ PolygonGeometryUpdater.prototype.createDynamicUpdater = function(primitives) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!this._dynamic) {
+ throw new DeveloperError('This instance does not represent dynamic geometry.');
+ }
+
+ if (!defined(primitives)) {
+ throw new DeveloperError('primitives is required.');
+ }
+ //>>includeEnd('debug');
+
+ return new DynamicGeometryUpdater(primitives, this);
+ };
+
+ /**
+ * @private
+ */
+ var DynamicGeometryUpdater = function(primitives, geometryUpdater) {
+ this._primitives = primitives;
+ this._primitive = undefined;
+ this._outlinePrimitive = undefined;
+ this._geometryUpdater = geometryUpdater;
+ this._options = new GeometryOptions(geometryUpdater._dynamicObject);
+ };
+
+ DynamicGeometryUpdater.prototype.update = function(time) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+ //>>includeEnd('debug');
+
+ var geometryUpdater = this._geometryUpdater;
+
+ if (defined(this._primitive)) {
+ this._primitives.remove(this._primitive);
+ }
+
+ if (defined(this._outlinePrimitive)) {
+ this._primitives.remove(this._outlinePrimitive);
+ }
+
+ var dynamicObject = geometryUpdater._dynamicObject;
+ var polygon = dynamicObject.polygon;
+ var show = polygon.show;
+
+ if (!dynamicObject.isAvailable(time) || (defined(show) && !show.getValue(time))) {
+ return;
+ }
+
+ var options = this._options;
+
+ var vertexPositions = dynamicObject.vertexPositions;
+ var perPositionHeight = polygon.perPositionHeight;
+ var height = polygon.height;
+ var extrudedHeight = polygon.extrudedHeight;
+ var granularity = polygon.granularity;
+ var stRotation = polygon.stRotation;
+
+ options.polygonHierarchy.positions = vertexPositions.getValue(time, options.polygonHierarchy.positions);
+ options.height = defined(height) ? height.getValue(time, options) : undefined;
+ options.extrudedHeight = defined(extrudedHeight) ? extrudedHeight.getValue(time, options) : undefined;
+ options.granularity = defined(granularity) ? granularity.getValue(time) : undefined;
+ options.stRotation = defined(stRotation) ? stRotation.getValue(time) : undefined;
+
+ if (!defined(polygon.fill) || polygon.fill.getValue(time)) {
+ options.perPositionHeight = defined(perPositionHeight) ? perPositionHeight.getValue(time) : undefined;
+
+ this._material = MaterialProperty.getValue(time, geometryUpdater.fillMaterialProperty, this._material);
+ var material = this._material;
+ var appearance = new MaterialAppearance({
+ material : material,
+ faceForward : true,
+ translucent : material.isTranslucent(),
+ closed : defined(options.extrudedHeight)
+ });
+ options.vertexFormat = appearance.vertexFormat;
+
+ this._primitive = new Primitive({
+ geometryInstances : new GeometryInstance({
+ id : dynamicObject,
+ geometry : new PolygonGeometry(options)
+ }),
+ appearance : appearance,
+ asynchronous : false
+ });
+ this._primitives.add(this._primitive);
+ }
+
+ if (defined(polygon.outline) && polygon.outline.getValue(time)) {
+ options.vertexFormat = PerInstanceColorAppearance.VERTEX_FORMAT;
+
+ var outlineColor = defined(polygon.outlineColor) ? polygon.outlineColor.getValue(time) : Color.BLACK;
+ this._outlinePrimitive = new Primitive({
+ geometryInstances : new GeometryInstance({
+ id : dynamicObject,
+ geometry : new PolygonOutlineGeometry(options),
+ attributes : {
+ color : ColorGeometryInstanceAttribute.fromColor(outlineColor)
+ }
+ }),
+ appearance : new PerInstanceColorAppearance({
+ flat : true,
+ translucent : outlineColor.alpha !== 1.0
+ }),
+ asynchronous : false
+ });
+ this._primitives.add(this._outlinePrimitive);
+ }
+ };
+
+ DynamicGeometryUpdater.prototype.isDestroyed = function() {
+ return false;
+ };
+
+ DynamicGeometryUpdater.prototype.destroy = function() {
+ if (defined(this._primitive)) {
+ this._primitives.remove(this._primitive);
+ }
+
+ if (defined(this._outlinePrimitive)) {
+ this._primitives.remove(this._outlinePrimitive);
+ }
+ destroyObject(this);
+ };
+
+ return PolygonGeometryUpdater;
+});
\ No newline at end of file
diff --git a/Source/DynamicScene/PolylineGeometryUpdater.js b/Source/DynamicScene/PolylineGeometryUpdater.js
new file mode 100644
index 000000000000..ab6b0c3c88ad
--- /dev/null
+++ b/Source/DynamicScene/PolylineGeometryUpdater.js
@@ -0,0 +1,471 @@
+/*global define*/
+define(['../Core/Color',
+ '../Core/ColorGeometryInstanceAttribute',
+ '../Core/defaultValue',
+ '../Core/defined',
+ '../Core/defineProperties',
+ '../Core/destroyObject',
+ '../Core/DeveloperError',
+ '../Core/PolylineGeometry',
+ '../Core/Event',
+ '../Core/GeometryInstance',
+ '../Core/Iso8601',
+ '../Core/ShowGeometryInstanceAttribute',
+ '../DynamicScene/ColorMaterialProperty',
+ '../DynamicScene/ConstantProperty',
+ '../DynamicScene/MaterialProperty',
+ '../DynamicScene/Property',
+ '../Scene/PolylineMaterialAppearance',
+ '../Scene/PolylineColorAppearance',
+ '../Scene/Primitive'
+ ], function(
+ Color,
+ ColorGeometryInstanceAttribute,
+ defaultValue,
+ defined,
+ defineProperties,
+ destroyObject,
+ DeveloperError,
+ PolylineGeometry,
+ Event,
+ GeometryInstance,
+ Iso8601,
+ ShowGeometryInstanceAttribute,
+ ColorMaterialProperty,
+ ConstantProperty,
+ MaterialProperty,
+ Property,
+ PolylineMaterialAppearance,
+ PolylineColorAppearance,
+ Primitive) {
+ "use strict";
+
+ var defaultMaterial = ColorMaterialProperty.fromColor(Color.WHITE);
+ var defaultShow = new ConstantProperty(true);
+
+ var GeometryOptions = function(dynamicObject) {
+ this.id = dynamicObject;
+ this.vertexFormat = undefined;
+ this.positions = undefined;
+ this.width = undefined;
+ };
+
+ /**
+ * A {@link GeometryUpdater} for polylines.
+ * Clients do not normally create this class directly, but instead rely on {@link DataSourceDisplay}.
+ * @alias PolygonGeometryUpdater
+ * @constructor
+ *
+ * @param {DynamicObject} dynamicObject The object containing the geometry to be visualized.
+ */
+ var PolylineGeometryUpdater = function(dynamicObject) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(dynamicObject)) {
+ throw new DeveloperError('dynamicObject is required');
+ }
+ //>>includeEnd('debug');
+
+ this._dynamicObject = dynamicObject;
+ this._dynamicObjectSubscription = dynamicObject.definitionChanged.addEventListener(PolylineGeometryUpdater.prototype._onDynamicObjectPropertyChanged, this);
+ this._fillEnabled = false;
+ this._dynamic = false;
+ this._geometryChanged = new Event();
+ this._showProperty = undefined;
+ this._materialProperty = undefined;
+ this._options = new GeometryOptions(dynamicObject);
+ this._onDynamicObjectPropertyChanged(dynamicObject, 'polyline', dynamicObject.polyline, undefined);
+ };
+
+ defineProperties(PolylineGeometryUpdater, {
+ /**
+ * Gets the type of Appearance to use for simple color-based geometry.
+ * @memberof PolylineGeometryUpdater
+ * @type {Appearance}
+ */
+ perInstanceColorAppearanceType : {
+ value : PolylineColorAppearance
+ },
+ /**
+ * Gets the type of Appearance to use for material-based geometry.
+ * @memberof PolylineGeometryUpdater
+ * @type {Appearance}
+ */
+ materialAppearanceType : {
+ value : PolylineMaterialAppearance
+ }
+ });
+
+ defineProperties(PolylineGeometryUpdater.prototype, {
+ /**
+ * Gets the object associated with this geometry.
+ * @memberof PolylineGeometryUpdater.prototype
+ * @type {DynamicObject}
+ */
+ dynamicObject :{
+ get : function() {
+ return this._dynamicObject;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry has a fill component.
+ * @memberof PolylineGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ fillEnabled : {
+ get : function() {
+ return this._fillEnabled;
+ }
+ },
+ /**
+ * Gets a value indicating if fill visibility varies with simulation time.
+ * @memberof PolylineGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ hasConstantFill : {
+ get : function() {
+ return !this._fillEnabled || (!defined(this._dynamicObject.availability) && Property.isConstant(this._showProperty));
+ }
+ },
+ /**
+ * Gets the material property used to fill the geometry.
+ * @memberof PolylineGeometryUpdater.prototype
+ * @type {MaterialProperty}
+ */
+ fillMaterialProperty : {
+ get : function() {
+ return this._materialProperty;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry has an outline component.
+ * @memberof PolylineGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ outlineEnabled : {
+ value : false
+ },
+ /**
+ * Gets a value indicating if outline visibility varies with simulation time.
+ * @memberof PolylineGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ hasConstantOutline : {
+ value : true
+ },
+ /**
+ * Gets the {@link Color} property for the geometry outline.
+ * @memberof PolylineGeometryUpdater.prototype
+ * @type {Property}
+ */
+ outlineColorProperty : {
+ value : undefined
+ },
+ /**
+ * Gets a value indicating if the geometry is time-varying.
+ * If true, all visualization is delegated to the {@link DynamicGeometryUpdater}
+ * returned by GeometryUpdater#createDynamicUpdater.
+ *
+ * @memberof PolylineGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ isDynamic : {
+ get : function() {
+ return this._dynamic;
+ }
+ },
+ /**
+ * Gets a value indicating if the geometry is closed.
+ * This property is only valid for static geometry.
+ * @memberof PolylineGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ isClosed : {
+ value : false
+ },
+ /**
+ * Gets an event that is raised whenever the public properties
+ * of this updater change.
+ * @memberof PolylineGeometryUpdater.prototype
+ * @type {Boolean}
+ */
+ geometryChanged : {
+ get : function() {
+ return this._geometryChanged;
+ }
+ }
+ });
+
+ /**
+ * Checks if the geometry is outlined at the provided time.
+ * @memberof PolylineGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time for which to retrieve visibility.
+ * @returns {Boolean} true if geometry is outlined at the provided time, false otherwise.
+ */
+ PolylineGeometryUpdater.prototype.isOutlineVisible = function(time) {
+ return false;
+ };
+
+ /**
+ * Checks if the geometry is filled at the provided time.
+ * @memberof PolylineGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time for which to retrieve visibility.
+ * @returns {Boolean} true if geometry is filled at the provided time, false otherwise.
+ */
+ PolylineGeometryUpdater.prototype.isFilled = function(time) {
+ var dynamicObject = this._dynamicObject;
+ return this._fillEnabled && dynamicObject.isAvailable(time) && this._showProperty.getValue(time);
+ };
+
+ /**
+ * Creates the geometry instance which represents the fill of the geometry.
+ * @memberof PolylineGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time to use when retrieving initial attribute values.
+ * @returns {GeometryInstance} The geometry instance representing the filled portion of the geometry.
+ *
+ * @exception {DeveloperError} This instance does not represent a filled geometry.
+ */
+ PolylineGeometryUpdater.prototype.createFillGeometryInstance = function(time) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+
+ if (!this._fillEnabled) {
+ throw new DeveloperError('This instance does not represent a filled geometry.');
+ }
+ //>>includeEnd('debug');
+
+ var color;
+ var attributes;
+ var dynamicObject = this._dynamicObject;
+ var isAvailable = dynamicObject.isAvailable(time);
+ var show = new ShowGeometryInstanceAttribute(isAvailable && this._showProperty.getValue(time));
+
+ if (this._materialProperty instanceof ColorMaterialProperty) {
+ var currentColor = Color.WHITE;
+ if (defined(this._materialProperty.color) && (this._materialProperty.color.isConstant || isAvailable)) {
+ currentColor = this._materialProperty.color.getValue(time);
+ }
+ color = ColorGeometryInstanceAttribute.fromColor(currentColor);
+ attributes = {
+ show : show,
+ color : color
+ };
+ } else {
+ attributes = {
+ show : show
+ };
+ }
+
+ return new GeometryInstance({
+ id : dynamicObject,
+ geometry : new PolylineGeometry(this._options),
+ attributes : attributes
+ });
+ };
+
+ /**
+ * Creates the geometry instance which represents the outline of the geometry.
+ * @memberof PolylineGeometryUpdater
+ * @function
+ *
+ * @param {JulianDate} time The time to use when retrieving initial attribute values.
+ * @returns {GeometryInstance} The geometry instance representing the outline portion of the geometry.
+ *
+ * @exception {DeveloperError} This instance does not represent an outlined geometry.
+ */
+ PolylineGeometryUpdater.prototype.createOutlineGeometryInstance = function(time) {
+ //>>includeStart('debug', pragmas.debug);
+ throw new DeveloperError('This instance does not represent an outlined geometry.');
+ //>>includeEnd('debug');
+ };
+
+ /**
+ * Returns true if this object was destroyed; otherwise, false.
+ * @memberof PolylineGeometryUpdater
+ * @function
+ *
+ * @returns {Boolean} True if this object was destroyed; otherwise, false.
+ */
+ PolylineGeometryUpdater.prototype.isDestroyed = function() {
+ return false;
+ };
+
+ /**
+ * Destroys and resources used by the object. Once an object is destroyed, it should not be used.
+ * @memberof PolylineGeometryUpdater
+ * @function
+ *
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
+ */
+ PolylineGeometryUpdater.prototype.destroy = function() {
+ this._dynamicObjectSubscription();
+ destroyObject(this);
+ };
+
+ PolylineGeometryUpdater.prototype._onDynamicObjectPropertyChanged = function(dynamicObject, propertyName, newValue, oldValue) {
+ if (!(propertyName === 'availability' || propertyName === 'vertexPositions' || propertyName === 'polyline')) {
+ return;
+ }
+
+ var polyline = this._dynamicObject.polyline;
+
+ if (!defined(polyline)) {
+ if (this._fillEnabled) {
+ this._fillEnabled = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ return;
+ }
+
+ var vertexPositions = this._dynamicObject.vertexPositions;
+
+ var show = polyline.show;
+ if ((defined(show) && show.isConstant && !show.getValue(Iso8601.MINIMUM_VALUE)) || //
+ (!defined(vertexPositions))) {
+ if (this._fillEnabled) {
+ this._fillEnabled = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ return;
+ }
+
+ var material = defaultValue(polyline.material, defaultMaterial);
+ var isColorMaterial = material instanceof ColorMaterialProperty;
+ this._materialProperty = material;
+ this._showProperty = defaultValue(show, defaultShow);
+ this._fillEnabled = true;
+
+ var width = polyline.width;
+
+ if (!vertexPositions.isConstant || !Property.isConstant(width)) {
+ if (!this._dynamic) {
+ this._dynamic = true;
+ this._geometryChanged.raiseEvent(this);
+ }
+ } else {
+ var options = this._options;
+ var positions = vertexPositions.getValue(Iso8601.MINIMUM_VALUE, options.positions);
+
+ //Because of the way we currently handle reference properties,
+ //we can't automatically assume the positions are always valid.
+ if (!defined(positions) || positions.length < 2) {
+ if (this._fillEnabled) {
+ this._fillEnabled = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ return;
+ }
+
+ options.vertexFormat = isColorMaterial ? PolylineColorAppearance.VERTEX_FORMAT : PolylineMaterialAppearance.VERTEX_FORMAT;
+ options.positions = positions;
+ options.width = defined(width) ? width.getValue(Iso8601.MINIMUM_VALUE) : undefined;
+ this._dynamic = false;
+ this._geometryChanged.raiseEvent(this);
+ }
+ };
+
+ /**
+ * Creates the dynamic updater to be used when GeometryUpdater#isDynamic is true.
+ * @memberof PolylineGeometryUpdater
+ * @function
+ *
+ * @param {CompositePrimitive} primitives The primitive collection to use.
+ * @returns {DynamicGeometryUpdater} The dynamic updater used to update the geometry each frame.
+ *
+ * @exception {DeveloperError} This instance does not represent dynamic geometry.
+ */
+ PolylineGeometryUpdater.prototype.createDynamicUpdater = function(primitives) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!this._dynamic) {
+ throw new DeveloperError('This instance does not represent dynamic geometry.');
+ }
+
+ if (!defined(primitives)) {
+ throw new DeveloperError('primitives is required.');
+ }
+ //>>includeEnd('debug');
+
+ return new DynamicGeometryUpdater(primitives, this);
+ };
+
+ /**
+ * @private
+ */
+ var DynamicGeometryUpdater = function(primitives, geometryUpdater) {
+ this._primitives = primitives;
+ this._primitive = undefined;
+ this._geometryUpdater = geometryUpdater;
+ this._options = new GeometryOptions(geometryUpdater._dynamicObject);
+ };
+
+ DynamicGeometryUpdater.prototype.update = function(time) {
+ var geometryUpdater = this._geometryUpdater;
+
+ if (defined(this._primitive)) {
+ this._primitives.remove(this._primitive);
+ }
+
+ var dynamicObject = geometryUpdater._dynamicObject;
+ var polyline = dynamicObject.polyline;
+ var show = polyline.show;
+
+ if (!dynamicObject.isAvailable(time) || (defined(show) && !show.getValue(time))) {
+ return;
+ }
+
+ var options = this._options;
+ var vertexPositions = dynamicObject.vertexPositions;
+
+ var positions = vertexPositions.getValue(time, options.positions);
+ //Because of the way we currently handle reference properties,
+ //we can't automatically assume the positions are always valid.
+ if (!defined(positions) || positions.length < 2) {
+ return;
+ }
+
+ options.positions = positions;
+
+ var width = polyline.width;
+ options.width = defined(width) ? width.getValue(time) : undefined;
+
+ this._material = MaterialProperty.getValue(time, geometryUpdater.fillMaterialProperty, this._material);
+ var material = this._material;
+ var appearance = new PolylineMaterialAppearance({
+ material : material,
+ faceForward : true,
+ translucent : material.isTranslucent(),
+ closed : false
+ });
+ options.vertexFormat = appearance.vertexFormat;
+
+ this._primitive = new Primitive({
+ geometryInstances : new GeometryInstance({
+ id : dynamicObject,
+ geometry : new PolylineGeometry(options)
+ }),
+ appearance : appearance,
+ asynchronous : false
+ });
+ this._primitives.add(this._primitive);
+ };
+
+ DynamicGeometryUpdater.prototype.isDestroyed = function() {
+ return false;
+ };
+
+ DynamicGeometryUpdater.prototype.destroy = function() {
+ if (defined(this._primitive)) {
+ this._primitives.remove(this._primitive);
+ }
+ destroyObject(this);
+ };
+
+ return PolylineGeometryUpdater;
+});
\ No newline at end of file
diff --git a/Source/DynamicScene/PolylineOutlineMaterialProperty.js b/Source/DynamicScene/PolylineOutlineMaterialProperty.js
index 0b586e32dce2..b495aa4fe7bb 100644
--- a/Source/DynamicScene/PolylineOutlineMaterialProperty.js
+++ b/Source/DynamicScene/PolylineOutlineMaterialProperty.js
@@ -1,12 +1,17 @@
/*global define*/
-define([
- '../Core/Color',
+define(['../Core/Color',
'../Core/defined',
+ '../Core/defineProperties',
+ '../Core/Event',
+ './createDynamicPropertyDescriptor',
'./ConstantProperty',
'./Property'
], function(
Color,
defined,
+ defineProperties,
+ Event,
+ createDynamicPropertyDescriptor,
ConstantProperty,
Property) {
"use strict";
@@ -17,25 +22,63 @@ define([
* @constructor
*/
var PolylineOutlineMaterialProperty = function() {
+ this._definitionChanged = new Event();
+ this._color = undefined;
+ this._colorSubscription = undefined;
+ this._outlineColor = undefined;
+ this._outlineColorSubscription = undefined;
+ this._outlineWidth = undefined;
+ this._outlineWidthSubscription = undefined;
+ this.color = new ConstantProperty(Color.WHITE);
+ this.outlineColor = new ConstantProperty(Color.BLACK);
+ this.outlineWidth = new ConstantProperty(0.0);
+ };
+
+ defineProperties(PolylineOutlineMaterialProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof PolylineOutlineMaterialProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return Property.isConstant(this._color) && Property.isConstant(this._outlineColor) && Property.isConstant(this._outlineWidth);
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is considered to have changed if a call to getValue would return
+ * a different result for the same time.
+ * @memberof PolylineOutlineMaterialProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
/**
- * A {@link Color} {@link Property} which determines the polyline's color.
+ * Gets or sets {@link Color} property which determines the polyline's color.
+ * @memberof PolylineOutlineMaterialProperty.prototype
* @type {Property}
* @default new ConstantProperty(Color.WHITE)
*/
- this.color = new ConstantProperty(Color.WHITE);
+ color : createDynamicPropertyDescriptor('color'),
/**
- * A {@link Color} {@link Property} which determines the polyline's outline color.
+ * Gets or sets the {@link Color} property which determines the polyline's outline color.
+ * @memberof PolylineOutlineMaterialProperty.prototype
* @type {Property}
* @default new ConstantProperty(Color.BLACK)
*/
- this.outlineColor = new ConstantProperty(Color.BLACK);
+ outlineColor : createDynamicPropertyDescriptor('outlineColor'),
/**
- * A Number {@link Property} which determines the polyline's outline width.
+ * Gets or sets the numberic property which determines the polyline's outline width.
* @type {Property}
* @default new ConstantProperty(0)
*/
- this.outlineWidth = new ConstantProperty(0);
- };
+ outlineWidth : createDynamicPropertyDescriptor('outlineWidth')
+ });
/**
* Gets the {@link Material} type at the provided time.
@@ -60,9 +103,9 @@ define([
if (!defined(result)) {
result = {};
}
- result.color = defined(this.color) ? this.color.getValue(time, result.color) : undefined;
- result.outlineColor = defined(this.outlineColor) ? this.outlineColor.getValue(time, result.outlineColor) : undefined;
- result.outlineWidth = defined(this.outlineWidth) ? this.outlineWidth.getValue(time) : undefined;
+ result.color = defined(this._color) ? this._color.getValue(time, result.color) : undefined;
+ result.outlineColor = defined(this._outlineColor) ? this._outlineColor.getValue(time, result.outlineColor) : undefined;
+ result.outlineWidth = defined(this._outlineWidth) ? this._outlineWidth.getValue(time) : undefined;
return result;
};
@@ -77,9 +120,16 @@ define([
PolylineOutlineMaterialProperty.prototype.equals = function(other) {
return this === other || //
(other instanceof PolylineOutlineMaterialProperty && //
- Property.equals(this.color, other.color) && //
- Property.equals(this.outlineColor, other.outlineColor) && //
- Property.equals(this.outlineWidth, other.outlineWidth));
+ Property.equals(this._color, other._color) && //
+ Property.equals(this._outlineColor, other._outlineColor) && //
+ Property.equals(this._outlineWidth, other._outlineWidth));
+ };
+
+ /**
+ * @private
+ */
+ PolylineOutlineMaterialProperty.prototype._raiseDefinitionChanged = function(){
+ this._definitionChanged.raiseEvent(this);
};
return PolylineOutlineMaterialProperty;
diff --git a/Source/DynamicScene/PositionProperty.js b/Source/DynamicScene/PositionProperty.js
index c17f9d3504b7..e9996d852e57 100644
--- a/Source/DynamicScene/PositionProperty.js
+++ b/Source/DynamicScene/PositionProperty.js
@@ -1,6 +1,5 @@
/*global define*/
-define([
- '../Core/Cartesian3',
+define(['../Core/Cartesian3',
'../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
@@ -17,14 +16,9 @@ define([
Transforms) {
"use strict";
- function throwInstantiationError() {
- throw new DeveloperError('This type should not be instantiated directly.');
- }
-
/**
- * The interface for all position {@link Property} objects. Position properties
- * represent a world location as a {@link Cartesian3} with an associated
- * {@link ReferenceFrame}.
+ * The interface for all {@link Property} objects that define a world
+ * location as a {@link Cartesian3} with an associated {@link ReferenceFrame}.
* This type defines an interface and cannot be instantiated directly.
*
* @alias PositionProperty
@@ -35,21 +29,42 @@ define([
* @see SampledPositionProperty
* @see TimeIntervalCollectionPositionProperty
*/
- var PositionProperty = throwInstantiationError;
+ var PositionProperty = function() {
+ DeveloperError.throwInstantiationError();
+ };
defineProperties(PositionProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof PositionProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is considered to have changed if a call to getValue would return
+ * a different result for the same time.
+ * @memberof PositionProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : DeveloperError.throwInstantiationError
+ },
/**
* Gets the reference frame that the position is defined in.
* @memberof PositionProperty.prototype
* @Type {ReferenceFrame}
*/
referenceFrame : {
- get : throwInstantiationError
+ get : DeveloperError.throwInstantiationError
}
});
/**
- * Gets the value of the property at the provided time.
+ * Gets the value of the property at the provided time in the fixed frame.
* @memberof PositionProperty
* @function
*
@@ -57,7 +72,7 @@ define([
* @param {Cartesian3} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {Cartesian3} The modified result parameter or a new instance if the result parameter was not supplied.
*/
- PositionProperty.prototype.getValue = throwInstantiationError;
+ PositionProperty.prototype.getValue = DeveloperError.throwInstantiationError;
/**
* Gets the value of the property at the provided time and in the provided reference frame.
@@ -69,7 +84,7 @@ define([
* @param {Cartesian3} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {Cartesian3} The modified result parameter or a new instance if the result parameter was not supplied.
*/
- PositionProperty.prototype.getValueInReferenceFrame = throwInstantiationError;
+ PositionProperty.prototype.getValueInReferenceFrame = DeveloperError.throwInstantiationError;
/**
* Compares this property to the provided property and returns
@@ -79,7 +94,7 @@ define([
* @param {Property} [other] The other property.
* @returns {Boolean} true
if left and right are equal, false
otherwise.
*/
- PositionProperty.prototype.equals = throwInstantiationError;
+ PositionProperty.prototype.equals = DeveloperError.throwInstantiationError;
var scratchMatrix3 = new Matrix3();
@@ -87,6 +102,10 @@ define([
* @private
*/
PositionProperty.convertToReferenceFrame = function(time, value, inputFrame, outputFrame, result) {
+ if (!defined(value)) {
+ return value;
+ }
+
if (inputFrame === outputFrame) {
return Cartesian3.clone(value, result);
}
diff --git a/Source/DynamicScene/PositionPropertyArray.js b/Source/DynamicScene/PositionPropertyArray.js
new file mode 100644
index 000000000000..897386139ee6
--- /dev/null
+++ b/Source/DynamicScene/PositionPropertyArray.js
@@ -0,0 +1,189 @@
+/*global define*/
+define(['../Core/defaultValue',
+ '../Core/defined',
+ '../Core/defineProperties',
+ '../Core/DeveloperError',
+ '../Core/Enumeration',
+ '../Core/Event',
+ '../Core/EventHelper',
+ '../Core/ReferenceFrame',
+ './Property'
+ ], function(
+ defaultValue,
+ defined,
+ defineProperties,
+ DeveloperError,
+ Enumeration,
+ Event,
+ EventHelper,
+ ReferenceFrame,
+ Property) {
+ "use strict";
+
+ /**
+ * A {@link PositionProperty} whose value is an array whose items are the computed value
+ * of other PositionProperty instances.
+ *
+ * @alias PositionProperty
+ * @constructor
+ *
+ * @param {Array} [value] An array of Property instances.
+ */
+ var PositionPropertyArray = function(value, referenceFrame) {
+ this._value = undefined;
+ this._definitionChanged = new Event();
+ this._eventHelper = new EventHelper();
+ this._referenceFrame = defaultValue(referenceFrame, ReferenceFrame.FIXED);
+ this.setValue(value);
+ };
+
+ defineProperties(PositionPropertyArray.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. This property
+ * is considered constant if all property items in the array are constant.
+ * @memberof PositionPropertyArray.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ var value = this._value;
+ if (!defined(value)) {
+ return true;
+ }
+
+ var length = value.length;
+ for (var i = 0; i < length; i++) {
+ if (!Property.isConstant(value[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is changed whenever setValue is called with data different
+ * than the current value or one of the properties in the array also changes.
+ * @memberof PositionPropertyArray.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
+ /**
+ * Gets the reference frame in which the position is defined.
+ * @memberof PositionPropertyArray.prototype
+ * @Type {ReferenceFrame}
+ * @default ReferenceFrame.FIXED;
+ */
+ referenceFrame : {
+ get : function() {
+ return this._referenceFrame;
+ }
+ }
+ });
+
+ /**
+ * Gets the value of the property.
+ * @memberof PositionPropertyArray
+ *
+ * @param {JulianDate} [time] The time for which to retrieve the value. This parameter is unused since the value does not change with respect to time.
+ * @param {Array} [result] The object to store the value into, if omitted, a new instance is created and returned.
+ * @returns {Array} The modified result parameter or a new instance if the result parameter was not supplied.
+ */
+ PositionPropertyArray.prototype.getValue = function(time, result) {
+ return this.getValueInReferenceFrame(time, ReferenceFrame.FIXED, result);
+ };
+
+ /**
+ * Gets the value of the property at the provided time and in the provided reference frame.
+ * @memberof PositionPropertyArray
+ *
+ * @param {JulianDate} time The time for which to retrieve the value.
+ * @param {ReferenceFrame} referenceFrame The desired referenceFrame of the result.
+ * @param {Cartesian3} [result] The object to store the value into, if omitted, a new instance is created and returned.
+ * @returns {Cartesian3} The modified result parameter or a new instance if the result parameter was not supplied.
+ */
+ PositionPropertyArray.prototype.getValueInReferenceFrame = function(time, referenceFrame, result) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+ if (!defined(referenceFrame)) {
+ throw new DeveloperError('referenceFrame is required.');
+ }
+ //>>includeEnd('debug');
+
+ var value = this._value;
+ if (!defined(value)) {
+ return undefined;
+ }
+
+ var length = value.length;
+ if (!defined(result)) {
+ result = new Array(length);
+ }
+ var i = 0;
+ var x = 0;
+ while (i < length) {
+ var property = value[i];
+ var itemValue = property.getValueInReferenceFrame(time, referenceFrame, result[i]);
+ if (defined(itemValue)) {
+ result[x] = itemValue;
+ x++;
+ }
+ i++;
+ }
+ result.length = x;
+ return result;
+ };
+
+ /**
+ * Sets the value of the property.
+ * If the value is an object, the object must provide clone and equals functions.
+ * @memberof PositionPropertyArray
+ *
+ * @param {Array} value An array of Property instances.
+ */
+ PositionPropertyArray.prototype.setValue = function(value) {
+ var eventHelper = this._eventHelper;
+ eventHelper.removeAll();
+
+ if (defined(value)) {
+ this._value = value.slice();
+ var length = value.length;
+ for (var i = 0; i < length; i++) {
+ var property = value[i];
+ if (defined(property)) {
+ eventHelper.add(property.definitionChanged, PositionPropertyArray.prototype._raiseDefinitionChanged, this);
+ }
+ }
+ } else {
+ this._value = undefined;
+ }
+ this._definitionChanged.raiseEvent(this);
+ };
+
+ /**
+ * Compares this property to the provided property and returns
+ * true
if they are equal, false
otherwise.
+ * @memberof PositionPropertyArray
+ *
+ * @param {Property} [other] The other property.
+ * @returns {Boolean} true
if left and right are equal, false
otherwise.
+ */
+ PositionPropertyArray.prototype.equals = function(other) {
+ return this === other || //
+ (other instanceof PositionPropertyArray && //
+ this._referenceFrame === other._referenceFrame && //
+ Property.arrayEquals(this._value, other._value));
+ };
+
+ PositionPropertyArray.prototype._raiseDefinitionChanged = function() {
+ this._definitionChanged.raiseEvent(this);
+ };
+
+ return PositionPropertyArray;
+});
diff --git a/Source/DynamicScene/Property.js b/Source/DynamicScene/Property.js
index 180978ba2e89..8befdb972010 100644
--- a/Source/DynamicScene/Property.js
+++ b/Source/DynamicScene/Property.js
@@ -1,18 +1,15 @@
/*global define*/
define(['../Core/defined',
+ '../Core/defineProperties',
'../Core/DeveloperError'
], function(
defined,
+ defineProperties,
DeveloperError) {
"use strict";
- function throwInstantiationError() {
- throw new DeveloperError('This type should not be instantiated directly.');
- }
-
/**
- * The interface for all properties, which represent a value that can
- * optionally vary over time.
+ * The interface for all properties, which represent a value that can optionally vary over time.
* This type defines an interface and cannot be instantiated directly.
*
* @alias Property
@@ -24,9 +21,33 @@ define(['../Core/defined',
* @see TimeIntervalCollectionProperty
* @see MaterialProperty
* @see PositionProperty
- * @see RefereenceProperty
+ * @see ReferenceProperty
*/
- var Property = throwInstantiationError;
+ var Property = function() {
+ DeveloperError.throwInstantiationError();
+ };
+
+ defineProperties(Property.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof Property.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : DeveloperError.throwInstantiationError
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is considered to have changed if a call to getValue would return
+ * a different result for the same time.
+ * @memberof Property.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : DeveloperError.throwInstantiationError
+ }
+ });
/**
* Gets the value of the property at the provided time.
@@ -37,7 +58,7 @@ define(['../Core/defined',
* @param {Object} [result] The object to store the value into, if omitted, a new instance is created and returned.
* @returns {Object} The modified result parameter or a new instance if the result parameter was not supplied.
*/
- Property.prototype.getValue = throwInstantiationError;
+ Property.prototype.getValue = DeveloperError.throwInstantiationError;
/**
* Compares this property to the provided property and returns
@@ -47,7 +68,7 @@ define(['../Core/defined',
* @param {Property} [other] The other property.
* @returns {Boolean} true
if left and right are equal, false
otherwise.
*/
- Property.prototype.equals = throwInstantiationError;
+ Property.prototype.equals = DeveloperError.throwInstantiationError;
/**
* @private
@@ -56,5 +77,31 @@ define(['../Core/defined',
return left === right || (defined(left) && left.equals(right));
};
+ /**
+ * @private
+ */
+ Property.arrayEquals = function(left, right) {
+ if (left === right) {
+ return true;
+ }
+ if ((!defined(left) || !defined(right)) || (left.length !== right.length)) {
+ return false;
+ }
+ var length = left.length;
+ for (var i = 0; i < length; i++) {
+ if (!Property.equals(left[i], right[i])) {
+ return false;
+ }
+ }
+ return true;
+ };
+
+ /**
+ * @private
+ */
+ Property.isConstant = function(property) {
+ return !defined(property) || property.isConstant;
+ };
+
return Property;
-});
\ No newline at end of file
+});
diff --git a/Source/DynamicScene/PropertyArray.js b/Source/DynamicScene/PropertyArray.js
new file mode 100644
index 000000000000..04356d557c99
--- /dev/null
+++ b/Source/DynamicScene/PropertyArray.js
@@ -0,0 +1,156 @@
+/*global define*/
+define(['../Core/defaultValue',
+ '../Core/defined',
+ '../Core/defineProperties',
+ '../Core/DeveloperError',
+ '../Core/Enumeration',
+ '../Core/Event',
+ '../Core/EventHelper',
+ './Property'
+ ], function(
+ defaultValue,
+ defined,
+ defineProperties,
+ DeveloperError,
+ Enumeration,
+ Event,
+ EventHelper,
+ Property) {
+ "use strict";
+
+ /**
+ * A {@link Property} whose value is an array whose items are the computed value
+ * of other property instances.
+ *
+ * @alias PropertyArray
+ * @constructor
+ *
+ * @param {Array} [value] An array of Property instances.
+ */
+ var PropertyArray = function(value) {
+ this._value = undefined;
+ this._definitionChanged = new Event();
+ this._eventHelper = new EventHelper();
+ this.setValue(value);
+ };
+
+ defineProperties(PropertyArray.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. This property
+ * is considered constant if all property items in the array are constant.
+ * @memberof PropertyArray.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ var value = this._value;
+ if (!defined(value)) {
+ return true;
+ }
+ var length = value.length;
+ for (var i = 0; i < length; i++) {
+ if (!Property.isConstant(value[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is changed whenever setValue is called with data different
+ * than the current value or one of the properties in the array also changes.
+ * @memberof PropertyArray.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ }
+ });
+
+ /**
+ * Gets the value of the property.
+ * @memberof PropertyArray
+ *
+ * @param {JulianDate} [time] The time for which to retrieve the value. This parameter is unused since the value does not change with respect to time.
+ * @param {Array} [result] The object to store the value into, if omitted, a new instance is created and returned.
+ * @returns {Array} The modified result parameter or a new instance if the result parameter was not supplied.
+ */
+ PropertyArray.prototype.getValue = function(time, result) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+ //>>includeEnd('debug');
+
+ var value = this._value;
+ if (!defined(value)) {
+ return undefined;
+ }
+
+ var length = value.length;
+ if (!defined(result)) {
+ result = new Array(length);
+ }
+ var i = 0;
+ var x = 0;
+ while (i < length) {
+ var property = this._value[i];
+ var itemValue = property.getValue(time, result[i]);
+ if (defined(itemValue)) {
+ result[x] = itemValue;
+ x++;
+ }
+ i++;
+ }
+ result.length = x;
+ return result;
+ };
+
+ /**
+ * Sets the value of the property.
+ * @memberof PropertyArray
+ *
+ * @param {Array} value An array of Property instances.
+ */
+ PropertyArray.prototype.setValue = function(value) {
+ var eventHelper = this._eventHelper;
+ eventHelper.removeAll();
+
+ if (defined(value)) {
+ this._value = value.slice();
+ var length = value.length;
+ for (var i = 0; i < length; i++) {
+ var property = value[i];
+ if (defined(property)) {
+ eventHelper.add(property.definitionChanged, PropertyArray.prototype._raiseDefinitionChanged, this);
+ }
+ }
+ } else {
+ this._value = undefined;
+ }
+ this._definitionChanged.raiseEvent(this);
+ };
+
+ /**
+ * Compares this property to the provided property and returns
+ * true
if they are equal, false
otherwise.
+ * @memberof PropertyArray
+ *
+ * @param {Property} [other] The other property.
+ * @returns {Boolean} true
if left and right are equal, false
otherwise.
+ */
+ PropertyArray.prototype.equals = function(other) {
+ return this === other || //
+ (other instanceof PropertyArray && //
+ Property.arrayEquals(this._value, other._value));
+ };
+
+ PropertyArray.prototype._raiseDefinitionChanged = function() {
+ this._definitionChanged.raiseEvent(this);
+ };
+
+ return PropertyArray;
+});
diff --git a/Source/DynamicScene/ReferenceProperty.js b/Source/DynamicScene/ReferenceProperty.js
index 24086f0eb1f5..719ff883a3fa 100644
--- a/Source/DynamicScene/ReferenceProperty.js
+++ b/Source/DynamicScene/ReferenceProperty.js
@@ -2,11 +2,17 @@
define([
'../Core/defaultValue',
'../Core/defined',
- '../Core/DeveloperError'
+ '../Core/defineProperties',
+ '../Core/DeveloperError',
+ '../Core/Event',
+ '../DynamicScene/Property'
], function(
defaultValue,
defined,
- DeveloperError) {
+ defineProperties,
+ DeveloperError,
+ Event,
+ Property) {
"use strict";
function resolve(referenceProperty) {
@@ -51,8 +57,35 @@ define([
this._targetObjectId = targetObjectId;
this._targetObject = undefined;
this._targetPropertyName = targetPropertyName;
+ this._definitionChanged = new Event();
};
+ defineProperties(ReferenceProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant.
+ * This property always returns true
.
+ * @memberof ConstantProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return Property.isConstant(resolve(this));
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is changed whenever setValue is called with data different
+ * than the current value.
+ * @memberof ConstantProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ }
+ });
+
/**
* Creates a new reference property given the dynamic object collection that will
* be used to resolve it and a string indicating the target object id and property,
@@ -106,6 +139,27 @@ define([
return defined(targetProperty) && this._targetObject.isAvailable(time) ? targetProperty.getValue(time, result) : undefined;
};
+ /**
+ * Gets the value of the property at the provided time and in the provided reference frame.
+ * This method is only valid if the property being referenced is a {@link PositionProperty}.
+ * @memberof ReferenceProperty
+ *
+ * @param {JulianDate} time The time for which to retrieve the value.
+ * @param {ReferenceFrame} referenceFrame The desired referenceFrame of the result.
+ * @param {Cartesian3} [result] The object to store the value into, if omitted, a new instance is created and returned.
+ * @returns {Cartesian3} The modified result parameter or a new instance if the result parameter was not supplied.
+ */
+ ReferenceProperty.prototype.getValueInReferenceFrame = function(time, referenceFrame, result) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(time)) {
+ throw new DeveloperError('time is required.');
+ }
+ //>>includeEnd('debug');
+
+ var targetProperty = resolve(this);
+ return defined(targetProperty) && this._targetObject.isAvailable(time) ? targetProperty.getValueInReferenceFrame(time, referenceFrame, result) : undefined;
+ };
+
/**
* Compares this property to the provided property and returns
* true
if they are equal, false
otherwise.
diff --git a/Source/DynamicScene/SampledPositionProperty.js b/Source/DynamicScene/SampledPositionProperty.js
index c1b859128302..e37e7140e876 100644
--- a/Source/DynamicScene/SampledPositionProperty.js
+++ b/Source/DynamicScene/SampledPositionProperty.js
@@ -1,24 +1,25 @@
/*global define*/
-define([
+define(['./PositionProperty',
+ './Property',
+ './SampledProperty',
'../Core/Cartesian3',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
- '../Core/ReferenceFrame',
- './PositionProperty',
- './Property',
- './SampledProperty'
+ '../Core/Event',
+ '../Core/ReferenceFrame'
], function(
+ PositionProperty,
+ Property,
+ SampledProperty,
Cartesian3,
defaultValue,
defined,
defineProperties,
DeveloperError,
- ReferenceFrame,
- PositionProperty,
- Property,
- SampledProperty) {
+ Event,
+ ReferenceFrame) {
"use strict";
/**
@@ -31,10 +32,38 @@ define([
*/
var SampledPositionProperty = function(referenceFrame) {
this._property = new SampledProperty(Cartesian3);
+ this._definitionChanged = new Event();
this._referenceFrame = defaultValue(referenceFrame, ReferenceFrame.FIXED);
+
+ this._property._definitionChanged.addEventListener(function() {
+ this._definitionChanged.raiseEvent(this);
+ }, this);
};
defineProperties(SampledPositionProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof SampledPositionProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return this._property.isConstant;
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is considered to have changed if a call to getValue would return
+ * a different result for the same time.
+ * @memberof SampledPositionProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
/**
* Gets the reference frame in which the position is defined.
* @memberof SampledPositionProperty.prototype
@@ -47,7 +76,7 @@ define([
}
},
/**
- * Gets or sets the degree of interpolation to perform when retrieving a value.
+ * Gets the degree of interpolation to perform when retrieving a value.
* @memberof SampledPositionProperty.prototype
*
* @type {Object}
@@ -56,13 +85,10 @@ define([
interpolationDegree : {
get : function() {
return this._property.interpolationDegree;
- },
- set : function(value) {
- this._property.interpolationDegree = value;
}
},
/**
- * Gets or sets the interpolation algorithm to use when retrieving a value.
+ * Gets the interpolation algorithm to use when retrieving a value.
* @memberof SampledPositionProperty.prototype
*
* @type {InterpolationAlgorithm}
@@ -71,9 +97,6 @@ define([
interpolationAlgorithm : {
get : function() {
return this._property.interpolationAlgorithm;
- },
- set : function(value) {
- this._property.interpolationAlgorithm = value;
}
}
});
@@ -116,6 +139,18 @@ define([
return result;
};
+ /**
+ * Sets the algorithm and degree to use when interpolating a position.
+ * @memberof SampledPositionProperty
+ *
+ * @param {Object} options The options
+ * @param {InterpolationAlgorithm} [options.interpolationAlgorithm] The new interpolation algorithm. If undefined, the existing property will be unchanged.
+ * @param {Number} [options.interpolationDegree] The new interpolation degree. If undefined, the existing property will be unchanged.
+ */
+ SampledPositionProperty.prototype.setInterpolationOptions = function(options) {
+ this._property.setInterpolationOptions(options);
+ };
+
/**
* Adds a new sample
* @memberof SampledPositionProperty
diff --git a/Source/DynamicScene/SampledProperty.js b/Source/DynamicScene/SampledProperty.js
index a17e26b73ebb..637fc80c79ad 100644
--- a/Source/DynamicScene/SampledProperty.js
+++ b/Source/DynamicScene/SampledProperty.js
@@ -1,10 +1,10 @@
/*global define*/
-define([
- '../Core/binarySearch',
+define(['../Core/binarySearch',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
+ '../Core/Event',
'../Core/JulianDate',
'../Core/LinearApproximation'
], function(
@@ -13,6 +13,7 @@ define([
defined,
defineProperties,
DeveloperError,
+ Event,
JulianDate,
LinearApproximation) {
"use strict";
@@ -123,7 +124,7 @@ define([
* @alias SampledProperty
* @constructor
*
- * @param {Object} type The type of property, which must be Number, String or implement {@link Packable}.
+ * @param {Number|Object} type The type of property, which must be a Number or implement {@link Packable}.
*
* @see SampledPositionProperty
*
@@ -143,8 +144,10 @@ define([
* @example
* //Create a simple numeric SampledProperty that uses third degree Hermite Polynomial Approximation
* var property = new Cesium.SampledProperty(Number);
- * property.interpolationDegree = 3;
- * property.interpolationAlgorithm = Cesium.HermitePolynomialApproximation;
+ * property.setInterpolationOptions({
+ * interpolationDegree : 3,
+ * interpolationAlgorithm : Cesium.HermitePolynomialApproximation
+ * });
*
* //Populate it with data
* property.addSample(Cesium.JulianDate.fromIso8601(`2012-08-01T00:00:00.00Z`), 1.0);
@@ -184,9 +187,33 @@ define([
this._packedInterpolationLength = packedInterpolationLength;
this._updateTableLength = true;
this._interpolationResult = new Array(packedInterpolationLength);
+ this._definitionChanged = new Event();
};
defineProperties(SampledProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof SampledProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return this._values.length === 0;
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is considered to have changed if a call to getValue would return
+ * a different result for the same time.
+ * @memberof SampledProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
/**
* Gets the type of property.
* @memberof SampledProperty.prototype
@@ -198,22 +225,18 @@ define([
}
},
/**
- * Gets or sets the degree of interpolation to perform when retrieving a value.
+ * Gets the degree of interpolation to perform when retrieving a value.
* @memberof SampledProperty.prototype
- * @type {Object}
+ * @type {Number}
* @default 1
*/
interpolationDegree : {
get : function() {
return this._interpolationDegree;
- },
- set : function(value) {
- this._interpolationDegree = value;
- this._updateTableLength = true;
}
},
/**
- * Gets or sets the interpolation algorithm to use when retrieving a value.
+ * Gets the interpolation algorithm to use when retrieving a value.
* @memberof SampledProperty.prototype
* @type {InterpolationAlgorithm}
* @default LinearApproximation
@@ -221,10 +244,6 @@ define([
interpolationAlgorithm : {
get : function() {
return this._interpolationAlgorithm;
- },
- set : function(value) {
- this._interpolationAlgorithm = value;
- this._updateTableLength = true;
}
}
});
@@ -331,6 +350,42 @@ define([
return innerType.unpack(this._values, index * innerType.packedLength, result);
};
+ /**
+ * Sets the algorithm and degree to use when interpolating a value.
+ * @memberof SampledProperty
+ *
+ * @param {Object} options The options
+ * @param {InterpolationAlgorithm} [options.interpolationAlgorithm] The new interpolation algorithm. If undefined, the existing property will be unchanged.
+ * @param {Number} [options.interpolationDegree] The new interpolation degree. If undefined, the existing property will be unchanged.
+ */
+ SampledProperty.prototype.setInterpolationOptions = function(options) {
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(options)) {
+ throw new DeveloperError('options is required.');
+ }
+ //>>includeEnd('debug');
+
+ var valuesChanged = false;
+
+ var interpolationAlgorithm = options.interpolationAlgorithm;
+ var interpolationDegree = options.interpolationDegree;
+
+ if (this._interpolationAlgorithm !== interpolationAlgorithm) {
+ this._interpolationAlgorithm = interpolationAlgorithm;
+ valuesChanged = true;
+ }
+
+ if (this._interpolationDegree !== interpolationDegree) {
+ this._interpolationDegree = interpolationDegree;
+ valuesChanged = true;
+ }
+
+ if (valuesChanged) {
+ this._updateTableLength = true;
+ this._definitionChanged.raiseEvent(this);
+ }
+ };
+
/**
* Adds a new sample
* @memberof SampledProperty
@@ -353,6 +408,7 @@ define([
innerType.pack(value, data, 1);
mergeNewSamples(undefined, this._times, this._values, data, innerType.packedLength);
this._updateTableLength = true;
+ this._definitionChanged.raiseEvent(this);
};
/**
@@ -386,6 +442,7 @@ define([
}
mergeNewSamples(undefined, this._times, this._values, data, innerType.packedLength);
this._updateTableLength = true;
+ this._definitionChanged.raiseEvent(this);
};
/**
@@ -404,6 +461,7 @@ define([
mergeNewSamples(epoch, this._times, this._values, packedSamples, this._innerType.packedLength);
this._updateTableLength = true;
+ this._definitionChanged.raiseEvent(this);
};
/**
diff --git a/Source/DynamicScene/StaticGeometryColorBatch.js b/Source/DynamicScene/StaticGeometryColorBatch.js
new file mode 100644
index 000000000000..d05b942410a9
--- /dev/null
+++ b/Source/DynamicScene/StaticGeometryColorBatch.js
@@ -0,0 +1,183 @@
+/*global define*/
+define(['../Core/Color',
+ '../Core/ColorGeometryInstanceAttribute',
+ '../Core/defined',
+ '../Core/AssociativeArray',
+ '../Core/ShowGeometryInstanceAttribute',
+ '../Scene/Primitive',
+ '../Scene/PrimitiveState'
+ ], function(
+ Color,
+ ColorGeometryInstanceAttribute,
+ defined,
+ AssociativeArray,
+ ShowGeometryInstanceAttribute,
+ Primitive,
+ PrimitiveState) {
+ "use strict";
+
+ var colorScratch = new Color();
+
+ var Batch = function(primitives, translucent, appearanceType, closed) {
+ this.translucent = translucent;
+ this.appearanceType = appearanceType;
+ this.closed = closed;
+ this.primitives = primitives;
+ this.createPrimitive = false;
+ this.primitive = undefined;
+ this.geometry = new AssociativeArray();
+ this.updaters = new AssociativeArray();
+ this.updatersWithAttributes = new AssociativeArray();
+ this.attributes = new AssociativeArray();
+ this.itemsToRemove = [];
+ };
+
+ Batch.prototype.add = function(updater, instance) {
+ var id = updater.dynamicObject.id;
+ this.createPrimitive = true;
+ this.geometry.set(id, instance);
+ this.updaters.set(id, updater);
+ if (!updater.hasConstantFill || !updater.fillMaterialProperty.isConstant) {
+ this.updatersWithAttributes.set(id, updater);
+ }
+ };
+
+ Batch.prototype.remove = function(updater) {
+ var id = updater.dynamicObject.id;
+ this.createPrimitive = this.geometry.remove(id) || this.createPrimitive;
+ this.updaters.remove(id);
+ this.updatersWithAttributes.remove(id);
+ };
+
+ Batch.prototype.update = function(time) {
+ var removedCount = 0;
+ var primitive = this.primitive;
+ var primitives = this.primitives;
+ if (this.createPrimitive) {
+ this.attributes.removeAll();
+ if (defined(primitive)) {
+ primitives.remove(primitive);
+ }
+ var geometry = this.geometry.values;
+ if (geometry.length > 0) {
+ primitive = new Primitive({
+ asynchronous : false,
+ geometryInstances : geometry,
+ appearance : new this.appearanceType({
+ faceForward : true,
+ translucent : this.translucent,
+ closed : this.closed
+ })
+ });
+
+ primitives.add(primitive);
+ }
+ this.primitive = primitive;
+ this.createPrimitive = false;
+ } else if (defined(primitive) && primitive._state === PrimitiveState.COMPLETE){
+ var updatersWithAttributes = this.updatersWithAttributes.values;
+ var length = updatersWithAttributes.length;
+ for (var i = 0; i < length; i++) {
+ var updater = updatersWithAttributes[i];
+ var instance = this.geometry.get(updater.dynamicObject.id);
+
+ var attributes = this.attributes.get(instance.id.id);
+ if (!defined(attributes)) {
+ attributes = primitive.getGeometryInstanceAttributes(instance.id);
+ this.attributes.set(instance.id.id, attributes);
+ }
+
+ if (!updater.fillMaterialProperty.isConstant) {
+ var colorProperty = updater.fillMaterialProperty.color;
+ colorProperty.getValue(time, colorScratch);
+ attributes.color = ColorGeometryInstanceAttribute.toValue(colorScratch, attributes.color);
+ if ((this.translucent && attributes.color[3] === 255) || (!this.translucent && attributes.color[3] !== 255)) {
+ this.itemsToRemove[removedCount++] = updater;
+ }
+ }
+
+ if (!updater.hasConstantFill) {
+ attributes.show = ShowGeometryInstanceAttribute.toValue(updater.isFilled(time), attributes.show);
+ }
+ }
+ }
+ this.itemsToRemove.length = removedCount;
+ };
+
+ Batch.prototype.removeAllPrimitives = function() {
+ var primitive = this.primitive;
+ if (defined(primitive)) {
+ this.primitives.remove(primitive);
+ this.primitive = undefined;
+ this.geometry.removeAll();
+ this.updaters.removeAll();
+ }
+ };
+
+ /**
+ * @private
+ */
+ var StaticGeometryColorBatch = function(primitives, appearanceType, closed) {
+ this._solidBatch = new Batch(primitives, false, appearanceType, closed);
+ this._translucentBatch = new Batch(primitives, true, appearanceType, closed);
+ };
+
+ StaticGeometryColorBatch.prototype.add = function(time, updater) {
+ var instance = updater.createFillGeometryInstance(time);
+ if (instance.attributes.color.value[3] === 255) {
+ this._solidBatch.add(updater, instance);
+ } else {
+ this._translucentBatch.add(updater, instance);
+ }
+ };
+
+ StaticGeometryColorBatch.prototype.remove = function(updater) {
+ if (!this._solidBatch.remove(updater)) {
+ this._translucentBatch.remove(updater);
+ }
+ };
+
+ StaticGeometryColorBatch.prototype.update = function(time) {
+ var i;
+ var updater;
+
+ //Perform initial update
+ this._solidBatch.update(time);
+ this._translucentBatch.update(time);
+
+ //If any items swapped between solid/translucent, we need to
+ //move them between batches
+ var itemsToRemove = this._solidBatch.itemsToRemove;
+ var solidsToMoveLength = itemsToRemove.length;
+ if (solidsToMoveLength > 0) {
+ for (i = 0; i < solidsToMoveLength; i++) {
+ updater = itemsToRemove[i];
+ this._solidBatch.remove(updater);
+ this._translucentBatch.add(updater, updater.createFillGeometryInstance(time));
+ }
+ }
+
+ itemsToRemove = this._translucentBatch.itemsToRemove;
+ var translucentToMoveLength = itemsToRemove.length;
+ if (translucentToMoveLength > 0) {
+ for (i = 0; i < translucentToMoveLength; i++) {
+ updater = itemsToRemove[i];
+ this._translucentBatch.remove(updater);
+ this._solidBatch.add(updater, updater.createFillGeometryInstance(time));
+ }
+ }
+
+ //If we moved anything around, we need to re-build the primitive
+ if (solidsToMoveLength > 0 || translucentToMoveLength > 0) {
+ this._solidBatch.update(time);
+ this._translucentBatch.update(time);
+ }
+ };
+
+ StaticGeometryColorBatch.prototype.removeAllPrimitives = function() {
+ this._solidBatch.removeAllPrimitives();
+ this._translucentBatch.removeAllPrimitives();
+ };
+
+ return StaticGeometryColorBatch;
+});
diff --git a/Source/DynamicScene/StaticGeometryPerMaterialBatch.js b/Source/DynamicScene/StaticGeometryPerMaterialBatch.js
new file mode 100644
index 000000000000..d3503d939ea2
--- /dev/null
+++ b/Source/DynamicScene/StaticGeometryPerMaterialBatch.js
@@ -0,0 +1,197 @@
+/*global define*/
+define(['../Core/defined',
+ '../Core/AssociativeArray',
+ '../Core/ShowGeometryInstanceAttribute',
+ '../Scene/Primitive',
+ '../Scene/Material',
+ '../Scene/PrimitiveState',
+ './MaterialProperty'
+ ], function(
+ defined,
+ AssociativeArray,
+ ShowGeometryInstanceAttribute,
+ Primitive,
+ Material,
+ PrimitiveState,
+ MaterialProperty) {
+ "use strict";
+
+ var Batch = function(primitives, appearanceType, materialProperty, closed) {
+ this.primitives = primitives;
+ this.appearanceType = appearanceType;
+ this.materialProperty = materialProperty;
+ this.closed = closed;
+ this.updaters = new AssociativeArray();
+ this.createPrimitive = true;
+ this.primitive = undefined;
+ this.geometry = new AssociativeArray();
+ this.material = Material.fromType('Color');
+ this.updatersWithAttributes = new AssociativeArray();
+ this.attributes = new AssociativeArray();
+ this.invalidated = false;
+ this.removeMaterialSubscription = materialProperty.definitionChanged.addEventListener(Batch.prototype.onMaterialChanged, this);
+ };
+
+ Batch.prototype.onMaterialChanged = function() {
+ this.invalidated = true;
+ };
+
+ Batch.prototype.isMaterial = function(updater) {
+ var material = this.materialProperty;
+ var updaterMaterial = updater.fillMaterialProperty;
+ if (updaterMaterial === material) {
+ return true;
+ }
+ if (defined(material)) {
+ return material.equals(updaterMaterial);
+ }
+ return false;
+ };
+
+ Batch.prototype.add = function(time, updater) {
+ var id = updater.dynamicObject.id;
+ this.updaters.set(id, updater);
+ this.geometry.set(id, updater.createFillGeometryInstance(time));
+ if (!updater.hasConstantFill || !updater.fillMaterialProperty.isConstant) {
+ this.updatersWithAttributes.set(id, updater);
+ }
+ this.createPrimitive = true;
+ };
+
+ Batch.prototype.remove = function(updater) {
+ var id = updater.dynamicObject.id;
+ this.createPrimitive = this.updaters.remove(id);
+ this.geometry.remove(id);
+ this.updatersWithAttributes.remove(id);
+ return this.createPrimitive;
+ };
+
+ Batch.prototype.update = function(time) {
+ var primitive = this.primitive;
+ var primitives = this.primitives;
+ var geometries = this.geometry.values;
+ if (this.createPrimitive) {
+ if (defined(primitive)) {
+ primitives.remove(primitive);
+ }
+ if (geometries.length > 0) {
+ primitive = new Primitive({
+ asynchronous : false,
+ geometryInstances : geometries,
+ appearance : new this.appearanceType({
+ material : MaterialProperty.getValue(time, this.materialProperty, this.material),
+ faceForward : true,
+ translucent : this.material.isTranslucent(),
+ closed : this.closed
+ })
+ });
+
+ primitives.add(primitive);
+ }
+ this.primitive = primitive;
+ this.createPrimitive = false;
+ } else if (defined(primitive) && primitive._state === PrimitiveState.COMPLETE){
+ this.primitive.appearance.material = MaterialProperty.getValue(time, this.materialProperty, this.material);
+
+ var updatersWithAttributes = this.updatersWithAttributes.values;
+ var length = updatersWithAttributes.length;
+ for (var i = 0; i < length; i++) {
+ var updater = updatersWithAttributes[i];
+ var instance = this.geometry.get(updater.dynamicObject.id);
+
+ var attributes = this.attributes.get(instance.id.id);
+ if (!defined(attributes)) {
+ attributes = primitive.getGeometryInstanceAttributes(instance.id);
+ this.attributes.set(instance.id.id, attributes);
+ }
+
+ if (!updater.hasConstantFill) {
+ attributes.show = ShowGeometryInstanceAttribute.toValue(updater.isFilled(time), attributes.show);
+ }
+ }
+ }
+ };
+
+ Batch.prototype.destroy = function(time) {
+ var primitive = this.primitive;
+ var primitives = this.primitives;
+ if (defined(primitive)) {
+ primitives.remove(primitive);
+ }
+ this.removeMaterialSubscription();
+ };
+
+ /**
+ * @private
+ */
+ var StaticGeometryPerMaterialBatch = function(primitives, appearanceType, closed) {
+ this._items = [];
+ this._primitives = primitives;
+ this._appearanceType = appearanceType;
+ this._closed = closed;
+ };
+
+ StaticGeometryPerMaterialBatch.prototype.add = function(time, updater) {
+ var items = this._items;
+ var length = items.length;
+ for (var i = 0; i < length; i++) {
+ var item = items[i];
+ if (item.isMaterial(updater)) {
+ item.add(time, updater);
+ return;
+ }
+ }
+ var batch = new Batch(this._primitives, this._appearanceType, updater.fillMaterialProperty, this._closed);
+ batch.add(time, updater);
+ items.push(batch);
+ };
+
+ StaticGeometryPerMaterialBatch.prototype.remove = function(updater) {
+ var items = this._items;
+ var length = items.length;
+ for (var i = length - 1; i >= 0; i--) {
+ var item = items[i];
+ if (item.remove(updater)) {
+ if (item.updaters.length === 0) {
+ items.splice(i, 1);
+ item.destroy();
+ }
+ break;
+ }
+ }
+ };
+
+ StaticGeometryPerMaterialBatch.prototype.update = function(time) {
+ var i;
+ var items = this._items;
+ var length = items.length;
+
+ for (i = length - 1; i >= 0; i--) {
+ var item = items[i];
+ if (item.invalidated) {
+ items.splice(i, 1);
+ var updaters = item.updaters.values;
+ var updatersLength = updaters.length;
+ for (var h = 0; h < updatersLength; i++) {
+ this.add(updaters[h]);
+ }
+ item.destroy();
+ }
+ }
+
+ for (i = 0; i < length; i++) {
+ items[i].update(time);
+ }
+ };
+
+ StaticGeometryPerMaterialBatch.prototype.removeAllPrimitives = function() {
+ var items = this._items;
+ var length = items.length;
+ for (var i = 0; i < length; i++) {
+ items[i].destroy();
+ }
+ this._items.length = 0;
+ };
+
+ return StaticGeometryPerMaterialBatch;
+});
diff --git a/Source/DynamicScene/StaticOutlineGeometryBatch.js b/Source/DynamicScene/StaticOutlineGeometryBatch.js
new file mode 100644
index 000000000000..f518406a75e4
--- /dev/null
+++ b/Source/DynamicScene/StaticOutlineGeometryBatch.js
@@ -0,0 +1,177 @@
+/*global define*/
+define(['../Core/Color',
+ '../Core/ColorGeometryInstanceAttribute',
+ '../Core/defined',
+ '../Core/AssociativeArray',
+ '../Core/ShowGeometryInstanceAttribute',
+ '../Scene/PerInstanceColorAppearance',
+ '../Scene/Primitive',
+ '../Scene/PrimitiveState'
+ ], function(
+ Color,
+ ColorGeometryInstanceAttribute,
+ defined,
+ AssociativeArray,
+ ShowGeometryInstanceAttribute,
+ PerInstanceColorAppearance,
+ Primitive,
+ PrimitiveState) {
+ "use strict";
+
+ var Batch = function(primitives, translucent, appearanceType) {
+ this.translucent = translucent;
+ this.appearanceType = appearanceType;
+ this.primitives = primitives;
+ this.createPrimitive = false;
+ this.primitive = undefined;
+ this.geometry = new AssociativeArray();
+ this.updaters = new AssociativeArray();
+ this.updatersWithAttributes = new AssociativeArray();
+ this.attributes = new AssociativeArray();
+ this.itemsToRemove = [];
+ };
+
+ Batch.prototype.add = function(updater, instance) {
+ var id = updater.dynamicObject.id;
+ this.createPrimitive = true;
+ this.geometry.set(id, instance);
+ this.updaters.set(id, updater);
+ if (!updater.hasConstantOutline || !updater.outlineColorProperty.isConstant) {
+ this.updatersWithAttributes.set(id, updater);
+ }
+ };
+
+ Batch.prototype.remove = function(updater) {
+ var id = updater.dynamicObject.id;
+ this.createPrimitive = this.geometry.remove(id) || this.createPrimitive;
+ this.updaters.remove(id);
+ this.updatersWithAttributes.remove(id);
+ };
+
+ var colorScratch = new Color();
+ Batch.prototype.update = function(time) {
+ var removedCount = 0;
+ var primitive = this.primitive;
+ var primitives = this.primitives;
+ if (this.createPrimitive) {
+ this.attributes.removeAll();
+ if (defined(primitive)) {
+ primitives.remove(primitive);
+ }
+ var geometry = this.geometry.values;
+ if (geometry.length > 0) {
+ primitive = new Primitive({
+ asynchronous : false,
+ geometryInstances : geometry,
+ appearance : new PerInstanceColorAppearance({
+ flat : true,
+ translucent : this.translucent
+ })
+ });
+
+ primitives.add(primitive);
+ }
+ this.primitive = primitive;
+ this.createPrimitive = false;
+ } else if (defined(primitive) && primitive._state === PrimitiveState.COMPLETE) {
+ var updatersWithAttributes = this.updatersWithAttributes.values;
+ var length = updatersWithAttributes.length;
+ for (var i = 0; i < length; i++) {
+ var updater = updatersWithAttributes[i];
+ var instance = this.geometry.get(updater.dynamicObject.id);
+
+ var attributes = this.attributes.get(instance.id.id);
+ if (!defined(attributes)) {
+ attributes = primitive.getGeometryInstanceAttributes(instance.id);
+ this.attributes.set(instance.id.id, attributes);
+ }
+
+ var outlineColorProperty = updater.outlineColorProperty;
+ outlineColorProperty.getValue(time, colorScratch);
+ attributes.color = ColorGeometryInstanceAttribute.toValue(colorScratch, attributes.color);
+ if ((this.translucent && attributes.color[3] === 255) || (!this.translucent && attributes.color[3] !== 255)) {
+ this.itemsToRemove[removedCount++] = updater;
+ }
+ attributes.show = ShowGeometryInstanceAttribute.toValue(updater.isOutlineVisible(time), attributes.show);
+ }
+ }
+ this.itemsToRemove.length = removedCount;
+ };
+
+ Batch.prototype.removeAllPrimitives = function() {
+ var primitive = this.primitive;
+ if (defined(primitive)) {
+ this.primitives.remove(primitive);
+ this.primitive = undefined;
+ this.geometry.removeAll();
+ this.updaters.removeAll();
+ }
+ };
+
+ /**
+ * @private
+ */
+ var StaticOutlineGeometryBatch = function(primitives, appearanceType) {
+ this._solidBatch = new Batch(primitives, false, appearanceType);
+ this._translucentBatch = new Batch(primitives, true, appearanceType);
+ };
+
+ StaticOutlineGeometryBatch.prototype.add = function(time, updater) {
+ var instance = updater.createOutlineGeometryInstance(time);
+ if (instance.attributes.color.value[3] === 255) {
+ this._solidBatch.add(updater, instance);
+ } else {
+ this._translucentBatch.add(updater, instance);
+ }
+ };
+
+ StaticOutlineGeometryBatch.prototype.remove = function(updater) {
+ if (!this._solidBatch.remove(updater)) {
+ this._translucentBatch.remove(updater);
+ }
+ };
+
+ StaticOutlineGeometryBatch.prototype.update = function(time) {
+ var i;
+ var updater;
+
+ //Perform initial update
+ this._solidBatch.update(time);
+ this._translucentBatch.update(time);
+
+ //If any items swapped between solid/translucent, we need to
+ //move them between batches
+ var itemsToRemove = this._solidBatch.itemsToRemove;
+ var solidsToMoveLength = itemsToRemove.length;
+ if (solidsToMoveLength > 0) {
+ for (i = 0; i < solidsToMoveLength; i++) {
+ updater = itemsToRemove[i];
+ this._solidBatch.remove(updater);
+ this._translucentBatch.add(updater, updater.createOutlineGeometryInstance(time));
+ }
+ }
+
+ itemsToRemove = this._translucentBatch.itemsToRemove;
+ var translucentToMoveLength = itemsToRemove.length;
+ if (translucentToMoveLength > 0) {
+ for (i = 0; i < translucentToMoveLength; i++) {
+ updater = itemsToRemove[i];
+ this._translucentBatch.remove(updater);
+ this._solidBatch.add(updater, updater.createOutlineGeometryInstance(time));
+ }
+ }
+
+ //If we moved anything around, we need to re-build the primitive
+ if (solidsToMoveLength > 0 || translucentToMoveLength > 0) {
+ this._solidBatch.update(time);
+ this._translucentBatch.update(time);
+ }
+ };
+
+ StaticOutlineGeometryBatch.prototype.removeAllPrimitives = function() {
+ this._solidBatch.removeAllPrimitives();
+ this._translucentBatch.removeAllPrimitives();
+ };
+
+ return StaticOutlineGeometryBatch;
+});
diff --git a/Source/DynamicScene/TimeIntervalCollectionPositionProperty.js b/Source/DynamicScene/TimeIntervalCollectionPositionProperty.js
index aca282e86c31..aaf964212cef 100644
--- a/Source/DynamicScene/TimeIntervalCollectionPositionProperty.js
+++ b/Source/DynamicScene/TimeIntervalCollectionPositionProperty.js
@@ -1,22 +1,23 @@
/*global define*/
-define([
+define(['./PositionProperty',
+ './Property',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
+ '../Core/Event',
'../Core/ReferenceFrame',
- '../Core/TimeIntervalCollection',
- './PositionProperty',
- './Property'
+ '../Core/TimeIntervalCollection'
], function(
+ PositionProperty,
+ Property,
defaultValue,
defined,
defineProperties,
DeveloperError,
+ Event,
ReferenceFrame,
- TimeIntervalCollection,
- PositionProperty,
- Property) {
+ TimeIntervalCollection) {
"use strict";
/**
@@ -28,11 +29,36 @@ define([
* @param {ReferenceFrame} [referenceFrame=ReferenceFrame.FIXED] The reference frame in which the position is defined.
*/
var TimeIntervalCollectionPositionProperty = function(referenceFrame) {
+ this._definitionChanged = new Event();
this._intervals = new TimeIntervalCollection();
+ this._intervals.getChangedEvent().addEventListener(TimeIntervalCollectionPositionProperty.prototype._intervalsChanged, this);
this._referenceFrame = defaultValue(referenceFrame, ReferenceFrame.FIXED);
};
defineProperties(TimeIntervalCollectionPositionProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof TimeIntervalCollectionPositionProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return this._intervals.isEmpty();
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is considered to have changed if a call to getValue would return
+ * a different result for the same time.
+ * @memberof TimeIntervalCollectionPositionProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
/**
* Gets the interval collection.
* @memberof TimeIntervalCollectionPositionProperty.prototype
@@ -109,5 +135,12 @@ define([
this._referenceFrame === other._referenceFrame);
};
+ /**
+ * @private
+ */
+ TimeIntervalCollectionPositionProperty.prototype._intervalsChanged = function() {
+ this._definitionChanged.raiseEvent(this);
+ };
+
return TimeIntervalCollectionPositionProperty;
});
\ No newline at end of file
diff --git a/Source/DynamicScene/TimeIntervalCollectionProperty.js b/Source/DynamicScene/TimeIntervalCollectionProperty.js
index df88f4083809..e39bee689f11 100644
--- a/Source/DynamicScene/TimeIntervalCollectionProperty.js
+++ b/Source/DynamicScene/TimeIntervalCollectionProperty.js
@@ -1,30 +1,30 @@
/*global define*/
-define([
+define(['./Property',
'../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
'../Core/Enumeration',
- '../Core/TimeIntervalCollection',
- './Property'
+ '../Core/Event',
+ '../Core/isArray',
+ '../Core/TimeIntervalCollection'
], function(
+ Property,
defined,
defineProperties,
DeveloperError,
Enumeration,
- TimeIntervalCollection,
- Property) {
+ Event,
+ isArray,
+ TimeIntervalCollection) {
"use strict";
/**
- * A {@link Property} which is defined by a TimeIntervalCollection, where the
+ * A {@link Property} which is defined by a {@link TimeIntervalCollection}, where the
* data property of each {@link TimeInterval} represents the value at time.
*
* @alias TimeIntervalCollectionProperty
* @constructor
*
- * @param {Function} [clone=value.clone] A function which takes the value and a result parameter and clones it.
- * This parameter is only required if the value is not a number or string and does not have a clone function.
- *
* @example
* //Create a Cartesian2 interval property which contains data on August 1st, 2012
* //and uses a different value every 6 hours.
@@ -36,26 +36,55 @@ define([
*
* @example
* //Create a TimeIntervalCollectionProperty that contains user-defined objects.
- * var myObject = {
- * value : 6
- * };
- * var myObject2 = {
- * value : 12
- * };
* function cloneMyObject(value, result) {
* return {
* value : value.value
* };
* }
- * var composite = new Cesium.TimeIntervalCollectionProperty(cloneMyObject);
+ *
+ * var myObject = {
+ * value : 6,
+ * clone : cloneMyObject
+ * };
+ * var myObject2 = {
+ * value : 12,
+ * clone : cloneMyObject
+ * };
+ *
+ * var composite = new Cesium.TimeIntervalCollectionProperty();
* composite.intervals.addInterval(Cesium.TimeInterval.fromIso8601('2012-08-01T00:00:00.00Z/2012-08-01T06:00:00.00Z', true, false, myObject));
* composite.intervals.addInterval(Cesium.TimeInterval.fromIso8601('2012-08-01T06:00:00.00Z/2012-08-01T12:00:00.00Z', true, false, myObject2));
*/
var TimeIntervalCollectionProperty = function() {
+ this._definitionChanged = new Event();
this._intervals = new TimeIntervalCollection();
+ this._intervals.getChangedEvent().addEventListener(TimeIntervalCollectionProperty.prototype._intervalsChanged, this);
};
defineProperties(TimeIntervalCollectionProperty.prototype, {
+ /**
+ * Gets a value indicating if this property is constant. A property is considered
+ * constant if getValue always returns the same result for the current definition.
+ * @memberof TimeIntervalCollectionProperty.prototype
+ * @type {Boolean}
+ */
+ isConstant : {
+ get : function() {
+ return this._intervals.isEmpty();
+ }
+ },
+ /**
+ * Gets the event that is raised whenever the definition of this property changes.
+ * The definition is changed whenever setValue is called with data different
+ * than the current value.
+ * @memberof TimeIntervalCollectionProperty.prototype
+ * @type {Event}
+ */
+ definitionChanged : {
+ get : function() {
+ return this._definitionChanged;
+ }
+ },
/**
* Gets the interval collection.
* @memberof TimeIntervalCollectionProperty.prototype
@@ -87,7 +116,7 @@ define([
//>>includeEnd('debug');
var value = this._intervals.findDataForIntervalContainingDate(time);
- if (defined(value) && (typeof value === 'object' && !Array.isArray(value) && !(value instanceof Enumeration))) {
+ if (defined(value) && (typeof value === 'object' && !isArray(value) && !(value instanceof Enumeration))) {
return value.clone(result);
}
return value;
@@ -107,5 +136,12 @@ define([
this._intervals.equals(other._intervals, Property.equals));
};
+ /**
+ * @private
+ */
+ TimeIntervalCollectionProperty.prototype._intervalsChanged = function() {
+ this._definitionChanged.raiseEvent(this);
+ };
+
return TimeIntervalCollectionProperty;
-});
\ No newline at end of file
+});
diff --git a/Source/DynamicScene/VisualizerCollection.js b/Source/DynamicScene/VisualizerCollection.js
deleted file mode 100644
index 39f9492cf751..000000000000
--- a/Source/DynamicScene/VisualizerCollection.js
+++ /dev/null
@@ -1,157 +0,0 @@
-/*global define*/
-define([
- '../Core/defaultValue',
- '../Core/defined',
- '../Core/destroyObject'
- ], function(
- defaultValue,
- defined,
- destroyObject) {
- "use strict";
-
- /**
- * A collection of visualizers which makes it easy to manage and
- * update them in unison.
- * @alias VisualizerCollection
- * @constructor
- *
- * @param {Object} The array of visualizers to use.
- * @param {DynamicObjectCollection} The objects to be visualized.
- */
- var VisualizerCollection = function(visualizers, dynamicObjectCollection) {
- this._visualizers = defined(visualizers) ? visualizers : [];
- this._dynamicObjectCollection = undefined;
- this.setDynamicObjectCollection(dynamicObjectCollection);
- };
-
- /**
- * Gets a copy of the array of visualizers in the collection.
- * @returns {Array} the array of visualizers in the collection.
- */
- VisualizerCollection.prototype.getVisualizers = function() {
- return this._visualizers.slice(0);
- };
-
- /**
- * Sets the array of visualizers in the collection.
- *
- * @param {Array} visualizers The new array of visualizers. This array can partially overlap with visualizers currently in the collection.
- * @param {Boolean} destroyOldVisualizers If true, visualizers no longer in the collection will be destroyed.
- */
- VisualizerCollection.prototype.setVisualizers = function(visualizers, destroyOldVisualizers) {
- destroyOldVisualizers = defaultValue(destroyOldVisualizers, true);
-
- var i;
- var thisVisualizers = this._visualizers;
- if (destroyOldVisualizers) {
- for (i = thisVisualizers.length - 1; i > -1; i--) {
- var visualizer = thisVisualizers[i];
- if (visualizers.indexOf(visualizer) === -1) {
- visualizer.destroy();
- }
- }
- }
-
- if (!defined(visualizers)) {
- visualizers = [];
- }
- this._visualizers = visualizers;
- var dynamicObjectCollection = this._dynamicObjectCollection;
- for (i = visualizers.length - 1; i > -1; i--) {
- visualizers[i].setDynamicObjectCollection(dynamicObjectCollection);
- }
- };
-
- /**
- * Gets the DynamicObjectCollection being visualized.
- * @returns the DynamicObjectCollection being visualized
- */
- VisualizerCollection.prototype.getDynamicObjectCollection = function() {
- return this._dynamicObjectCollection;
- };
-
- /**
- * Sets the DynamicObjectCollection being visualized.
- * @param {DynamicObjectCollection} dynamicObjectCollection the DynamicObjectCollection being visualized.
- */
- VisualizerCollection.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) {
- var oldCollection = this._dynamicObjectCollection;
- if (oldCollection !== dynamicObjectCollection) {
- this._dynamicObjectCollection = dynamicObjectCollection;
- var visualizers = this._visualizers;
- for ( var i = visualizers.length - 1; i > -1; i--) {
- visualizers[i].setDynamicObjectCollection(dynamicObjectCollection);
- }
- }
- };
-
- /**
- * Updates all visualizers to the provided time.
- * @param {JulianDate} time The time to updated to.
- */
- VisualizerCollection.prototype.update = function(time) {
- var visualizers = this._visualizers;
- for ( var i = visualizers.length - 1; i > -1; i--) {
- visualizers[i].update(time);
- }
- };
-
- /**
- * Removes all primitives from visualization.
- */
- VisualizerCollection.prototype.removeAllPrimitives = function() {
- var visualizers = this._visualizers;
- for ( var i = visualizers.length - 1; i > -1; i--) {
- visualizers[i].removeAllPrimitives();
- }
- };
-
- /**
- * Returns true if this object was destroyed; otherwise, false.
- * isDestroyed
will result in a {@link DeveloperError} exception.
- *
- * @memberof VisualizerCollection
- *
- * @returns {Boolean} True if this object was destroyed; otherwise, false.
- *
- * @see VisualizerCollection#destroy
- */
- VisualizerCollection.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.
- * isDestroyed
will result in a {@link DeveloperError} exception. Therefore,
- * assign the return value (undefined
) to the object as done in the example.
- *
- * @memberof VisualizerCollection
- *
- * @returns {undefined}
- *
- * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
- *
- * @see VisualizerCollection#isDestroyed
- *
- * @example
- * visualizerCollection = visualizerCollection && visualizerCollection.destroy();
- */
- VisualizerCollection.prototype.destroy = function(destroyVisualizers) {
- destroyVisualizers = defaultValue(destroyVisualizers, true);
- this.removeAllPrimitives();
- if (destroyVisualizers) {
- var visualizers = this._visualizers;
- for ( var i = visualizers.length - 1; i > -1; i--) {
- visualizers[i].destroy();
- }
- }
- return destroyObject(this);
- };
-
- return VisualizerCollection;
-});
\ No newline at end of file
diff --git a/Source/DynamicScene/createDynamicPropertyDescriptor.js b/Source/DynamicScene/createDynamicPropertyDescriptor.js
index 12005b6b7329..7303a66b8705 100644
--- a/Source/DynamicScene/createDynamicPropertyDescriptor.js
+++ b/Source/DynamicScene/createDynamicPropertyDescriptor.js
@@ -1,26 +1,46 @@
/*global define*/
-define(['../Core/defaultValue'], function(defaultValue) {
+define(['../Core/defaultValue',
+ '../Core/defined'
+ ], function(
+ defaultValue,
+ defined) {
"use strict";
- /**
- * Used to consistently define all DynamicScene graphics objects.
- * @private
- */
- function createDynamicPropertyDescriptor(name, privateName, configurable) {
+ function createProperty(name, privateName, subscriptionName, configurable) {
return {
- configurable : defaultValue(configurable, false),
+ configurable : configurable,
get : function() {
return this[privateName];
},
set : function(value) {
var oldValue = this[privateName];
+ var subscription = this[subscriptionName];
+ if (defined(subscription)) {
+ subscription();
+ this[subscriptionName] = undefined;
+ }
if (oldValue !== value) {
this[privateName] = value;
- this._propertyChanged.raiseEvent(this, name, value, oldValue);
+ this._definitionChanged.raiseEvent(this, name, value, oldValue);
+ }
+ if (defined(value) && defined(value.definitionChanged)) {
+ this[subscriptionName] = value.definitionChanged.addEventListener(function() {
+ this._definitionChanged.raiseEvent(this, name, value, value);
+ }, this);
}
}
};
}
+ /**
+ * Used to consistently define all DynamicScene graphics objects.
+ * This is broken into two functions because the Chrome profiler does a better
+ * job of optimizing lookups if it notices that the string is constant throughout the function.
+ * @private
+ */
+ function createDynamicPropertyDescriptor(name, configurable) {
+ return createProperty(name, '_' + name, '_' + name + 'Subscription', defaultValue(configurable, false));
+ }
+
return createDynamicPropertyDescriptor;
});
\ No newline at end of file
diff --git a/Source/Scene/Billboard.js b/Source/Scene/Billboard.js
index 3a830e35da66..74e3eafc1191 100644
--- a/Source/Scene/Billboard.js
+++ b/Source/Scene/Billboard.js
@@ -29,8 +29,6 @@ define([
SceneTransforms) {
"use strict";
- var EMPTY_OBJECT = {};
-
/**
* A viewport-aligned image positioned in the 3D scene, that is created
* and rendered using a {@link BillboardCollection}. A billboard is created and its initial
@@ -65,7 +63,7 @@ define([
* @demo Cesium Sandcastle Billboard Demo
*/
var Billboard = function(options, billboardCollection) {
- options = defaultValue(options, EMPTY_OBJECT);
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
//>>includeStart('debug', pragmas.debug);
if (defined(options.scaleByDistance) && options.scaleByDistance.far <= options.scaleByDistance.near) {
@@ -100,6 +98,7 @@ define([
this._translucencyByDistance = options.translucencyByDistance;
this._pixelOffsetScaleByDistance = options.pixelOffsetScaleByDistance;
this._id = options.id;
+ this._collection = defaultValue(options.collection, billboardCollection);
this._pickId = undefined;
this._pickIdThis = options._pickIdThis;
@@ -136,6 +135,7 @@ define([
if (!defined(this._pickId)) {
this._pickId = context.createPickId({
primitive : defaultValue(this._pickIdThis, this),
+ collection : this._collection,
id : this._id
});
}
@@ -1009,7 +1009,7 @@ define([
* @see Billboard#setPixelOffset
*
* @example
- * console.log(b.computeScreenSpacePosition(scene.getContext(), scene.getFrameState()).toString());
+ * console.log(b.computeScreenSpacePosition(scene.context, scene.frameState).toString());
*/
var tempPixelOffset = new Cartesian2(0.0, 0.0);
Billboard.prototype.computeScreenSpacePosition = function(context, frameState) {
diff --git a/Source/Scene/Camera.js b/Source/Scene/Camera.js
index 6725af438020..9b051a16ee08 100644
--- a/Source/Scene/Camera.js
+++ b/Source/Scene/Camera.js
@@ -71,7 +71,7 @@ define([
this._transform = Matrix4.clone(Matrix4.IDENTITY);
this._invTransform = Matrix4.clone(Matrix4.IDENTITY);
- var maxRadii = Ellipsoid.WGS84.getMaximumRadius();
+ var maxRadii = Ellipsoid.WGS84.maximumRadius;
var position = Cartesian3.multiplyByScalar(Cartesian3.normalize(new Cartesian3(0.0, -2.0, 1.0)), 2.5 * maxRadii);
/**
@@ -250,12 +250,10 @@ define([
defineProperties(Camera.prototype, {
/**
* Gets the inverse camera transform.
+ * @memberof Camera.prototype
*
- * @memberof Camera
* @type {Matrix4}
* @default {@link Matrix4.IDENTITY}
- *
- * @see Camera#transform
*/
inverseTransform : {
get : function () {
@@ -265,9 +263,9 @@ define([
},
/**
- * The view matrix.
+ * Gets the view matrix.
+ * @memberof Camera.prototype
*
- * @memberof Camera
* @type {Matrix4}
*
* @see UniformState#getView
@@ -282,9 +280,9 @@ define([
},
/**
- * The inverse view matrix.
+ * Gets the inverse view matrix.
+ * @memberof Camera.prototype
*
- * @memberof Camera
* @type {Matrix4}
*
* @see UniformState#getInverseView
@@ -299,9 +297,8 @@ define([
},
/**
- * The position of the camera in world coordinates.
- *
- * @memberof Camera
+ * Gets the position of the camera in world coordinates.
+ * @memberof Camera.prototype
* @type {Cartesian3}
*/
positionWC : {
@@ -312,9 +309,8 @@ define([
},
/**
- * The view direction of the camera in world coordinates.
- *
- * @memberof Camera
+ * Gets the view direction of the camera in world coordinates.
+ * @memberof Camera.prototype
* @type {Cartesian3}
*/
directionWC : {
@@ -325,9 +321,8 @@ define([
},
/**
- * The up direction of the camera in world coordinates.
- *
- * @memberof Camera
+ * Gets the up direction of the camera in world coordinates.
+ * @memberof Camera.prototype
* @type {Cartesian3}
*/
upWC : {
@@ -338,9 +333,8 @@ define([
},
/**
- * The right direction of the camera in world coordinates.
- *
- * @memberof Camera
+ * Gets the right direction of the camera in world coordinates.
+ * @memberof Camera.prototype
* @type {Cartesian3}
*/
rightWC : {
diff --git a/Source/Scene/CameraController.js b/Source/Scene/CameraController.js
index a506e28af1f0..61a3324f2c54 100644
--- a/Source/Scene/CameraController.js
+++ b/Source/Scene/CameraController.js
@@ -824,9 +824,8 @@ define([
defineProperties(CameraController.prototype, {
/**
- * The camera heading in radians.
- * @memberof CameraController
- *
+ * Gets or sets the camera heading in radians.
+ * @memberof CameraController.prototype
* @type {Number}
*/
heading : {
@@ -857,9 +856,8 @@ define([
},
/**
- * The the camera tilt in radians
- * @memberof CameraController
- *
+ * Gets or sets the camera tilt in radians
+ * @memberof CameraController.prototype
* @type {Number}
*/
tilt : {
diff --git a/Source/Scene/CameraFlightPath.js b/Source/Scene/CameraFlightPath.js
index 1aac3179631b..b5a58d063162 100644
--- a/Source/Scene/CameraFlightPath.js
+++ b/Source/Scene/CameraFlightPath.js
@@ -87,7 +87,7 @@ define([
function createPath3D(camera, ellipsoid, start, end, duration) {
// get minimum altitude from which the whole ellipsoid is visible
- var radius = ellipsoid.getMaximumRadius();
+ var radius = ellipsoid.maximumRadius;
var frustum = camera.frustum;
var maxStartAlt = getAltitude(frustum, radius, radius);
@@ -208,7 +208,7 @@ define([
function createPath2D(camera, ellipsoid, start, end, duration) {
// get minimum altitude from which the whole map is visible
- var radius = ellipsoid.getMaximumRadius();
+ var radius = ellipsoid.maximumRadius;
var frustum = camera.frustum;
var maxStartAlt = getAltitude(frustum, Math.PI * radius, CesiumMath.PI_OVER_TWO * radius);
@@ -365,7 +365,7 @@ define([
* @exception {DeveloperError} frameState.mode cannot be SceneMode.MORPHING
* @exception {DeveloperError} If either direction or up is given, then both are required.
*
- * @see Scene#getAnimations
+ * @see Scene#animations
*/
var dirScratch = new Cartesian3();
var rightScratch = new Cartesian3();
@@ -386,14 +386,14 @@ define([
if ((defined(direction) && !defined(up)) || (defined(up) && !defined(direction))) {
throw new DeveloperError('If either direction or up is given, then both are required.');
}
- if (scene.getFrameState().mode === SceneMode.MORPHING) {
+ if (scene.frameState.mode === SceneMode.MORPHING) {
throw new DeveloperError('frameState.mode cannot be SceneMode.MORPHING');
}
//>>includeEnd('debug');
var duration = defaultValue(description.duration, 3000.0);
- var frameState = scene.getFrameState();
- var controller = scene.getScreenSpaceCameraController();
+ var frameState = scene.frameState;
+ var controller = scene.screenSpaceCameraController;
controller.enableInputs = false;
var wrapCallback = function(cb) {
var wrapped = function() {
@@ -517,7 +517,7 @@ define([
*
* @exception {DeveloperError} frameState.mode cannot be SceneMode.MORPHING
*
- * @see Scene#getAnimations
+ * @see Scene#animations
*/
CameraFlightPath.createAnimationCartographic = function(scene, description) {
description = defaultValue(description, defaultValue.EMPTY_OBJECT);
@@ -532,7 +532,7 @@ define([
}
//>>includeEnd('debug');
- var frameState = scene.getFrameState();
+ var frameState = scene.frameState;
var projection = frameState.scene2D.projection;
if (frameState.mode === SceneMode.SCENE3D) {
var ellipsoid = projection.getEllipsoid();
@@ -562,12 +562,12 @@ define([
*
* @exception {DeveloperError} frameState.mode cannot be SceneMode.MORPHING
*
- * @see Scene#getAnimations
+ * @see Scene#animations
*/
CameraFlightPath.createAnimationExtent = function(scene, description) {
description = defaultValue(description, defaultValue.EMPTY_OBJECT);
var extent = description.destination;
- var frameState = scene.getFrameState();
+ var frameState = scene.frameState;
//>>includeStart('debug', pragmas.debug);
if (!defined(frameState)) {
diff --git a/Source/Scene/CentralBody.js b/Source/Scene/CentralBody.js
index c14c7947f3a6..1579582904c9 100644
--- a/Source/Scene/CentralBody.js
+++ b/Source/Scene/CentralBody.js
@@ -5,6 +5,7 @@ define([
'../Core/loadImage',
'../Core/defaultValue',
'../Core/defined',
+ '../Core/defineProperties',
'../Core/destroyObject',
'../Core/BoundingRectangle',
'../Core/BoundingSphere',
@@ -49,6 +50,7 @@ define([
loadImage,
defaultValue,
defined,
+ defineProperties,
destroyObject,
BoundingRectangle,
BoundingSphere,
@@ -116,7 +118,7 @@ define([
imageryLayerCollection : imageryLayerCollection
});
- this._occluder = new Occluder(new BoundingSphere(Cartesian3.ZERO, ellipsoid.getMinimumRadius()), Cartesian3.ZERO);
+ this._occluder = new Occluder(new BoundingSphere(Cartesian3.ZERO, ellipsoid.minimumRadius), Cartesian3.ZERO);
this._surfaceShaderSet = new CentralBodySurfaceShaderSet(TerrainProvider.attributeLocations);
@@ -131,7 +133,7 @@ define([
this._depthCommand = new DrawCommand();
this._depthCommand.primitiveType = PrimitiveType.TRIANGLES;
- this._depthCommand.boundingVolume = new BoundingSphere(Cartesian3.ZERO, ellipsoid.getMaximumRadius());
+ this._depthCommand.boundingVolume = new BoundingSphere(Cartesian3.ZERO, ellipsoid.maximumRadius);
this._depthCommand.pass = Pass.OPAQUE;
this._depthCommand.owner = this;
@@ -266,27 +268,29 @@ define([
};
};
- /**
- * Gets an ellipsoid describing the shape of this central body.
- *
- * @memberof CentralBody
- *
- * @returns {Ellipsoid}
- */
- CentralBody.prototype.getEllipsoid = function() {
- return this._ellipsoid;
- };
+ defineProperties(CentralBody.prototype, {
+ /**
+ * Gets an ellipsoid describing the shape of this central body.
+ * @memberof CentralBody.prototype
+ * @type {Ellipsoid}
+ */
+ ellipsoid : {
+ get: function() {
+ return this._ellipsoid;
+ }
+ },
- /**
- * Gets the collection of image layers that will be rendered on this central body.
- *
- * @memberof CentralBody
- *
- * @returns {ImageryLayerCollection}
- */
- CentralBody.prototype.getImageryLayers = function() {
- return this._imageryLayerCollection;
- };
+ /**
+ * Gets the collection of image layers that will be rendered on this central body.
+ * @memberof CentralBody.prototype
+ * @type {ImageryLayerCollection}
+ */
+ imageryLayerCollection : {
+ get : function() {
+ return this._imageryLayerCollection;
+ }
+ }
+ });
var depthQuadScratch = FeatureDetection.supportsTypedArrays() ? new Float32Array(12) : [];
var scratchCartesian1 = new Cartesian3();
@@ -295,11 +299,11 @@ define([
var scratchCartesian4 = new Cartesian3();
function computeDepthQuad(centralBody, frameState) {
- var radii = centralBody._ellipsoid.getRadii();
+ var radii = centralBody._ellipsoid.radii;
var p = frameState.camera.positionWC;
// Find the corresponding position in the scaled space of the ellipsoid.
- var q = Cartesian3.multiplyComponents(centralBody._ellipsoid.getOneOverRadii(), p, scratchCartesian1);
+ var q = Cartesian3.multiplyComponents(centralBody._ellipsoid.oneOverRadii, p, scratchCartesian1);
var qMagnitude = Cartesian3.magnitude(q);
var qUnit = Cartesian3.normalize(q, scratchCartesian2);
diff --git a/Source/Scene/CentralBodySurface.js b/Source/Scene/CentralBodySurface.js
index 1ba144c7d3c2..fdc3efec455c 100644
--- a/Source/Scene/CentralBodySurface.js
+++ b/Source/Scene/CentralBodySurface.js
@@ -373,7 +373,7 @@ define([
var ellipsoid = surface._terrainProvider.getTilingScheme().getEllipsoid();
var cameraPositionCartographic = ellipsoid.cartesianToCartographic(cameraPosition, scratchCamera);
- surface._ellipsoidalOccluder.setCameraPosition(cameraPosition);
+ surface._ellipsoidalOccluder.cameraPosition = cameraPosition;
var tile;
diff --git a/Source/Scene/CompositePrimitive.js b/Source/Scene/CompositePrimitive.js
index 34ec4b172e21..ce1621026416 100644
--- a/Source/Scene/CompositePrimitive.js
+++ b/Source/Scene/CompositePrimitive.js
@@ -2,11 +2,13 @@
define([
'../Core/createGuid',
'../Core/defined',
+ '../Core/defineProperties',
'../Core/destroyObject',
'../Core/DeveloperError'
], function(
createGuid,
defined,
+ defineProperties,
destroyObject,
DeveloperError) {
"use strict";
@@ -22,7 +24,7 @@ define([
* @example
* // Example 1. Add primitives to a composite.
* var primitives = new Cesium.CompositePrimitive();
- * primitives.setCentralBody(new Cesium.CentralBody());
+ * primitives.centralBody = new Cesium.CentralBody();
* primitives.add(billboards);
* primitives.add(labels);
*
@@ -47,7 +49,6 @@ define([
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
*
* @see CompositePrimitive#destroy
- * @see CompositePrimitive#setCentralBody
* @see CompositePrimitive#remove
* @see CompositePrimitive#removeAll
*
@@ -78,38 +79,35 @@ define([
this.show = true;
};
- /**
- * DOC_TBA
- *
- * @memberof CompositePrimitive
- * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
- *
- * @see CompositePrimitive#setCentralBody
- */
- CompositePrimitive.prototype.getCentralBody = function() {
- return this._centralBody;
- };
+ defineProperties(CompositePrimitive.prototype, {
- /**
- * DOC_TBA
- *
- * Implicitly sets the depth-test ellipsoid.
- *
- * @memberof CompositePrimitive
- *
- * @see CompositePrimitive#depthTestEllipsoid
- * @see CompositePrimitive#getCentralBody
- *
- * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
- *
- * @example
- * var primitives = new Cesium.CompositePrimitive();
- * primitives.setCentralBody(new Cesium.CentralBody());
- */
- CompositePrimitive.prototype.setCentralBody = function(centralBody) {
- this._centralBody = this.destroyPrimitives && this._centralBody && this._centralBody.destroy();
- this._centralBody = centralBody;
- };
+ /**
+ * Gets or sets the depth-test ellipsoid.
+ * @memberof CompositePrimitive.prototype
+ * @type {CentralBody}
+ */
+ centralBody : {
+ get: function() {
+ return this._centralBody;
+ },
+
+ set: function(centralBody) {
+ this._centralBody = this.destroyPrimitives && this._centralBody && this._centralBody.destroy();
+ this._centralBody = centralBody;
+ }
+ },
+
+ /**
+ * Gets the length of the list of primitives
+ * @memberof CompositePrimitive.prototype
+ * @type {Number}
+ */
+ length : {
+ get : function() {
+ return this._primitives.length;
+ }
+ }
+ });
/**
* Adds a primitive to a composite primitive. When a composite is rendered
@@ -358,7 +356,7 @@ define([
* @example
* // Toggle the show property of every primitive in the composite -
* // not recursive on child composites.
- * var len = primitives.getLength();
+ * var len = primitives.length;
* for (var i = 0; i < len; ++i) {
* var p = primitives.get(i);
* p.show = !p.show;
@@ -374,28 +372,6 @@ define([
return this._primitives[index];
};
- /**
- * DOC_TBA
- *
- * @memberof CompositePrimitive
- *
- * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
- *
- * @see CompositePrimitive#get
- *
- * @example
- * // Toggle the show property of every primitive in the composite -
- * // not recursive on child composites.
- * var len = primitives.getLength();
- * for (var i = 0; i < len; ++i) {
- * var p = primitives.get(i);
- * p.show = !p.show;
- * }
- */
- CompositePrimitive.prototype.getLength = function() {
- return this._primitives.length;
- };
-
/**
* @private
*/
diff --git a/Source/Scene/CustomSensorVolume.js b/Source/Scene/CustomSensorVolume.js
index 150e8a9b8006..1f23ca826544 100644
--- a/Source/Scene/CustomSensorVolume.js
+++ b/Source/Scene/CustomSensorVolume.js
@@ -542,11 +542,12 @@ define([
pickCommand.shaderProgram, CustomSensorVolumeVS, pickFS, attributeLocations);
var that = this;
- pickCommand.uniformMap = combine([this._uniforms, this._material._uniforms, {
+ var uniforms = {
czm_pickColor : function() {
return that._pickId.color;
}
- }], false, false);
+ };
+ pickCommand.uniformMap = combine(combine(this._uniforms, this._material._uniforms), uniforms);
}
pickCommand.pass = translucent ? Pass.TRANSLUCENT : Pass.OPAQUE;
diff --git a/Source/Scene/DebugModelMatrixPrimitive.js b/Source/Scene/DebugModelMatrixPrimitive.js
index 1ea5d08bee6a..4055767c7188 100644
--- a/Source/Scene/DebugModelMatrixPrimitive.js
+++ b/Source/Scene/DebugModelMatrixPrimitive.js
@@ -153,7 +153,8 @@ define([
}),
appearance : new PolylineColorAppearance(),
asynchronous : false,
- allow3DOnly : Matrix4.equals(this.modelMatrix, Matrix4.IDENTITY) // Workaround projecting (0, 0, 0)
+ // Workaround projecting (0, 0, 0)
+ allow3DOnly : (this.modelMatrix[12] === 0.0 && this.modelMatrix[13] === 0.0 && this.modelMatrix[14] === 0.0)
});
}
diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js
index ac1dabbf69f1..9c880150e2ee 100644
--- a/Source/Scene/ImageryLayer.js
+++ b/Source/Scene/ImageryLayer.js
@@ -957,7 +957,7 @@ define([
var ellipsoid = tilingScheme.getEllipsoid();
var latitudeFactor = !(layer._imageryProvider.getTilingScheme() instanceof GeographicTilingScheme) ? Math.cos(latitudeClosestToEquator) : 1.0;
var tilingSchemeExtent = tilingScheme.getExtent();
- var levelZeroMaximumTexelSpacing = ellipsoid.getMaximumRadius() * (tilingSchemeExtent.east - tilingSchemeExtent.west) * latitudeFactor / (imageryProvider.getTileWidth() * tilingScheme.getNumberOfXTilesAtLevel(0));
+ var levelZeroMaximumTexelSpacing = ellipsoid.maximumRadius * (tilingSchemeExtent.east - tilingSchemeExtent.west) * latitudeFactor / (imageryProvider.getTileWidth() * tilingScheme.getNumberOfXTilesAtLevel(0));
var twoToTheLevelPower = levelZeroMaximumTexelSpacing / texelSpacing;
var level = Math.log(twoToTheLevelPower) / Math.log(2);
diff --git a/Source/Scene/ImageryProvider.js b/Source/Scene/ImageryProvider.js
index b778a0a96d75..69bd712649ef 100644
--- a/Source/Scene/ImageryProvider.js
+++ b/Source/Scene/ImageryProvider.js
@@ -116,65 +116,65 @@ define([
*/
this.defaultGamma = undefined;
- throw new DeveloperError('This type should not be instantiated directly.');
+ DeveloperError.throwInstantiationError();
};
/**
* Gets a value indicating whether or not the provider is ready for use.
+ * @memberof ImageryProvider
+ * @function
*
* @returns {Boolean} True if the provider is ready to use; otherwise, false.
*/
- ImageryProvider.prototype.isReady = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.isReady = DeveloperError.throwInstantiationError;
/**
* Gets the extent, in radians, of the imagery provided by this instance. This function should
* not be called before {@link ImageryProvider#isReady} returns true.
+ * @memberof ImageryProvider
+ * @function
*
* @returns {Extent} The extent.
*
* @exception {DeveloperError} getExtent
must not be called before the imagery provider is ready.
*/
- ImageryProvider.prototype.getExtent = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.getExtent = DeveloperError.throwInstantiationError;
/**
* Gets the width of each tile, in pixels. This function should
* not be called before {@link ImageryProvider#isReady} returns true.
+ * @memberof ImageryProvider
+ * @function
*
* @returns {Number} The width.
*
* @exception {DeveloperError} getTileWidth
must not be called before the imagery provider is ready.
*/
- ImageryProvider.prototype.getTileWidth = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.getTileWidth = DeveloperError.throwInstantiationError;
/**
* Gets the height of each tile, in pixels. This function should
* not be called before {@link ImageryProvider#isReady} returns true.
+ * @memberof ImageryProvider
+ * @function
*
* @returns {Number} The height.
*
* @exception {DeveloperError} getTileHeight
must not be called before the imagery provider is ready.
*/
- ImageryProvider.prototype.getTileHeight = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.getTileHeight = DeveloperError.throwInstantiationError;
/**
* Gets the maximum level-of-detail that can be requested. This function should
* not be called before {@link ImageryProvider#isReady} returns true.
+ * @memberof ImageryProvider
+ * @function
*
* @returns {Number} The maximum level, or undefined if there is no maximum level.
*
* @exception {DeveloperError} getMaximumLevel
must not be called before the imagery provider is ready.
*/
- ImageryProvider.prototype.getMaximumLevel = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.getMaximumLevel = DeveloperError.throwInstantiationError;
/**
* Gets the minimum level-of-detail that can be requested. This function should
@@ -183,18 +183,20 @@ define([
* enough that the number of tiles at the minimum level is small. An imagery
* provider with more than a few tiles at the minimum level will lead to
* rendering problems.
+ * @memberof ImageryProvider
+ * @function
*
* @returns {Number} The minimum level, or undefined if there is no minimum level.
*
* @exception {DeveloperError} getMinimumLevel
must not be called before the imagery provider is ready.
*/
- ImageryProvider.prototype.getMinimumLevel = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.getMinimumLevel = DeveloperError.throwInstantiationError;
/**
* Gets the tiling scheme used by this provider. This function should
* not be called before {@link ImageryProvider#isReady} returns true.
+ * @memberof ImageryProvider
+ * @function
*
* @returns {TilingScheme} The tiling scheme.
* @see WebMercatorTilingScheme
@@ -202,17 +204,15 @@ define([
*
* @exception {DeveloperError} getTilingScheme
must not be called before the imagery provider is ready.
*/
- ImageryProvider.prototype.getTilingScheme = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.getTilingScheme = DeveloperError.throwInstantiationError;
/**
* Gets the tile discard policy. If not undefined, the discard policy is responsible
* for filtering out "missing" tiles via its shouldDiscardImage function. If this function
* returns undefined, no tiles are filtered. This function should
* not be called before {@link ImageryProvider#isReady} returns true.
- *
* @memberof ImageryProvider
+ * @function
*
* @returns {TileDiscardPolicy} The discard policy.
*
@@ -221,52 +221,44 @@ define([
*
* @exception {DeveloperError} getTileDiscardPolicy
must not be called before the imagery provider is ready.
*/
- ImageryProvider.prototype.getTileDiscardPolicy = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.getTileDiscardPolicy = DeveloperError.throwInstantiationError;
/**
* Gets an event that is raised when the imagery provider encounters an asynchronous error. By subscribing
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
* are passed an instance of {@link TileProviderError}.
- *
* @memberof ImageryProvider
+ * @function
*
* @returns {Event} The event.
*/
- ImageryProvider.prototype.getErrorEvent = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.getErrorEvent = DeveloperError.throwInstantiationError;
/**
* Gets the credit to display when this imagery provider is active. Typically this is used to credit
* the source of the imagery. This function should not be called before {@link ImageryProvider#isReady} returns true.
- *
* @memberof ImageryProvider
+ * @function
*
* @returns {Credit} The credit, or undefined if no credit exists
*/
- ImageryProvider.prototype.getCredit = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.getCredit = DeveloperError.throwInstantiationError;
/**
* Gets the proxy used by this provider.
- *
* @memberof ImageryProvider
+ * @function
*
* @returns {Proxy} The proxy.
*
* @see DefaultProxy
*/
- ImageryProvider.prototype.getProxy = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.getProxy = DeveloperError.throwInstantiationError;
/**
* Gets the credits to be displayed when a given tile is displayed.
- *
* @memberof ImageryProvider
+ * @function
*
* @param {Number} x The tile X coordinate.
* @param {Number} y The tile Y coordinate.
@@ -276,15 +268,13 @@ define([
*
* @exception {DeveloperError} getTileCredits
must not be called before the imagery provider is ready.
*/
- ImageryProvider.prototype.getTileCredits = function(x, y, level) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.getTileCredits = DeveloperError.throwInstantiationError;
/**
* Requests the image for a given tile. This function should
* not be called before {@link ImageryProvider#isReady} returns true.
- *
* @memberof ImageryProvider
+ * @function
*
* @param {Number} x The tile X coordinate.
* @param {Number} y The tile Y coordinate.
@@ -297,15 +287,12 @@ define([
*
* @exception {DeveloperError} requestImage
must not be called before the imagery provider is ready.
*/
- ImageryProvider.prototype.requestImage = function(hostnames, hostnameIndex, x, y, level) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ ImageryProvider.prototype.requestImage = DeveloperError.throwInstantiationError;
/**
* Loads an image from a given URL. If the server referenced by the URL already has
* too many requests pending, this function will instead return undefined, indicating
* that the request should be retried later.
- *
* @memberof ImageryProvider
*
* @param url {String} The URL of the image.
diff --git a/Source/Scene/Label.js b/Source/Scene/Label.js
index 5226b11652fd..d74e2fdf5436 100644
--- a/Source/Scene/Label.js
+++ b/Source/Scene/Label.js
@@ -826,7 +826,7 @@ define([
* @see Label#setPixelOffset
*
* @example
- * console.log(l.computeScreenSpacePosition(scene.getContext(), scene.getFrameState()).toString());
+ * console.log(l.computeScreenSpacePosition(scene.context, scene.frameState).toString());
*/
Label.prototype.computeScreenSpacePosition = function(context, frameState) {
//>>includeStart('debug', pragmas.debug);
diff --git a/Source/Scene/LabelCollection.js b/Source/Scene/LabelCollection.js
index 5d5680b1fb4c..58e7068d3182 100644
--- a/Source/Scene/LabelCollection.js
+++ b/Source/Scene/LabelCollection.js
@@ -184,6 +184,7 @@ define([
billboard.setScale(label._scale);
billboard._pickIdThis = label;
billboard._id = label._id;
+ billboard._collection = label._labelCollection;
}
glyph.billboard.setImageIndex(glyphTextureInfo.index);
diff --git a/Source/Scene/Material.js b/Source/Scene/Material.js
index 87258f942c33..45bd534b2cc7 100644
--- a/Source/Scene/Material.js
+++ b/Source/Scene/Material.js
@@ -12,6 +12,7 @@ define([
'../Core/defineProperties',
'../Core/destroyObject',
'../Core/Cartesian2',
+ '../Core/isArray',
'../Core/Matrix2',
'../Core/Matrix3',
'../Core/Matrix4',
@@ -45,6 +46,7 @@ define([
defineProperties,
destroyObject,
Cartesian2,
+ isArray,
Matrix2,
Matrix3,
Matrix4,
@@ -867,7 +869,7 @@ define([
uniformType = 'sampler2D';
}
} else if (type === 'object') {
- if (Array.isArray(uniformValue)) {
+ if (isArray(uniformValue)) {
if (uniformValue.length === 4 || uniformValue.length === 9 || uniformValue.length === 16) {
uniformType = 'mat' + Math.sqrt(uniformValue.length);
}
diff --git a/Source/Scene/Moon.js b/Source/Scene/Moon.js
index ae9cf007f6da..30925e23fe2b 100644
--- a/Source/Scene/Moon.js
+++ b/Source/Scene/Moon.js
@@ -80,7 +80,7 @@ define([
this.onlySunLighting = defaultValue(options.onlySunLighting, true);
this._ellipsoidPrimitive = new EllipsoidPrimitive({
- radii : this.ellipsoid.getRadii(),
+ radii : this.ellipsoid.radii,
material : Material.fromType(Material.ImageType),
onlySunLighting : this.onlySunLighting,
_owner : this
diff --git a/Source/Scene/OrthographicFrustum.js b/Source/Scene/OrthographicFrustum.js
index 90085eecb9a4..84c67be7fbb8 100644
--- a/Source/Scene/OrthographicFrustum.js
+++ b/Source/Scene/OrthographicFrustum.js
@@ -29,7 +29,7 @@ define([
* @constructor
*
* @example
- * var maxRadii = ellipsoid.getMaximumRadius();
+ * var maxRadii = ellipsoid.maximumRadius;
*
* var frustum = new Cesium.OrthographicFrustum();
* frustum.right = maxRadii * Cesium.Math.PI;
@@ -129,8 +129,8 @@ define([
defineProperties(OrthographicFrustum.prototype, {
/**
- * The orthographic projection matrix computed from the view frustum.
- * @memberof OrthographicFrustum
+ * Gets the orthographic projection matrix computed from the view frustum.
+ * @memberof OrthographicFrustum.prototype
* @type {Matrix4}
*/
projectionMatrix : {
diff --git a/Source/Scene/PerformanceDisplay.js b/Source/Scene/PerformanceDisplay.js
index 5adf35f5c97f..03f4d99b640f 100644
--- a/Source/Scene/PerformanceDisplay.js
+++ b/Source/Scene/PerformanceDisplay.js
@@ -53,7 +53,7 @@ define([
display.style['background-color'] = this._backgroundColor;
display.style.font = this._font;
display.style.padding = '7px';
- display.style['border-radius']= '5px';
+ display.style['border-radius'] = '5px';
display.style.border = '1px solid #444';
this._container.appendChild(display);
@@ -98,7 +98,7 @@ define([
}
if (frameTime !== this._frameTime) {
- this._msText.nodeValue = frameTime + ' MS';
+ this._msText.nodeValue = frameTime.toFixed(2) + ' MS';
this._frameTime = frameTime;
}
diff --git a/Source/Scene/PerspectiveFrustum.js b/Source/Scene/PerspectiveFrustum.js
index 405201e6e297..f27d4f455256 100644
--- a/Source/Scene/PerspectiveFrustum.js
+++ b/Source/Scene/PerspectiveFrustum.js
@@ -106,8 +106,8 @@ define([
defineProperties(PerspectiveFrustum.prototype, {
/**
- * The perspective projection matrix computed from the view frustum.
- * @memberof PerspectiveFrustum
+ * Gets the perspective projection matrix computed from the view frustum.
+ * @memberof PerspectiveFrustum.prototype
* @type {Matrix4}
*
* @see PerspectiveFrustum#infiniteProjectionMatrix
diff --git a/Source/Scene/PerspectiveOffCenterFrustum.js b/Source/Scene/PerspectiveOffCenterFrustum.js
index 8506b6e83868..5d7948eb8cdd 100644
--- a/Source/Scene/PerspectiveOffCenterFrustum.js
+++ b/Source/Scene/PerspectiveOffCenterFrustum.js
@@ -134,8 +134,8 @@ define([
defineProperties(PerspectiveOffCenterFrustum.prototype, {
/**
- * The perspective projection matrix computed from the view frustum.
- * @memberof PerspectiveOffCenterFrustum
+ * Gets the perspective projection matrix computed from the view frustum.
+ * @memberof PerspectiveOffCenterFrustum.prototype
* @type {Matrix4}
*
* @see PerspectiveOffCenterFrustum#infiniteProjectionMatrix
@@ -148,8 +148,8 @@ define([
},
/**
- * The perspective projection matrix computed from the view frustum with an infinite far plane.
- * @memberof PerspectiveOffCenterFrustum
+ * Gets the perspective projection matrix computed from the view frustum with an infinite far plane.
+ * @memberof PerspectiveOffCenterFrustum.prototype
* @type {Matrix4}
*
* @see PerspectiveOffCenterFrustum#projectionMatrix
diff --git a/Source/Scene/Polyline.js b/Source/Scene/Polyline.js
index e2b83dae68c1..14eeea1bae41 100644
--- a/Source/Scene/Polyline.js
+++ b/Source/Scene/Polyline.js
@@ -19,8 +19,6 @@ define([
Material) {
"use strict";
- var EMPTY_OBJECT = {};
-
/**
* DOC_TBA
*
@@ -30,7 +28,7 @@ define([
* @demo Cesium Sandcastle Polyline Demo
*/
var Polyline = function(options, polylineCollection) {
- options = defaultValue(options, EMPTY_OBJECT);
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
this._show = defaultValue(options.show, true);
this._width = defaultValue(options.width, 1.0);
@@ -306,6 +304,7 @@ define([
if (!defined(this._pickId)) {
this._pickId = context.createPickId({
primitive : defaultValue(this._pickIdThis, this),
+ collection: this._polylineCollection,
id : this._id
});
}
diff --git a/Source/Scene/PolylineCollection.js b/Source/Scene/PolylineCollection.js
index 3baa7929662d..7d6040cac575 100644
--- a/Source/Scene/PolylineCollection.js
+++ b/Source/Scene/PolylineCollection.js
@@ -1398,13 +1398,27 @@ define([
return scratchSegments;
};
+ var scratchPositionsArray;
+ var scratchTexCoordArray;
+
PolylineBucket.prototype.writeUpdate = function(index, polyline, positionBuffer, texCoordExpandWidthAndShowBuffer) {
var mode = this.mode;
var positionsLength = polyline._actualLength;
if (positionsLength) {
index += this.getPolylineStartIndex(polyline);
- var positionArray = new Float32Array(6 * positionsLength * 3);
- var texCoordExpandWidthAndShowArray = new Float32Array(positionsLength * 4);
+
+ var positionArray = scratchPositionsArray;
+ var texCoordExpandWidthAndShowArray = scratchTexCoordArray;
+
+ var positionsArrayLength = 6 * positionsLength * 3;
+
+ if (!defined(positionArray) || positionArray.length < positionsArrayLength) {
+ positionArray = scratchPositionsArray = new Float32Array(positionsArrayLength);
+ texCoordExpandWidthAndShowArray = scratchTexCoordArray = new Float32Array(positionsLength * 4);
+ } else if (positionArray.length > positionsArrayLength) {
+ positionArray = new Float32Array(positionArray.buffer, 0, positionsArrayLength);
+ texCoordExpandWidthAndShowArray = new Float32Array(texCoordExpandWidthAndShowArray.buffer, 0, positionsLength * 4);
+ }
var positionIndex = 0;
var texCoordExpandWidthAndShowIndex = 0;
diff --git a/Source/Scene/Primitive.js b/Source/Scene/Primitive.js
index 12cde039a10c..776b984ec3ec 100644
--- a/Source/Scene/Primitive.js
+++ b/Source/Scene/Primitive.js
@@ -16,6 +16,7 @@ define([
'../Core/TaskProcessor',
'../Core/GeographicProjection',
'../Core/clone',
+ '../Core/isArray',
'../Renderer/BufferUsage',
'../Renderer/VertexLayout',
'../Renderer/DrawCommand',
@@ -43,6 +44,7 @@ define([
TaskProcessor,
GeographicProjection,
clone,
+ isArray,
BufferUsage,
VertexLayout,
DrawCommand,
@@ -110,7 +112,7 @@ define([
* material : Cesium.Material.fromType('Checkerboard')
* })
* });
- * scene.getPrimitives().add(primitive);
+ * scene.primitives.add(primitive);
*
* // 2. Draw different instances each with a unique color
* var extentInstance = new Cesium.GeometryInstance({
@@ -143,7 +145,7 @@ define([
* geometryInstances : [extentInstance, ellipsoidInstance],
* appearance : new Cesium.PerInstanceColorAppearance()
* });
- * scene.getPrimitives().add(primitive);
+ * scene.primitives.add(primitive);
*
* // 3. Create the geometry on the main thread.
* var primitive = new Cesium.Primitive({
@@ -161,7 +163,7 @@ define([
* }),
* appearance : new Cesium.PerInstanceColorAppearance()
* });
- * scene.getPrimitives().add(primitive);
+ * scene.primitives.add(primitive);
*
* @see GeometryInstance
* @see Appearance
@@ -523,7 +525,7 @@ define([
Primitive.prototype.update = function(context, frameState, commandList) {
if (!this.show ||
((!defined(this.geometryInstances)) && (this._va.length === 0)) ||
- (defined(this.geometryInstances) && Array.isArray(this.geometryInstances) && this.geometryInstances.length === 0) ||
+ (defined(this.geometryInstances) && isArray(this.geometryInstances) && this.geometryInstances.length === 0) ||
(!defined(this.appearance)) ||
(frameState.mode !== SceneMode.SCENE3D && this.allow3DOnly) ||
(!frameState.passes.render && !frameState.passes.pick)) {
@@ -554,7 +556,7 @@ define([
if (this._state === PrimitiveState.FAILED) {
throw this._error;
} else if (this._state === PrimitiveState.READY) {
- instances = (Array.isArray(this.geometryInstances)) ? this.geometryInstances : [this.geometryInstances];
+ instances = (isArray(this.geometryInstances)) ? this.geometryInstances : [this.geometryInstances];
length = instances.length;
var promises = [];
@@ -587,7 +589,7 @@ define([
that._state = PrimitiveState.FAILED;
});
} else if (this._state === PrimitiveState.CREATED) {
- instances = (Array.isArray(this.geometryInstances)) ? this.geometryInstances : [this.geometryInstances];
+ instances = (isArray(this.geometryInstances)) ? this.geometryInstances : [this.geometryInstances];
clonedInstances = new Array(instances.length);
geometries = this._geometries.concat(this._createdGeometries);
@@ -633,7 +635,7 @@ define([
});
}
} else {
- instances = (Array.isArray(this.geometryInstances)) ? this.geometryInstances : [this.geometryInstances];
+ instances = (isArray(this.geometryInstances)) ? this.geometryInstances : [this.geometryInstances];
length = instances.length;
geometries = this._createdGeometries;
@@ -721,7 +723,7 @@ define([
this.geometryInstances = undefined;
}
- this._geomtries = undefined;
+ this._geometries = undefined;
this._createdGeometries = undefined;
this._state = PrimitiveState.COMPLETE;
}
diff --git a/Source/Scene/QuantizedMeshTerrainData.js b/Source/Scene/QuantizedMeshTerrainData.js
index 3efbc24b8753..832d8f4e765c 100644
--- a/Source/Scene/QuantizedMeshTerrainData.js
+++ b/Source/Scene/QuantizedMeshTerrainData.js
@@ -7,7 +7,6 @@ define([
'../Core/Cartographic',
'../Core/DeveloperError',
'../Core/Ellipsoid',
- '../Core/EllipsoidalOccluder',
'../Core/HeightmapTessellator',
'../Core/Intersections2D',
'../Core/Math',
@@ -25,7 +24,6 @@ define([
Cartographic,
DeveloperError,
Ellipsoid,
- EllipsoidalOccluder,
HeightmapTessellator,
Intersections2D,
CesiumMath,
diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js
index 0ec545ffba60..8babd89bc297 100644
--- a/Source/Scene/Scene.js
+++ b/Source/Scene/Scene.js
@@ -4,6 +4,7 @@ define([
'../Core/Color',
'../Core/defaultValue',
'../Core/defined',
+ '../Core/defineProperties',
'../Core/destroyObject',
'../Core/DeveloperError',
'../Core/GeographicProjection',
@@ -48,6 +49,7 @@ define([
Color,
defaultValue,
defined,
+ defineProperties,
destroyObject,
DeveloperError,
GeographicProjection,
@@ -344,72 +346,86 @@ define([
this.initializeFrame();
};
- /**
- * DOC_TBA
- * @memberof Scene
- */
- Scene.prototype.getCanvas = function() {
- return this._canvas;
- };
-
- /**
- * DOC_TBA
- * @memberof Scene
- */
- Scene.prototype.getContext = function() {
- return this._context;
- };
+ defineProperties(Scene.prototype, {
+ /**
+ * Gets the canvas element to which this scene is bound.
+ * @memberof Scene.prototype
+ * @type {Element}
+ */
+ canvas : {
+ get : function() {
+ return this._canvas;
+ }
+ },
- /**
- * DOC_TBA
- * @memberof Scene
- */
- Scene.prototype.getPrimitives = function() {
- return this._primitives;
- };
+ /**
+ * Gets the context.
+ * @memberof Scene.prototype
+ * @type {Context}
+ */
+ context : {
+ get : function() {
+ return this._context;
+ }
+ },
- /**
- * DOC_TBA
- * @memberof Scene
- */
- Scene.prototype.getCamera = function() {
- return this._camera;
- };
- // TODO: setCamera
+ /**
+ * Gets the collection of primitives.
+ * @memberof Scene.prototype
+ * @type {CompositePrimitive}
+ */
+ primitives : {
+ get : function() {
+ return this._primitives;
+ }
+ },
- /**
- * DOC_TBA
- * @memberof Scene
- */
- Scene.prototype.getScreenSpaceCameraController = function() {
- return this._screenSpaceCameraController;
- };
+ /**
+ * Gets the camera.
+ * @memberof Scene.prototype
+ * @type {Camera}
+ */
+ camera : {
+ get : function() {
+ return this._camera;
+ }
+ },
+ // TODO: setCamera
- /**
- * DOC_TBA
- * @memberof Scene
- */
- Scene.prototype.getUniformState = function() {
- return this._context.getUniformState();
- };
+ /**
+ * Gets the controller for camera input handling.
+ * @memberof Scene.prototype
+ * @type {ScreenSpaceCameraController}
+ */
+ screenSpaceCameraController : {
+ get : function() {
+ return this._screenSpaceCameraController;
+ }
+ },
- /**
- * Gets state information about the current scene. If called outside of a primitive's update
- * function, the previous frame's state is returned.
- *
- * @memberof Scene
- */
- Scene.prototype.getFrameState = function() {
- return this._frameState;
- };
+ /**
+ * Gets state information about the current scene. If called outside of a primitive's update
+ * function, the previous frame's state is returned.
+ * @memberof Scene.prototype
+ * @type {FrameState}
+ */
+ frameState : {
+ get: function() {
+ return this._frameState;
+ }
+ },
- /**
- * DOC_TBA
- * @memberof Scene
- */
- Scene.prototype.getAnimations = function() {
- return this._animations;
- };
+ /**
+ * Gets the collection of animations taking place in the scene.
+ * @memberof Scene.prototype
+ * @type {AnimationCollection}
+ */
+ animations : {
+ get : function() {
+ return this._animations;
+ }
+ }
+ });
var scratchOccluderBoundingSphere = new BoundingSphere();
var scratchOccluder;
@@ -417,10 +433,10 @@ define([
function getOccluder(scene) {
// TODO: The occluder is the top-level central body. When we add
// support for multiple central bodies, this should be the closest one.
- var cb = scene._primitives.getCentralBody();
+ var cb = scene._primitives.centralBody;
if (scene.mode === SceneMode.SCENE3D && defined(cb)) {
- var ellipsoid = cb.getEllipsoid();
- scratchOccluderBoundingSphere.radius = ellipsoid.getMinimumRadius();
+ var ellipsoid = cb.ellipsoid;
+ scratchOccluderBoundingSphere.radius = ellipsoid.minimumRadius;
scratchOccluder = Occluder.fromBoundingSphere(scratchOccluderBoundingSphere, scene._camera.positionWC, scratchOccluder);
return scratchOccluder;
}
@@ -896,7 +912,7 @@ define([
time = new JulianDate();
}
- var us = this.getUniformState();
+ var us = this.context.getUniformState();
var frameState = this._frameState;
var frameNumber = CesiumMath.incrementWrap(frameState.frameNumber, 15000000.0, 1.0);
@@ -1060,7 +1076,7 @@ define([
//>>includeEnd('debug');
var context = this._context;
- var us = this.getUniformState();
+ var us = this.context.getUniformState();
var frameState = this._frameState;
var drawingBufferPosition = SceneTransforms.transformWindowToDrawingBuffer(context, windowPosition, scratchPosition);
diff --git a/Source/Scene/SceneTransforms.js b/Source/Scene/SceneTransforms.js
index 39f7a048e648..8e145eb3298e 100644
--- a/Source/Scene/SceneTransforms.js
+++ b/Source/Scene/SceneTransforms.js
@@ -49,9 +49,9 @@ define([
* @example
* // Output the window position of longitude/latitude (0, 0) every time the mouse moves.
* var scene = widget.scene;
- * var ellipsoid = widget.centralBody.getEllipsoid();
+ * var ellipsoid = widget.centralBody.ellipsoid;
* var position = ellipsoid.cartographicToCartesian(new Cesium.Cartographic(0.0, 0.0));
- * var handler = new Cesium.ScreenSpaceEventHandler(scene.getCanvas());
+ * var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
* handler.setInputAction(function(movement) {
* console.log(Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, position));
* }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
@@ -67,7 +67,7 @@ define([
//>>includeEnd('debug');
// Transform for 3D, 2D, or Columbus view
- SceneTransforms.computeActualWgs84Position(scene.getFrameState(), position, actualPosition);
+ SceneTransforms.computeActualWgs84Position(scene.frameState, position, actualPosition);
if (!defined(actualPosition)) {
result = undefined;
@@ -75,11 +75,11 @@ define([
}
// View-projection matrix to transform from world coordinates to clip coordinates
- var camera = scene.getCamera();
+ var camera = scene.camera;
viewProjectionScratch = Matrix4.multiply(camera.frustum.projectionMatrix, camera.viewMatrix, viewProjectionScratch);
Matrix4.multiplyByVector(viewProjectionScratch, actualPosition, positionCC);
- return SceneTransforms.clipToWindowCoordinates(scene.getContext(), positionCC, result);
+ return SceneTransforms.clipToWindowCoordinates(scene.context, positionCC, result);
};
/**
@@ -97,9 +97,9 @@ define([
* @example
* // Output the window position of longitude/latitude (0, 0) every time the mouse moves.
* var scene = widget.scene;
- * var ellipsoid = widget.centralBody.getEllipsoid();
+ * var ellipsoid = widget.centralBody.ellipsoid;
* var position = ellipsoid.cartographicToCartesian(new Cesium.Cartographic(0.0, 0.0));
- * var handler = new Cesium.ScreenSpaceEventHandler(scene.getCanvas());
+ * var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
* handler.setInputAction(function(movement) {
* console.log(Cesium.SceneTransforms.wgs84ToWindowCoordinates(scene, position));
* }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
@@ -116,17 +116,17 @@ define([
//>>includeEnd('debug');
// Transform for 3D, 2D, or Columbus view
- SceneTransforms.computeActualWgs84Position(scene.getFrameState(), position, actualPosition);
+ SceneTransforms.computeActualWgs84Position(scene.frameState, position, actualPosition);
if (!defined(actualPosition)) {
return undefined;
}
// View-projection matrix to transform from world coordinates to clip coordinates
- var viewProjection = scene.getUniformState().getViewProjection();
+ var viewProjection = scene.context.getUniformState().getViewProjection();
Matrix4.multiplyByVector(viewProjection, Cartesian4.fromElements(actualPosition.x, actualPosition.y, actualPosition.z, 1, positionCC), positionCC);
- return SceneTransforms.clipToDrawingBufferCoordinates(scene.getContext(), positionCC, result);
+ return SceneTransforms.clipToDrawingBufferCoordinates(scene.context, positionCC, result);
};
var projectedPosition = new Cartesian3();
diff --git a/Source/Scene/SceneTransitioner.js b/Source/Scene/SceneTransitioner.js
index 8d188688909e..0c3b6ecacdc8 100644
--- a/Source/Scene/SceneTransitioner.js
+++ b/Source/Scene/SceneTransitioner.js
@@ -90,10 +90,10 @@ define([
this._scene = scene;
this._ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);
- var context = scene.getContext();
+ var context = scene.context;
// Position camera and size frustum so the entire 2D map is visible
- var maxRadii = this._ellipsoid.getMaximumRadius();
+ var maxRadii = this._ellipsoid.maximumRadius;
var position = new Cartesian3(0.0, 0.0, 2.0 * maxRadii);
var direction = Cartesian3.normalize(Cartesian3.negate(position));
var up = Cartesian3.UNIT_Y;
@@ -368,7 +368,7 @@ define([
function createMorphHandler(transitioner, completeMorphFunction) {
if (transitioner.completeMorphOnUserInput) {
- transitioner._morphHandler = new ScreenSpaceEventHandler(transitioner._scene.getCanvas());
+ transitioner._morphHandler = new ScreenSpaceEventHandler(transitioner._scene.canvas);
var completeMorph = function() {
transitioner._morphCancelled = true;
@@ -384,7 +384,7 @@ define([
}
function destroyMorphHandler(transitioner) {
- var animations = transitioner._scene.getAnimations();
+ var animations = transitioner._scene.animations;
for ( var i = 0; i < transitioner._currentAnimations.length; ++i) {
animations.remove(transitioner._currentAnimations[i]);
}
@@ -395,14 +395,14 @@ define([
function morphFromColumbusViewTo3D(transitioner, duration, onComplete) {
var scene = transitioner._scene;
- var camera = scene.getCamera();
+ var camera = scene.camera;
setCameraTransform(camera, Matrix4.IDENTITY);
var startPos = camera.position;
var startDir = camera.direction;
var startUp = camera.up;
- var maxRadii = transitioner._ellipsoid.getMaximumRadius();
+ var maxRadii = transitioner._ellipsoid.maximumRadius;
var endPos = transitioner._ellipsoid.cartographicToCartesian(new Cartographic(0.0, 0.0, 10.0));
endPos = Cartesian3.multiplyByScalar(Cartesian3.normalize(endPos), 2.0 * maxRadii);
var endDir = Cartesian3.normalize(Cartesian3.subtract(Cartesian3.ZERO, endPos));
@@ -416,7 +416,7 @@ define([
camera.right = Cartesian3.cross(camera.direction, camera.up);
};
- var animation = scene.getAnimations().add({
+ var animation = scene.animations.add({
duration : duration,
easingFunction : Tween.Easing.Quartic.Out,
startValue : {
@@ -435,7 +435,7 @@ define([
function morphFrom2DTo3D(transitioner, duration, onComplete) {
duration = duration * 0.5;
- var camera = transitioner._scene.getCamera();
+ var camera = transitioner._scene.camera;
morphOrthographicToPerspective(transitioner, duration, function() {
camera.frustum = transitioner._cameraCV.frustum.clone();
@@ -451,7 +451,7 @@ define([
function morphPerspectiveToOrthographic(transitioner, duration, onComplete) {
var scene = transitioner._scene;
- var camera = scene.getCamera();
+ var camera = scene.camera;
var startPos = camera.position;
var startFOVy = camera.frustum.fovy;
@@ -466,7 +466,7 @@ define([
camera.position = Cartesian3.multiplyByScalar(Cartesian3.normalize(camera.position), distance);
};
- var animation = scene.getAnimations().add({
+ var animation = scene.animations.add({
duration : duration,
easingFunction : Tween.Easing.Quartic.Out,
startValue : {
@@ -486,8 +486,8 @@ define([
function morphFromColumbusViewTo2D(transitioner, duration, onComplete) {
var scene = transitioner._scene;
- var camera = scene.getCamera();
- var maxRadii = transitioner._ellipsoid.getMaximumRadius();
+ var camera = scene.camera;
+ var maxRadii = transitioner._ellipsoid.maximumRadius;
setCameraTransform(camera, transitioner._cameraCV.transform);
@@ -511,7 +511,7 @@ define([
};
duration = duration * 0.5;
- var animation = scene.getAnimations().add({
+ var animation = scene.animations.add({
duration : duration,
easingFunction : Tween.Easing.Quartic.Out,
startValue : {
@@ -531,7 +531,7 @@ define([
function morphFrom3DTo2D(transitioner, duration, onComplete) {
duration = duration * 0.5;
- var maxRadii = transitioner._ellipsoid.getMaximumRadius();
+ var maxRadii = transitioner._ellipsoid.maximumRadius;
var tanPhi = Math.tan(transitioner._camera3D.frustum.fovy * 0.5);
var tanTheta = transitioner._camera3D.frustum.aspectRatio * tanPhi;
@@ -550,8 +550,8 @@ define([
function morphOrthographicToPerspective(transitioner, duration, onComplete) {
var scene = transitioner._scene;
- var camera = scene.getCamera();
- var maxRadii = transitioner._ellipsoid.getMaximumRadius();
+ var camera = scene.camera;
+ var maxRadii = transitioner._ellipsoid.maximumRadius;
var tanPhi = Math.tan(transitioner._cameraCV.frustum.fovy * 0.5);
var tanTheta = transitioner._cameraCV.frustum.aspectRatio * tanPhi;
@@ -598,7 +598,7 @@ define([
}
}
- var animation = scene.getAnimations().add({
+ var animation = scene.animations.add({
easingFunction : Tween.Easing.Quartic.Out,
duration : partialDuration,
startValue : {
@@ -618,7 +618,7 @@ define([
function morphFrom2DToColumbusView(transitioner, duration, onComplete) {
var scene = transitioner._scene;
- var camera = scene.getCamera();
+ var camera = scene.camera;
duration = duration * 0.5;
@@ -638,7 +638,7 @@ define([
camera.right = Cartesian3.cross(camera.direction, camera.up);
};
- var animation = scene.getAnimations().add({
+ var animation = scene.animations.add({
duration : duration,
easingFunction : Tween.Easing.Quartic.Out,
startValue : {
@@ -662,7 +662,7 @@ define([
function morphFrom3DToColumbusView(transitioner, duration, endCamera, onComplete) {
var scene = transitioner._scene;
- var camera = scene.getCamera();
+ var camera = scene.camera;
setCameraTransform(camera, transitioner._cameraCV.transform);
var startPos = Cartesian3.clone(camera.position);
@@ -680,7 +680,7 @@ define([
camera.right = Cartesian3.cross(camera.direction, camera.up);
};
- var animation = scene.getAnimations().add({
+ var animation = scene.animations.add({
duration : duration,
easingFunction : Tween.Easing.Quartic.Out,
startValue : {
@@ -715,14 +715,14 @@ define([
};
}
- var animation = scene.getAnimations().addProperty(scene, 'morphTime', start, stop, template);
+ var animation = scene.animations.addProperty(scene, 'morphTime', start, stop, template);
transitioner._currentAnimations.push(animation);
}
function updateFrustums(transitioner) {
var scene = transitioner._scene;
- var context = scene.getContext();
+ var context = scene.context;
var ratio = context.getDrawingBufferHeight() / context.getDrawingBufferWidth();
var frustum = transitioner._camera2D.frustum;
@@ -737,7 +737,7 @@ define([
frustum = transitioner._camera3D.frustum;
frustum.aspectRatio = ratio;
- var camera = scene.getCamera();
+ var camera = scene.camera;
switch (scene.mode) {
case SceneMode.SCENE3D:
camera.frustum = transitioner._camera3D.frustum.clone();
@@ -759,7 +759,7 @@ define([
destroyMorphHandler(transitioner);
updateFrustums(transitioner);
- var camera = scene.getCamera();
+ var camera = scene.camera;
camera.transform = Matrix4.clone(Matrix4.IDENTITY);
if (transitioner._previousMode !== SceneMode.MORPHING || transitioner._morphCancelled) {
@@ -786,7 +786,7 @@ define([
destroyMorphHandler(transitioner);
updateFrustums(transitioner);
- var camera = scene.getCamera();
+ var camera = scene.camera;
camera.transform = Matrix4.clone(transitioner._camera2D.transform);
// TODO: Match incoming columbus-view or 3D position
@@ -808,7 +808,7 @@ define([
destroyMorphHandler(transitioner);
updateFrustums(transitioner);
- var camera = scene.getCamera();
+ var camera = scene.camera;
camera.transform = Matrix4.clone(transitioner._cameraCV.transform);
if (transitioner._previousModeMode !== SceneMode.MORPHING || transitioner._morphCancelled) {
diff --git a/Source/Scene/ScreenSpaceCameraController.js b/Source/Scene/ScreenSpaceCameraController.js
index b93ff0fd2730..3d20a1455547 100644
--- a/Source/Scene/ScreenSpaceCameraController.js
+++ b/Source/Scene/ScreenSpaceCameraController.js
@@ -11,6 +11,7 @@ define([
'../Core/KeyboardEventModifier',
'../Core/FAR',
'../Core/IntersectionTests',
+ '../Core/isArray',
'../Core/Math',
'../Core/Matrix4',
'../Core/Ray',
@@ -32,6 +33,7 @@ define([
KeyboardEventModifier,
FAR,
IntersectionTests,
+ isArray,
CesiumMath,
Matrix4,
Ray,
@@ -247,7 +249,7 @@ define([
this._horizontalRotationAxis = undefined;
// Constants, Make any of these public?
- var radius = this._ellipsoid.getMaximumRadius();
+ var radius = this._ellipsoid.maximumRadius;
this._zoomFactor = 5.0;
this._rotateFactor = 1.0 / radius;
this._rotateRateRangeAdjustment = radius;
@@ -274,7 +276,7 @@ define([
*/
ScreenSpaceCameraController.prototype.setEllipsoid = function(ellipsoid) {
ellipsoid = ellipsoid || Ellipsoid.WGS84;
- var radius = ellipsoid.getMaximumRadius();
+ var radius = ellipsoid.maximumRadius;
this._ellipsoid = ellipsoid;
this._rotateFactor = 1.0 / radius;
this._rotateRateRangeAdjustment = radius;
@@ -368,7 +370,7 @@ define([
var aggregator = controller._aggregator;
- if (!Array.isArray(eventTypes)) {
+ if (!isArray(eventTypes)) {
scratchEventTypeArray[0] = eventTypes;
eventTypes = scratchEventTypeArray;
}
diff --git a/Source/Scene/SkyAtmosphere.js b/Source/Scene/SkyAtmosphere.js
index 5bf106de35f5..3d2fc0d99b91 100644
--- a/Source/Scene/SkyAtmosphere.js
+++ b/Source/Scene/SkyAtmosphere.js
@@ -72,8 +72,8 @@ define([
this._fCameraHeight = undefined;
this._fCameraHeight2 = undefined;
- this._outerRadius = Cartesian3.getMaximumComponent(Cartesian3.multiplyByScalar(ellipsoid.getRadii(), 1.025));
- var innerRadius = ellipsoid.getMaximumRadius();
+ this._outerRadius = Cartesian3.getMaximumComponent(Cartesian3.multiplyByScalar(ellipsoid.radii, 1.025));
+ var innerRadius = ellipsoid.maximumRadius;
var rayleighScaleDepth = 0.25;
var that = this;
@@ -139,7 +139,7 @@ define([
if (!defined(command.vertexArray)) {
var geometry = EllipsoidGeometry.createGeometry(new EllipsoidGeometry({
- radii : Cartesian3.multiplyByScalar(this._ellipsoid.getRadii(), 1.025),
+ radii : Cartesian3.multiplyByScalar(this._ellipsoid.radii, 1.025),
slicePartitions : 256,
stackPartitions : 256
}));
diff --git a/Source/Scene/TerrainData.js b/Source/Scene/TerrainData.js
index b6b130d94f95..45c05974488b 100644
--- a/Source/Scene/TerrainData.js
+++ b/Source/Scene/TerrainData.js
@@ -16,13 +16,13 @@ define([
* @see QuantizedMeshTerrainData
*/
var TerrainData = function TerrainData() {
- throw new DeveloperError('This type should not be instantiated directly.');
+ DeveloperError.throwInstantiationError();
};
/**
* Computes the terrain height at a specified longitude and latitude.
- *
* @memberof TerrainData
+ * @function
*
* @param {Extent} extent The extent covered by this terrain data.
* @param {Number} longitude The longitude in radians.
@@ -31,17 +31,15 @@ define([
* is outside the extent, this method will extrapolate the height, which is likely to be wildly
* incorrect for positions far outside the extent.
*/
- TerrainData.prototype.interpolateHeight = function(extent, longitude, latitude) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainData.prototype.interpolateHeight = DeveloperError.throwInstantiationError;
/**
* Determines if a given child tile is available, based on the
* {@link TerrainData#childTileMask}. The given child tile coordinates are assumed
* to be one of the four children of this tile. If non-child tile coordinates are
* given, the availability of the southeast child tile is returned.
- *
* @memberof TerrainData
+ * @function
*
* @param {Number} thisX The tile X coordinate of this (the parent) tile.
* @param {Number} thisY The tile Y coordinate of this (the parent) tile.
@@ -49,27 +47,23 @@ define([
* @param {Number} childY The tile Y coordinate of the child tile to check for availability.
* @returns {Boolean} True if the child tile is available; otherwise, false.
*/
- TerrainData.prototype.isChildAvailable = function(thisX, thisY, childX, childY) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainData.prototype.isChildAvailable = DeveloperError.throwInstantiationError;
/**
* Gets the water mask included in this terrain data, if any. A water mask is a rectangular
* Uint8Array or image where a value of 255 indicates water and a value of 0 indicates land.
* Values in between 0 and 255 are allowed as well to smoothly blend between land and water.
- *
- * @memberof TerrainData
+ * @memberof TerrainData
+ * @function
*
* @returns {Uint8Array|Image|Canvas} The water mask, or undefined if no water mask is associated with this terrain data.
*/
- TerrainData.prototype.getWaterMask = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainData.prototype.getWaterMask = DeveloperError.throwInstantiationError;
/**
* Creates a {@link TerrainMesh} from this terrain data.
- *
* @memberof TerrainData
+ * @function
*
* @param {TilingScheme} tilingScheme The tiling scheme to which this tile belongs.
* @param {Number} x The X coordinate of the tile for which to create the terrain data.
@@ -79,14 +73,12 @@ define([
* asynchronous mesh creations are already in progress and the operation should
* be retried later.
*/
- TerrainData.prototype.createMesh = function(tilingScheme, x, y, level) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainData.prototype.createMesh = DeveloperError.throwInstantiationError;
/**
* Upsamples this terrain data for use by a descendant tile.
- *
* @memberof TerrainData
+ * @function
*
* @param {TilingScheme} tilingScheme The tiling scheme of this terrain data.
* @param {Number} thisX The X coordinate of this tile in the tiling scheme.
@@ -100,23 +92,19 @@ define([
* or undefined if too many asynchronous upsample operations are in progress and the request has been
* deferred.
*/
- TerrainData.prototype.upsample = function(tilingScheme, thisX, thisY, thisLevel, descendantX, descendantY, descendantLevel) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainData.prototype.upsample = DeveloperError.throwInstantiationError;
/**
* Gets a value indicating whether or not this terrain data was created by upsampling lower resolution
* terrain data. If this value is false, the data was obtained from some other source, such
* as by downloading it from a remote server. This method should return true for instances
* returned from a call to {@link TerrainData#upsample}.
- *
* @memberof TerrainData
+ * @function
*
* @returns {Boolean} True if this instance was created by upsampling; otherwise, false.
*/
- TerrainData.prototype.wasCreatedByUpsampling = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainData.prototype.wasCreatedByUpsampling = DeveloperError.throwInstantiationError;
return TerrainData;
});
\ No newline at end of file
diff --git a/Source/Scene/TerrainProvider.js b/Source/Scene/TerrainProvider.js
index 1d488c6a01f9..96b956d884f2 100644
--- a/Source/Scene/TerrainProvider.js
+++ b/Source/Scene/TerrainProvider.js
@@ -26,7 +26,7 @@ define([
* @see ArcGisImageServerTerrainProvider
*/
var TerrainProvider = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
+ DeveloperError.throwInstantiationError();
};
/**
@@ -177,15 +177,15 @@ define([
* @returns {Number} An estimated geometric error.
*/
TerrainProvider.getEstimatedLevelZeroGeometricErrorForAHeightmap = function(ellipsoid, tileImageWidth, numberOfTilesAtLevelZero) {
- return ellipsoid.getMaximumRadius() * 2 * Math.PI * TerrainProvider.heightmapTerrainQuality / (tileImageWidth * numberOfTilesAtLevelZero);
+ return ellipsoid.maximumRadius * 2 * Math.PI * TerrainProvider.heightmapTerrainQuality / (tileImageWidth * numberOfTilesAtLevelZero);
};
/**
* Requests the geometry for a given tile. This function should not be called before
* {@link TerrainProvider#isReady} returns true. The result must include terrain data and
* may optionally include a water mask and an indication of which child tiles are available.
- *
* @memberof TerrainProvider
+ * @function
*
* @param {Number} x The X coordinate of the tile for which to request geometry.
* @param {Number} y The Y coordinate of the tile for which to request geometry.
@@ -197,53 +197,45 @@ define([
* returns undefined instead of a promise, it is an indication that too many requests are already
* pending and the request will be retried later.
*/
- TerrainProvider.prototype.requestTileGeometry = function(x, y, level, throttleRequests) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainProvider.prototype.requestTileGeometry = DeveloperError.throwInstantiationError;
/**
* Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
* are passed an instance of {@link TileProviderError}.
- *
* @memberof TerrainProvider
+ * @function
*
* @returns {Event} The event.
*/
- TerrainProvider.prototype.getErrorEvent = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainProvider.prototype.getErrorEvent = DeveloperError.throwInstantiationError;
/**
* Gets the maximum geometric error allowed in a tile at a given level. This function should not be
* called before {@link TerrainProvider#isReady} returns true.
- *
* @memberof TerrainProvider
+ * @function
*
* @param {Number} level The tile level for which to get the maximum geometric error.
* @returns {Number} The maximum geometric error.
*/
- TerrainProvider.prototype.getLevelMaximumGeometricError = function(level) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainProvider.prototype.getLevelMaximumGeometricError = DeveloperError.throwInstantiationError;
/**
* Gets the credit to display when this terrain provider is active. Typically this is used to credit
* the source of the terrain. This function should not be called before {@link TerrainProvider#isReady} returns true.
- *
* @memberof TerrainProvider
+ * @function
*
* @returns {Credit} The credit, or undefined if no credit exists
*/
- TerrainProvider.prototype.getCredit = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainProvider.prototype.getCredit = DeveloperError.throwInstantiationError;
/**
* Gets the tiling scheme used by this provider. This function should
* not be called before {@link TerrainProvider#isReady} returns true.
- *
* @memberof TerrainProvider
+ * @function
*
* @returns {GeographicTilingScheme} The tiling scheme.
* @see WebMercatorTilingScheme
@@ -251,34 +243,28 @@ define([
*
* @exception {DeveloperError} getTilingScheme
must not be called before the terrain provider is ready.
*/
- TerrainProvider.prototype.getTilingScheme = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainProvider.prototype.getTilingScheme = DeveloperError.throwInstantiationError;
/**
* Gets a value indicating whether or not the provider includes a water mask. The water mask
* indicates which areas of the globe are water rather than land, so they can be rendered
* as a reflective surface with animated waves. This function should not be
* called before {@link TerrainProvider#isReady} returns true.
- *
* @memberof TerrainProvider
+ * @function
*
* @returns {Boolean} True if the provider has a water mask; otherwise, false.
*/
- TerrainProvider.prototype.hasWaterMask = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainProvider.prototype.hasWaterMask = DeveloperError.throwInstantiationError;
/**
* Gets a value indicating whether or not the provider is ready for use.
- *
* @memberof TerrainProvider
+ * @function
*
* @returns {Boolean} True if the provider is ready to use; otherwise, false.
*/
- TerrainProvider.prototype.isReady = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TerrainProvider.prototype.isReady = DeveloperError.throwInstantiationError;
return TerrainProvider;
});
\ No newline at end of file
diff --git a/Source/Scene/TileDiscardPolicy.js b/Source/Scene/TileDiscardPolicy.js
index 9c40ec514a75..68f76d454f32 100644
--- a/Source/Scene/TileDiscardPolicy.js
+++ b/Source/Scene/TileDiscardPolicy.js
@@ -16,27 +16,27 @@ define([
* @see NeverTileDiscardPolicy
*/
var TileDiscardPolicy = function(description) {
- throw new DeveloperError('This type should not be instantiated directly.');
+ DeveloperError.throwInstantiationError();
};
/**
* Determines if the discard policy is ready to process images.
+ * @memberof TileDiscardPolicy
+ * @function
* @returns {Boolean} True if the discard policy is ready to process images; otherwise, false.
*/
- TileDiscardPolicy.prototype.isReady = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TileDiscardPolicy.prototype.isReady = DeveloperError.throwInstantiationError;
/**
* Given a tile image, decide whether to discard that image.
+ * @memberof TileDiscardPolicy
+ * @function
*
* @param {Image|Promise} image An image, or a promise that will resolve to an image.
*
* @returns {Boolean} A promise that will resolve to true if the tile should be discarded.
*/
- TileDiscardPolicy.prototype.shouldDiscardImage = function(image) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TileDiscardPolicy.prototype.shouldDiscardImage = DeveloperError.throwInstantiationError;
return TileDiscardPolicy;
});
\ No newline at end of file
diff --git a/Source/Scene/TilingScheme.js b/Source/Scene/TilingScheme.js
index 73e6d3007f3e..db7bae211230 100644
--- a/Source/Scene/TilingScheme.js
+++ b/Source/Scene/TilingScheme.js
@@ -28,78 +28,66 @@ define([
/**
* Gets the ellipsoid that is tiled by this tiling scheme.
- *
* @memberof TilingScheme
+ * @function
*
* @returns {Ellipsoid} The ellipsoid.
*/
- TilingScheme.prototype.getEllipsoid = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TilingScheme.prototype.getEllipsoid = DeveloperError.throwInstantiationError;
/**
* Gets the extent, in radians, covered by this tiling scheme.
- *
* @memberof TilingScheme
+ * @function
*
* @returns {Extent} The extent.
*/
- TilingScheme.prototype.getExtent = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TilingScheme.prototype.getExtent = DeveloperError.throwInstantiationError;
/**
* Gets the map projection used by this tiling scheme.
- *
* @memberof TilingScheme
+ * @function
*
* @returns {Projection} The map projection.
*/
- TilingScheme.prototype.getProjection = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TilingScheme.prototype.getProjection = DeveloperError.throwInstantiationError;
/**
* Gets the total number of tiles in the X direction at a specified level-of-detail.
- *
* @memberof TilingScheme
+ * @function
*
* @param {Number} level The level-of-detail.
* @returns {Number} The number of tiles in the X direction at the given level.
*/
- TilingScheme.prototype.getNumberOfXTilesAtLevel = function(level) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TilingScheme.prototype.getNumberOfXTilesAtLevel = DeveloperError.throwInstantiationError;
/**
* Gets the total number of tiles in the Y direction at a specified level-of-detail.
- *
* @memberof TilingScheme
+ * @function
*
* @param {Number} level The level-of-detail.
* @returns {Number} The number of tiles in the Y direction at the given level.
*/
- TilingScheme.prototype.getNumberOfYTilesAtLevel = function(level) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TilingScheme.prototype.getNumberOfYTilesAtLevel = DeveloperError.throwInstantiationError;
/**
* Creates the tile or tiles at level of detail zero, the coarsest, least detailed level.
- *
* @memberof TilingScheme
+ * @function
*
* @returns {Array} An array containing the tiles at level of detail zero, starting with the
* tile in the northwest corner and followed by the tile (if any) to its east.
*/
- TilingScheme.prototype.createLevelZeroTiles = function() {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TilingScheme.prototype.createLevelZeroTiles = DeveloperError.throwInstantiationError;
/**
* Transforms an extent specified in geodetic radians to the native coordinate system
* of this tiling scheme.
- *
* @memberof TilingScheme
+ * @function
*
* @param {Extent} extent The extent to transform.
* @param {Extent} [result] The instance to which to copy the result, or undefined if a new instance
@@ -107,15 +95,13 @@ define([
* @returns {Extent} The specified 'result', or a new object containing the native extent if 'result'
* is undefined.
*/
- TilingScheme.prototype.extentToNativeExtent = function(extent, result) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TilingScheme.prototype.extentToNativeExtent = DeveloperError.throwInstantiationError;
/**
* Converts tile x, y coordinates and level to an extent expressed in the native coordinates
* of the tiling scheme.
- *
* @memberof TilingScheme
+ * @function
*
* @param {Number} x The integer x coordinate of the tile.
* @param {Number} y The integer y coordinate of the tile.
@@ -126,14 +112,12 @@ define([
* @returns {Extent} The specified 'result', or a new object containing the extent
* if 'result' is undefined.
*/
- TilingScheme.prototype.tileXYToNativeExtent = function(x, y, level, result) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TilingScheme.prototype.tileXYToNativeExtent = DeveloperError.throwInstantiationError;
/**
* Converts tile x, y coordinates and level to a cartographic extent in radians.
- *
* @memberof TilingScheme
+ * @function
*
* @param {Number} x The integer x coordinate of the tile.
* @param {Number} y The integer y coordinate of the tile.
@@ -144,15 +128,13 @@ define([
* @returns {Extent} The specified 'result', or a new object containing the extent
* if 'result' is undefined.
*/
- TilingScheme.prototype.tileXYToExtent = function(x, y, level, result) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TilingScheme.prototype.tileXYToExtent = DeveloperError.throwInstantiationError;
/**
* Calculates the tile x, y coordinates of the tile containing
* a given cartographic position.
- *
* @memberof TilingScheme
+ * @function
*
* @param {Cartographic} position The position.
* @param {Number} level The tile level-of-detail. Zero is the least detailed.
@@ -162,9 +144,7 @@ define([
* @returns {Cartesian2} The specified 'result', or a new object containing the tile x, y coordinates
* if 'result' is undefined.
*/
- TilingScheme.prototype.positionToTileXY = function(position, level, result) {
- throw new DeveloperError('This type should not be instantiated directly.');
- };
+ TilingScheme.prototype.positionToTileXY = DeveloperError.throwInstantiationError;
/**
* Creates a rectangular set of tiles for level of detail zero, the coarsest, least detailed level.
diff --git a/Source/Scene/WebMercatorTilingScheme.js b/Source/Scene/WebMercatorTilingScheme.js
index 8591c120116b..9aec5bb586f8 100644
--- a/Source/Scene/WebMercatorTilingScheme.js
+++ b/Source/Scene/WebMercatorTilingScheme.js
@@ -53,7 +53,7 @@ define([
this._extentSouthwestInMeters = description.extentSouthwestInMeters;
this._extentNortheastInMeters = description.extentNortheastInMeters;
} else {
- var semimajorAxisTimesPi = this._ellipsoid.getMaximumRadius() * Math.PI;
+ var semimajorAxisTimesPi = this._ellipsoid.maximumRadius * Math.PI;
this._extentSouthwestInMeters = new Cartesian2(-semimajorAxisTimesPi, -semimajorAxisTimesPi);
this._extentNortheastInMeters = new Cartesian2(semimajorAxisTimesPi, semimajorAxisTimesPi);
}
diff --git a/Source/Scene/createTangentSpaceDebugPrimitive.js b/Source/Scene/createTangentSpaceDebugPrimitive.js
index 367cc0602a4c..62ad8c1f122f 100644
--- a/Source/Scene/createTangentSpaceDebugPrimitive.js
+++ b/Source/Scene/createTangentSpaceDebugPrimitive.js
@@ -36,7 +36,7 @@ define([
* @returns {Primitive} A new Primitive instance with geometry for the vectors.
*
* @example
- * scene.getPrimitives().add(Cesium.createTangentSpaceDebugPrimitive({
+ * scene.primitives.add(Cesium.createTangentSpaceDebugPrimitive({
* geometry : instance.geometry,
* length : 100000.0,
* modelMatrix : instance.modelMatrix
diff --git a/Source/Widgets/BaseLayerPicker/BaseLayerPicker.js b/Source/Widgets/BaseLayerPicker/BaseLayerPicker.js
index 3002e3865f27..ef1b3045eb93 100644
--- a/Source/Widgets/BaseLayerPicker/BaseLayerPicker.js
+++ b/Source/Widgets/BaseLayerPicker/BaseLayerPicker.js
@@ -91,7 +91,7 @@ define([
* var cesiumWidget = new Cesium.CesiumWidget('cesiumContainer', { imageryProvider: false });
*
* //Finally, create the baseLayerPicker widget using our view models.
- * var layers = cesiumWidget.centralBody.getImageryLayers();
+ * var layers = cesiumWidget.centralBody.imageryLayerCollection;
* var baseLayerPicker = new Cesium.BaseLayerPicker('baseLayerPickerContainer', layers, providerViewModels);
*
* //Use the first item in the list as the current selection.
diff --git a/Source/Widgets/BaseLayerPicker/BaseLayerPickerViewModel.js b/Source/Widgets/BaseLayerPicker/BaseLayerPickerViewModel.js
index bf6123b6b1bc..9ecc990bfd6f 100644
--- a/Source/Widgets/BaseLayerPicker/BaseLayerPickerViewModel.js
+++ b/Source/Widgets/BaseLayerPicker/BaseLayerPickerViewModel.js
@@ -3,12 +3,14 @@ define([
'../../Core/defined',
'../../Core/defineProperties',
'../../Core/DeveloperError',
+ '../../Core/isArray',
'../createCommand',
'../../ThirdParty/knockout'
], function(
defined,
defineProperties,
DeveloperError,
+ isArray,
createCommand,
knockout) {
"use strict";
@@ -34,7 +36,7 @@ define([
if (!defined(imageryProviderViewModels)) {
imageryProviderViewModels = [];
- } else if (!Array.isArray(imageryProviderViewModels)) {
+ } else if (!isArray(imageryProviderViewModels)) {
throw new DeveloperError('imageryProviderViewModels must be an array');
}
@@ -108,7 +110,7 @@ define([
if (defined(value)) {
var newProviders = value.creationCommand();
- if (Array.isArray(newProviders)) {
+ if (isArray(newProviders)) {
var newProvidersLength = newProviders.length;
for (i = newProvidersLength - 1; i >= 0; i--) {
imageryLayers.addImageryProvider(newProviders[i], 0);
diff --git a/Source/Widgets/CesiumInspector/CesiumInspector.css b/Source/Widgets/CesiumInspector/CesiumInspector.css
new file mode 100644
index 000000000000..60982f5df440
--- /dev/null
+++ b/Source/Widgets/CesiumInspector/CesiumInspector.css
@@ -0,0 +1,129 @@
+.cesium-cesiumInspector {
+ border-radius: 5px;
+ -webkit-transition: width ease-in-out 0.25s;
+ -moz-transition: width ease-in-out 0.25s;
+ transition: width ease-in-out 0.25s;
+ background: rgba(48, 51, 54, 0.8);
+ border: 1px solid #444;
+ color: #edffff;
+ display: inline-block;
+ position: relative;
+ padding: 4px 12px;
+ -moz-user-select: none;
+ -webkit-user-select: none;
+ user-select: none;
+ overflow: hidden;
+}
+
+.cesium-cesiumInspector-button {
+ text-align: center;
+ font-size: 11pt;
+}
+
+.cesium-cesiumInspector-visible .cesium-cesiumInspector-button {
+ border-bottom: 1px solid #aaa;
+ padding-bottom: 3px;
+}
+
+.cesium-cesiumInspector input:enabled, .cesium-cesiumInspector-button{
+ cursor: pointer;
+}
+
+.cesium-cesiumInspector-visible {
+ width: 185px;
+ height: auto;
+}
+
+.cesium-cesiumInspector-hidden {
+ width: 122px;
+ height: 17px;
+}
+
+.cesium-cesiumInspector-show {
+ max-height: 500px;
+}
+
+.cesium-cesiumInspector-hide {
+ max-height: 0;
+ padding: 0 !important;
+ overflow: hidden;
+}
+
+.cesium-cesiumInspector-dropDown {
+ margin: 5px 0;
+ font-family: sans-serif;
+ font-size: 10pt;
+ width: 185px;
+}
+
+.cesium-cesiumInspector-frustumStats {
+ padding-left: 10px;
+ padding: 5px;
+ background-color: rgba(80, 80, 80, 0.75);
+}
+
+.cesium-cesiumInspector-pickButton {
+ background-color: rgba(0, 0, 0, 0.3);
+ border: 1px solid #444;
+ color: #edffff;
+ border-radius: 5px;
+ padding: 3px 7px;
+ cursor: pointer;
+ -moz-user-select: none;
+ -webkit-user-select: none;
+ user-select: none;
+ margin: 0 auto;
+}
+
+.cesium-cesiumInspector-pickButton:focus {
+ outline: none;
+}
+
+.cesium-cesiumInspector-pickButton:active, .cesium-cesiumInspector-pickButtonHighlight {
+ color: #000; /* For text buttons */
+ background: #adf;
+ border-color: #fff;
+ box-shadow: 0 0 8px #fff;
+}
+
+.cesium-cesiumInspector-center {
+ text-align: center;
+}
+
+.cesium-cesiumInspector-sectionHeader {
+ font-weight: bold;
+}
+
+.cesium-cesiumInspector-pickSection {
+ border: 1px solid #aaa;
+ border-radius: 5px;
+ padding: 3px;
+ margin-bottom: 5px;
+}
+
+.cesium-cesiumInspector-section {
+ margin-bottom: 10px;
+ -webkit-transition: max-height 0.25s;
+ -moz-transition: max-height 0.25s;
+ transition: max-height 0.25s;
+}
+
+.cesium-cesiumInspector-toggleSwitch {
+ padding: 3px;
+ cursor: pointer;
+}
+
+.cesium-cesiumInspector-performanceDisplay {
+ position: absolute;
+ right: 10px;
+ top: 50px;
+}
+
+.cesium-cesiumInspector-tileText {
+ padding-bottom: 10px;
+ border-bottom: 1px solid #aaa;
+}
+
+.cesium-cesiumInspector-relativeText {
+ padding-top: 10px;
+}
\ No newline at end of file
diff --git a/Source/Widgets/CesiumInspector/CesiumInspector.js b/Source/Widgets/CesiumInspector/CesiumInspector.js
new file mode 100644
index 000000000000..6c080a81a728
--- /dev/null
+++ b/Source/Widgets/CesiumInspector/CesiumInspector.js
@@ -0,0 +1,339 @@
+/*global define*/
+define([
+ '../../Core/defined',
+ '../../Core/defineProperties',
+ '../../Core/destroyObject',
+ '../../Core/BoundingRectangle',
+ '../../Core/Color',
+ '../../Core/DeveloperError',
+ '../../Scene/PerformanceDisplay',
+ '../../Scene/DebugModelMatrixPrimitive',
+ '../getElement',
+ './CesiumInspectorViewModel',
+ '../../ThirdParty/knockout'
+ ], function(
+ defined,
+ defineProperties,
+ destroyObject,
+ BoundingRectangle,
+ Color,
+ DeveloperError,
+ PerformanceDisplay,
+ DebugModelMatrixPrimitive,
+ getElement,
+ CesiumInspectorViewModel,
+ knockout) {
+ "use strict";
+
+ /**
+ * Inspector widget to aid in debugging
+ *
+ * @alias CesiumInspector
+ * @constructor
+ *
+ * @param {Element|String} container The DOM element or ID that will contain the widget.
+ * @param {Scene} scene The Scene instance to use.
+ *
+ * @exception {DeveloperError} container is required.
+ * @exception {DeveloperError} scene is required.
+ */
+ var CesiumInspector = function(container, scene) {
+ if (!defined(container)) {
+ throw new DeveloperError('container is required.');
+ }
+
+ if (!defined(scene)) {
+ throw new DeveloperError('scene is required.');
+ }
+
+ container = getElement(container);
+
+ var viewModel = new CesiumInspectorViewModel(scene);
+ this._viewModel = viewModel;
+ this._container = container;
+
+ var element = document.createElement('div');
+ this._element = element;
+ var text = document.createElement('div');
+ text.textContent = 'Cesium Inspector';
+ text.className = 'cesium-cesiumInspector-button';
+ text.setAttribute('data-bind', 'click: toggleDropDown');
+ element.appendChild(text);
+ element.className = 'cesium-cesiumInspector';
+ element.setAttribute('data-bind', 'css: { "cesium-cesiumInspector-visible" : dropDownVisible, "cesium-cesiumInspector-hidden" : !dropDownVisible }');
+ container.appendChild(this._element);
+
+ var panel = document.createElement('div');
+ this._panel = panel;
+ panel.className = 'cesium-cesiumInspector-dropDown';
+ element.appendChild(panel);
+
+ // General
+ var general = document.createElement('div');
+ general.className = 'cesium-cesiumInspector-sectionHeader';
+ var plus = document.createElement('span');
+ plus.className = 'cesium-cesiumInspector-toggleSwitch';
+ plus.setAttribute('data-bind', 'click: toggleGeneral, text: generalSwitchText');
+ general.appendChild(plus);
+ general.appendChild(document.createTextNode('General'));
+ panel.appendChild(general);
+
+ var generalSection = document.createElement('div');
+ generalSection.className = 'cesium-cesiumInspector-section';
+ generalSection.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : generalVisible, "cesium-cesiumInspector-hide" : !generalVisible}');
+ panel.appendChild(generalSection);
+ var debugShowFrustums = document.createElement('div');
+ generalSection.appendChild(debugShowFrustums);
+ var frustumStats = document.createElement('div');
+ frustumStats.className = 'cesium-cesiumInspector-frustumStats';
+ frustumStats.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : frustums, "cesium-cesiumInspector-hide" : !frustums}, html: frustumStatisticText');
+ var frustumsCheckbox = document.createElement('input');
+ frustumsCheckbox.type = 'checkbox';
+ frustumsCheckbox.setAttribute('data-bind', 'checked: frustums, click: showFrustums');
+ debugShowFrustums.appendChild(frustumsCheckbox);
+ debugShowFrustums.appendChild(document.createTextNode('Show Frustums'));
+ debugShowFrustums.appendChild(frustumStats);
+
+ var performanceDisplay = document.createElement('div');
+ generalSection.appendChild(performanceDisplay);
+ var pdCheckbox = document.createElement('input');
+ pdCheckbox.type = 'checkbox';
+ pdCheckbox.setAttribute('data-bind', 'checked: performance, click: showPerformance');
+ performanceDisplay.appendChild(pdCheckbox);
+ performanceDisplay.appendChild(document.createTextNode('Performance Display'));
+
+ // Primitives
+ var prim = document.createElement('div');
+ prim.className = 'cesium-cesiumInspector-sectionHeader';
+ plus = document.createElement('span');
+ plus.className = 'cesium-cesiumInspector-toggleSwitch';
+ plus.setAttribute('data-bind', 'click: togglePrimitives, text: primitivesSwitchText');
+ prim.appendChild(plus);
+ prim.appendChild(document.createTextNode('Primitives'));
+ panel.appendChild(prim);
+
+ var primitivesSection = document.createElement('div');
+ primitivesSection.className = 'cesium-cesiumInspector-section';
+ primitivesSection.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : primitivesVisible, "cesium-cesiumInspector-hide" : !primitivesVisible}');
+ panel.appendChild(primitivesSection);
+ var pickPrimRequired = document.createElement('div');
+ pickPrimRequired.className = 'cesium-cesiumInspector-pickSection';
+ primitivesSection.appendChild(pickPrimRequired);
+
+ var pickPrimitiveButton = document.createElement('input');
+ pickPrimitiveButton.type = 'button';
+ pickPrimitiveButton.value = 'Pick a primitive';
+ pickPrimitiveButton.className = 'cesium-cesiumInspector-pickButton';
+ pickPrimitiveButton.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-pickButtonHighlight" : pickPrimitiveActive}, click: pickPrimitive');
+ var buttonWrap = document.createElement('div');
+ buttonWrap.className = 'cesium-cesiumInspector-center';
+ buttonWrap.appendChild(pickPrimitiveButton);
+ pickPrimRequired.appendChild(buttonWrap);
+
+ var debugSphere = document.createElement('div');
+ pickPrimRequired.appendChild(debugSphere);
+ var bsCheckbox = document.createElement('input');
+ bsCheckbox.type = 'checkbox';
+ bsCheckbox.setAttribute('data-bind', 'checked: primitiveBoundingSphere, click: showPrimitiveBoundingSphere, enable: hasPickedPrimitive');
+ debugSphere.appendChild(bsCheckbox);
+ debugSphere.appendChild(document.createTextNode('Show bounding sphere'));
+
+ var refFrame = document.createElement('div');
+ pickPrimRequired.appendChild(refFrame);
+ var rfCheckbox = document.createElement('input');
+ rfCheckbox.type = 'checkbox';
+ rfCheckbox.setAttribute('data-bind', 'checked: primitiveReferenceFrame, click: showPrimitiveReferenceFrame, enable: hasPickedPrimitive');
+ refFrame.appendChild(rfCheckbox);
+ refFrame.appendChild(document.createTextNode('Show reference frame'));
+
+ var primitiveOnly = document.createElement('div');
+ this._primitiveOnly = primitiveOnly;
+ pickPrimRequired.appendChild(primitiveOnly);
+ var primitiveOnlyCheckbox = document.createElement('input');
+ primitiveOnlyCheckbox.type = 'checkbox';
+ primitiveOnlyCheckbox.setAttribute('data-bind', 'checked: filterPrimitive, click: doFilterPrimitive, enable: hasPickedPrimitive');
+ primitiveOnly.appendChild(primitiveOnlyCheckbox);
+ primitiveOnly.appendChild(document.createTextNode('Show only selected'));
+
+ // Terrain
+ var terrain = document.createElement('div');
+ terrain.className = 'cesium-cesiumInspector-sectionHeader';
+ plus = document.createElement('span');
+ plus.className = 'cesium-cesiumInspector-toggleSwitch';
+ plus.setAttribute('data-bind', 'click: toggleTerrain, text: terrainSwitchText');
+ terrain.appendChild(plus);
+ terrain.appendChild(document.createTextNode('Terrain'));
+ panel.appendChild(terrain);
+
+ var terrainSection = document.createElement('div');
+ terrainSection.className = 'cesium-cesiumInspector-section';
+ terrainSection.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : terrainVisible, "cesium-cesiumInspector-hide" : !terrainVisible}');
+ panel.appendChild(terrainSection);
+ var pickTileRequired = document.createElement('div');
+ pickTileRequired.className = 'cesium-cesiumInspector-pickSection';
+ terrainSection.appendChild(pickTileRequired);
+ var pickTileButton = document.createElement('input');
+ pickTileButton.type = 'button';
+ pickTileButton.value = 'Pick a tile';
+ pickTileButton.className = 'cesium-cesiumInspector-pickButton';
+ pickTileButton.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-pickButtonHighlight" : pickTileActive}, click: pickTile');
+ buttonWrap = document.createElement('div');
+ buttonWrap.appendChild(pickTileButton);
+ buttonWrap.className = 'cesium-cesiumInspector-center';
+ pickTileRequired.appendChild(buttonWrap);
+ var tileInfo = document.createElement('div');
+ pickTileRequired.appendChild(tileInfo);
+ var parentTile = document.createElement('input');
+ parentTile.type = 'button';
+ parentTile.value = 'Parent';
+ parentTile.className = 'cesium-cesiumInspector-pickButton';
+ parentTile.setAttribute('data-bind', 'click: selectParent');
+ var nwTile = document.createElement('input');
+ nwTile.type = 'button';
+ nwTile.value = 'NW';
+ nwTile.className = 'cesium-cesiumInspector-pickButton';
+ nwTile.setAttribute('data-bind', 'click: selectNW');
+ var neTile = document.createElement('input');
+ neTile.type = 'button';
+ neTile.value = 'NE';
+ neTile.className = 'cesium-cesiumInspector-pickButton';
+ neTile.setAttribute('data-bind', 'click: selectNE');
+ var swTile = document.createElement('input');
+ swTile.type = 'button';
+ swTile.value = 'SW';
+ swTile.className = 'cesium-cesiumInspector-pickButton';
+ swTile.setAttribute('data-bind', 'click: selectSW');
+ var seTile = document.createElement('input');
+ seTile.type = 'button';
+ seTile.value = 'SE';
+ seTile.className = 'cesium-cesiumInspector-pickButton';
+ seTile.setAttribute('data-bind', 'click: selectSE');
+
+ var tileText = document.createElement('div');
+ tileText.className = 'cesium-cesiumInspector-tileText';
+ tileInfo.className = 'cesium-cesiumInspector-frustumStats';
+ tileInfo.appendChild(tileText);
+ tileInfo.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : hasPickedTile, "cesium-cesiumInspector-hide" : !hasPickedTile}');
+ tileText.setAttribute('data-bind', 'html: tileText');
+
+ var relativeText = document.createElement('div');
+ relativeText.className = 'cesium-cesiumInspector-relativeText';
+ relativeText.textContent = 'Select relative:';
+ tileInfo.appendChild(relativeText);
+
+ var table = document.createElement('table');
+ var tr1 = document.createElement('tr');
+ var tr2 = document.createElement('tr');
+ var td1 = document.createElement('td');
+ td1.appendChild(parentTile);
+ var td2 = document.createElement('td');
+ td2.appendChild(nwTile);
+ var td3 = document.createElement('td');
+ td3.appendChild(neTile);
+ tr1.appendChild(td1);
+ tr1.appendChild(td2);
+ tr1.appendChild(td3);
+ var td4 = document.createElement('td');
+ var td5 = document.createElement('td');
+ td5.appendChild(swTile);
+ var td6 = document.createElement('td');
+ td6.appendChild(seTile);
+ tr2.appendChild(td4);
+ tr2.appendChild(td5);
+ tr2.appendChild(td6);
+ table.appendChild(tr1);
+ table.appendChild(tr2);
+
+ tileInfo.appendChild(table);
+
+ var tileBoundingSphere = document.createElement('div');
+ pickTileRequired.appendChild(tileBoundingSphere);
+ var tbsCheck = document.createElement('input');
+ tbsCheck.type = 'checkbox';
+ tbsCheck.setAttribute('data-bind', 'checked: tileBoundingSphere, enable: hasPickedTile, click: showTileBoundingSphere');
+ tileBoundingSphere.appendChild(tbsCheck);
+ tileBoundingSphere.appendChild(document.createTextNode('Show bounding sphere'));
+
+ var renderTile = document.createElement('div');
+ pickTileRequired.appendChild(renderTile);
+ var rCheck = document.createElement('input');
+ rCheck.type = 'checkbox';
+ rCheck.setAttribute('data-bind', 'checked: filterTile, enable: hasPickedTile, click: doFilterTile');
+ renderTile.appendChild(rCheck);
+ renderTile.appendChild(document.createTextNode('Show only selected'));
+
+ var wireframe = document.createElement('div');
+ terrainSection.appendChild(wireframe);
+ var wCheckbox = document.createElement('input');
+ wCheckbox.type = 'checkbox';
+ wCheckbox.setAttribute('data-bind', 'checked: wireframe, click: showWireframe');
+ wireframe.appendChild(wCheckbox);
+ wireframe.appendChild(document.createTextNode('Wireframe'));
+
+ var suspendUpdates = document.createElement('div');
+ terrainSection.appendChild(suspendUpdates);
+ var upCheckbox = document.createElement('input');
+ upCheckbox.type = 'checkbox';
+ upCheckbox.setAttribute('data-bind', 'checked: suspendUpdates, click: doSuspendUpdates');
+ suspendUpdates.appendChild(upCheckbox);
+ suspendUpdates.appendChild(document.createTextNode('Suspend LOD update'));
+
+ var tileCoords = document.createElement('div');
+ terrainSection.appendChild(tileCoords);
+ var coordCheck = document.createElement('input');
+ coordCheck.type = 'checkbox';
+ coordCheck.setAttribute('data-bind', 'checked: tileCoordinates, click: showTileCoordinates');
+ tileCoords.appendChild(coordCheck);
+ tileCoords.appendChild(document.createTextNode('Show tile coordinates'));
+
+ knockout.applyBindings(viewModel, this._element);
+ };
+
+ defineProperties(CesiumInspector.prototype, {
+ /**
+ * Gets the parent container.
+ * @memberof CesiumInspector.prototype
+ *
+ * @type {Element}
+ */
+ container : {
+ get : function() {
+ return this._container;
+ }
+ },
+
+ /**
+ * Gets the view model.
+ * @memberof CesiumInspector.prototype
+ *
+ * @type {CesiumInspectorViewModel}
+ */
+ viewModel : {
+ get : function() {
+ return this._viewModel;
+ }
+ }
+ });
+
+ /**
+ * @memberof CesiumInspector
+ * @returns {Boolean} true if the object has been destroyed, false otherwise.
+ */
+ CesiumInspector.prototype.isDestroyed = function() {
+ return false;
+ };
+
+ /**
+ * Destroys the widget. Should be called if permanently
+ * removing the widget from layout.
+ * @memberof CesiumInspector
+ */
+ CesiumInspector.prototype.destroy = function() {
+ knockout.cleanNode(this._element);
+ var container = this._container;
+ container.removeChild(this._element);
+ return destroyObject(this);
+ };
+
+ return CesiumInspector;
+});
\ No newline at end of file
diff --git a/Source/Widgets/CesiumInspector/CesiumInspectorViewModel.js b/Source/Widgets/CesiumInspector/CesiumInspectorViewModel.js
new file mode 100644
index 000000000000..2ce6896eccce
--- /dev/null
+++ b/Source/Widgets/CesiumInspector/CesiumInspectorViewModel.js
@@ -0,0 +1,815 @@
+/*global define*/
+define([
+ '../../Core/defined',
+ '../../Core/defineProperties',
+ '../../Core/DeveloperError',
+ '../../Core/BoundingRectangle',
+ '../../Scene/PerformanceDisplay',
+ '../../Scene/DebugModelMatrixPrimitive',
+ '../../Scene/TileCoordinatesImageryProvider',
+ '../../Core/Color',
+ '../createCommand',
+ '../../ThirdParty/knockout'
+ ], function(
+ defined,
+ defineProperties,
+ DeveloperError,
+ BoundingRectangle,
+ PerformanceDisplay,
+ DebugModelMatrixPrimitive,
+ TileCoordinatesImageryProvider,
+ Color,
+ createCommand,
+ knockout) {
+ "use strict";
+
+ function frustumStatsToString(stats) {
+ var str;
+ if (defined(stats)) {
+ str = 'Command Statistics';
+ var com = stats.commandsInFrustums;
+ for (var n in com) {
+ if (com.hasOwnProperty(n)) {
+ var num = parseInt(n, 10);
+ var s;
+ if (num === 7) {
+ s = '1, 2 and 3';
+ } else {
+ var f = [];
+ for (var i = 2; i >= 0; i--) {
+ var p = Math.pow(2, i);
+ if (num >= p) {
+ f.push(i + 1);
+ num -= p;
+ }
+ }
+ s = f.reverse().join(' and ');
+ }
+ str += '
' + com[n] + ' in frustum ' + s;
+ }
+ }
+ str += '
Total: ' + stats.totalCommands;
+ }
+
+ return str;
+ }
+
+ var bc = new Color(0.15, 0.15, 0.15, 0.75);
+
+ var performanceContainer = document.createElement('div');
+ performanceContainer.className = 'cesium-cesiumInspector-performanceDisplay';
+
+ /**
+ * The view model for {@link CesiumInspector}.
+ * @alias CesiumInspectorViewModel
+ * @constructor
+ *
+ * @param {Scene} scene The scene instance to use.
+ *
+ * @exception {DeveloperError} scene is required.
+ */
+ var CesiumInspectorViewModel = function(scene) {
+ if (!defined(scene)) {
+ throw new DeveloperError('scene is required');
+ }
+
+ var that = this;
+ var canvas = scene.canvas;
+ canvas.parentNode.appendChild(performanceContainer);
+ this._scene = scene;
+ this._canvas = canvas;
+ this._primitive = undefined;
+ this._tile = undefined;
+ this._modelMatrixPrimitive = undefined;
+ this._performanceDisplay = undefined;
+
+ var centralBody = this._scene.primitives.centralBody;
+ centralBody.depthTestAgainstTerrain = true;
+
+ /**
+ * Gets or sets the show frustums state. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.frustums = false;
+
+ /**
+ * Gets or sets the show performance display state. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.performance = false;
+
+ /**
+ * Gets or sets the show primitive bounding sphere state. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.primitiveBoundingSphere = false;
+
+ /**
+ * Gets or sets the show primitive reference frame state. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.primitiveReferenceFrame = false;
+
+ /**
+ * Gets or sets the filter primitive state. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.filterPrimitive = false;
+
+ /**
+ * Gets or sets the show tile bounding sphere state. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.tileBoundingSphere = false;
+
+ /**
+ * Gets or sets the filter tile state. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.filterTile = false;
+
+ /**
+ * Gets or sets the show wireframe state. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.wireframe = false;
+
+ /**
+ * Gets or sets the suspend updates state. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.suspendUpdates = false;
+
+ /**
+ * Gets or sets the show tile coordinates state. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.tileCoordinates = false;
+
+ /**
+ * Gets or sets the frustum statistic text. This property is observable.
+ * @type {String}
+ * @default ''
+ */
+ this.frustumStatisticText = '';
+
+ /**
+ * Gets or sets the selected tile information text. This property is observable.
+ * @type {String}
+ * @default ''
+ */
+ this.tileText = '';
+
+ /**
+ * Gets if a primitive has been selected. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.hasPickedPrimitive = false;
+
+ /**
+ * Gets if a tile has been selected. This property is observable
+ * @type {Boolean}
+ * @default false
+ */
+ this.hasPickedTile = false;
+
+ /**
+ * Gets if the picking primitive command is active. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.pickPimitiveActive = false;
+
+ /**
+ * Gets if the picking tile command is active. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.pickTileActive = false;
+
+ /**
+ * Gets or sets if the cesium inspector drop down is visible. This property is observable.
+ * @type {Boolean}
+ * @default true
+ */
+ this.dropDownVisible = true;
+
+ /**
+ * Gets or sets if the general section is visible. This property is observable.
+ * @type {Boolean}
+ * @default true
+ */
+ this.generalVisible = true;
+
+ /**
+ * Gets or sets if the primitive section is visible. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.primitivesVisible = false;
+
+ /**
+ * Gets or sets if the terrain section is visible. This property is observable.
+ * @type {Boolean}
+ * @default false
+ */
+ this.terrainVisible = false;
+
+ /**
+ * Gets or sets if the text on the general section expand button. This property is observable.
+ * @type {String}
+ * @default '-'
+ */
+ this.generalSwitchText = '-';
+
+ /**
+ * Gets or sets if the text on the primitive section expand button. This property is observable.
+ * @type {String}
+ * @default '+'
+ */
+ this.primitivesSwitchText = '+';
+
+ /**
+ * Gets or sets if the text on the terrain section expand button. This property is observable.
+ * @type {String}
+ * @default '+'
+ */
+ this.terrainSwitchText = '+';
+
+ knockout.track(this, ['filterTile', 'suspendUpdates', 'dropDownVisible', 'frustums',
+ 'frustumStatisticText', 'pickTileActive', 'pickPrimitiveActive', 'hasPickedPrimitive',
+ 'hasPickedTile', 'tileText', 'generalVisible', 'generalSwitchText',
+ 'primitivesVisible', 'primitivesSwitchText', 'terrainVisible', 'terrainSwitchText']);
+
+ this._toggleDropDown = createCommand(function() {
+ that.dropDownVisible = !that.dropDownVisible;
+ });
+
+ this._toggleGeneral = createCommand(function() {
+ that.generalVisible = ! that.generalVisible;
+ that.generalSwitchText = that.generalVisible ? '-' : '+';
+ });
+
+ this._togglePrimitives = createCommand(function() {
+ that.primitivesVisible = ! that.primitivesVisible;
+ that.primitivesSwitchText = that.primitivesVisible ? '-' : '+';
+ });
+
+ this._toggleTerrain = createCommand(function() {
+ that.terrainVisible = ! that.terrainVisible;
+ that.terrainSwitchText = that.terrainVisible ? '-' : '+';
+ });
+
+ this._showFrustums = createCommand(function() {
+ if (that.frustums) {
+ that._scene.debugShowFrustums = true;
+ } else {
+ that._scene.debugShowFrustums = false;
+ }
+ return true;
+ });
+
+ this._showPerformance = createCommand(function() {
+ if (that.performance) {
+ that._performanceDisplay = new PerformanceDisplay({
+ container: performanceContainer,
+ backgroundColor: bc,
+ font: '12px arial,sans-serif'
+ });
+ } else {
+ performanceContainer.innerHTML= '';
+ }
+ return true;
+ });
+
+ this._showPrimitiveBoundingSphere = createCommand(function() {
+ that._primitive.debugShowBoundingVolume = that.primitiveBoundingSphere;
+ return true;
+ });
+
+ this._showPrimitiveReferenceFrame = createCommand(function() {
+ if (that.primitiveReferenceFrame) {
+ var modelMatrix = that._primitive.modelMatrix;
+ that._modelMatrixPrimitive = new DebugModelMatrixPrimitive({modelMatrix: modelMatrix});
+ that._scene.primitives.add(that._modelMatrixPrimitive);
+ } else if (defined(that._modelMatrixPrimitive)){
+ that._scene.primitives.remove(that._modelMatrixPrimitive);
+ that._modelMatrixPrimitive = undefined;
+ }
+ return true;
+ });
+
+ this._doFilterPrimitive = createCommand(function() {
+ if (that.filterPrimitive) {
+ that._scene.debugCommandFilter = function(command) {
+ if (defined(that._modelMatrixPrimitive) && command.owner === that._modelMatrixPrimitive._primitive) {
+ return true;
+ } else if (defined(that._primitive)) {
+ return command.owner === that._primitive|| command.owner === that._primitive._billboardCollection;
+ }
+ return false;
+ };
+ } else {
+ that._scene.debugCommandFilter = undefined;
+ }
+ return true;
+ });
+
+ this._showWireframe = createCommand(function() {
+ centralBody._surface._debug.wireframe = that.wireframe;
+ return true;
+ });
+
+ this._doSuspendUpdates = createCommand(function() {
+ centralBody._surface._debug.suspendLodUpdate = that.suspendUpdates;
+ if (!that.suspendUpdates) {
+ that.filterTile = false;
+ }
+ return true;
+ });
+
+ var tileBoundariesLayer;
+ this._showTileCoordinates = createCommand(function() {
+ if (that.tileCoordinates && !defined(tileBoundariesLayer)) {
+ tileBoundariesLayer = centralBody.imageryLayerCollection.addImageryProvider(new TileCoordinatesImageryProvider({
+ tilingScheme : centralBody.terrainProvider.getTilingScheme()
+ }));
+ } else if (!that.tileCoordinates && defined(tileBoundariesLayer)) {
+ centralBody.imageryLayerCollection.remove(tileBoundariesLayer);
+ tileBoundariesLayer = undefined;
+ }
+ return true;
+ });
+
+ this._showTileBoundingSphere = createCommand(function() {
+ if (that.tileBoundingSphere) {
+ centralBody._surface._debug.boundingSphereTile = that._tile;
+ } else {
+ centralBody._surface._debug.boundingSphereTile = undefined;
+ }
+ return true;
+ });
+
+ this._doFilterTile = createCommand(function() {
+ if (!that.filterTile) {
+ that.suspendUpdates = false;
+ that.doSuspendUpdates();
+ } else {
+ that.suspendUpdates = true;
+ that.doSuspendUpdates();
+
+ centralBody._surface._tilesToRenderByTextureCount = [];
+
+ if (defined(that._tile)) {
+ var readyTextureCount = 0;
+ var tileImageryCollection = that._tile.imagery;
+ for (var i = 0, len = tileImageryCollection.length; i < len; ++i) {
+ var tileImagery = tileImageryCollection[i];
+ if (defined(tileImagery.readyImagery) && tileImagery.readyImagery.imageryLayer.alpha !== 0.0) {
+ ++readyTextureCount;
+ }
+ }
+
+ centralBody._surface._tilesToRenderByTextureCount[readyTextureCount] = [that._tile];
+ centralBody._surface._tileLoadQueue.push(that._tile);
+
+ }
+ }
+ return true;
+ });
+
+ var pickPrimitive = function(e) {
+ that._canvas.removeEventListener('mousedown', pickPrimitive, false);
+ that.pickPrimitiveActive = false;
+ var newPick = that._scene.pick({x: e.clientX, y: e.clientY});
+ if (defined(newPick)) {
+ that.primitive = defined(newPick.collection) ? newPick.collection : newPick.primitive;
+ }
+ };
+
+ this._pickPrimitive = createCommand(function() {
+ that.pickPrimitiveActive = !that.pickPrimitiveActive;
+ if (that.pickPrimitiveActive) {
+ that._canvas.addEventListener('mousedown', pickPrimitive, false);
+ } else {
+ that._canvas.removeEventListener('mousedown', pickPrimitive, false);
+ }
+ });
+
+ var selectTile = function (e) {
+ var selectedTile;
+ var ellipsoid = centralBody.ellipsoid;
+ var cartesian = that._scene.camera.controller.pickEllipsoid({x: e.clientX, y: e.clientY}, ellipsoid);
+
+ if (defined(cartesian)) {
+ var cartographic = ellipsoid.cartesianToCartographic(cartesian);
+ var tilesRendered = centralBody._surface._tilesToRenderByTextureCount;
+ for (var textureCount = 0; !selectedTile && textureCount < tilesRendered.length; ++textureCount) {
+ var tilesRenderedByTextureCount = tilesRendered[textureCount];
+ if (!defined(tilesRenderedByTextureCount)) {
+ continue;
+ }
+
+ for (var tileIndex = 0; !selectedTile && tileIndex < tilesRenderedByTextureCount.length; ++tileIndex) {
+ var tile = tilesRenderedByTextureCount[tileIndex];
+ if (tile.extent.contains(cartographic)) {
+ selectedTile = tile;
+ }
+ }
+ }
+ }
+
+ that.tile = selectedTile;
+
+ that._canvas.removeEventListener('mousedown', selectTile, false);
+ that.pickTileActive = false;
+ };
+
+ this._pickTile = createCommand(function() {
+ that.pickTileActive = !that.pickTileActive;
+
+ if (that.pickTileActive) {
+ that._canvas.addEventListener('mousedown', selectTile, false);
+ } else {
+ that._canvas.removeEventListener('mousedown', selectTile, false);
+ }
+ });
+ };
+
+ defineProperties(CesiumInspectorViewModel.prototype, {
+ /**
+ * Gets the scene to control.
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Scene}
+ */
+ scene : {
+ get : function() {
+ return this._scene;
+ }
+ },
+
+ /**
+ * Gets the command to toggle the visibility of the drop down.
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ toggleDropDown : {
+ get : function() {
+ return this._toggleDropDown;
+ }
+ },
+
+ /**
+ * Gets the command to toggle {@link Scene.debugShowFrustums}
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ showFrustums : {
+ get : function() {
+ return this._showFrustums;
+ }
+ },
+
+ /**
+ * Gets the command to toggle the visibility of a {@link PerformanceDisplay}
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ showPerformance : {
+ get : function() {
+ return this._showPerformance;
+ }
+ },
+
+ /**
+ * Gets the command to toggle the visibility of a BoundingSphere for a primitive
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ showPrimitiveBoundingSphere : {
+ get : function() {
+ return this._showPrimitiveBoundingSphere;
+ }
+ },
+
+ /**
+ * Gets the command to toggle the visibility of a {@link DebugModelMatrixPrimitive} for the model matrix of a primitive
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ showPrimitiveReferenceFrame : {
+ get : function() {
+ return this._showPrimitiveReferenceFrame;
+ }
+ },
+
+ /**
+ * Gets the command to toggle a filter that renders only a selected primitive
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ doFilterPrimitive : {
+ get : function() {
+ return this._doFilterPrimitive;
+ }
+ },
+
+ /**
+ * Gets the command to toggle the view of the CentralBody as a wireframe
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ showWireframe : {
+ get : function() {
+ return this._showWireframe;
+ }
+ },
+
+ /**
+ * Gets the command to toggle whether to suspend tile updates
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ doSuspendUpdates : {
+ get : function() {
+ return this._doSuspendUpdates;
+ }
+ },
+
+ /**
+ * Gets the command to toggle the visibility of tile coordinates
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ showTileCoordinates : {
+ get : function() {
+ return this._showTileCoordinates;
+ }
+ },
+
+ /**
+ * Gets the command to toggle the visibility of a BoundingSphere for a selected tile
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ showTileBoundingSphere : {
+ get : function() {
+ return this._showTileBoundingSphere;
+ }
+ },
+
+ /**
+ * Gets the command to toggle a filter that renders only a selected tile
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ doFilterTile : {
+ get : function() {
+ return this._doFilterTile;
+ }
+ },
+
+ /**
+ * Gets the command to expand and collapse the general section
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ toggleGeneral : {
+ get : function() {
+ return this._toggleGeneral;
+ }
+ },
+
+ /**
+ * Gets the command to expand and collapse the primitives section
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ togglePrimitives : {
+ get : function() {
+ return this._togglePrimitives;
+ }
+ },
+
+ /**
+ * Gets the command to expand and collapse the terrain section
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ toggleTerrain : {
+ get : function() {
+ return this._toggleTerrain;
+ }
+ },
+
+ /**
+ * Gets the command to pick a primitive
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ pickPrimitive : {
+ get : function() {
+ return this._pickPrimitive;
+ }
+ },
+
+ /**
+ * Gets the command to pick a tile
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ pickTile : {
+ get : function() {
+ return this._pickTile;
+ }
+ },
+
+ /**
+ * Gets the command to pick a tile
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ selectParent : {
+ get : function() {
+ var that = this;
+ return createCommand(function() {
+ that.tile = that.tile.parent;
+ });
+ }
+ },
+
+ /**
+ * Gets the command to pick a tile
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ selectNW : {
+ get : function() {
+ var that = this;
+ return createCommand(function() {
+ that.tile = that.tile.getChildren()[0];
+ });
+ }
+ },
+
+ /**
+ * Gets the command to pick a tile
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ selectNE: {
+ get : function() {
+ var that = this;
+ return createCommand(function() {
+ that.tile = that.tile.getChildren()[1];
+ });
+ }
+ },
+
+ /**
+ * Gets the command to pick a tile
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ selectSW : {
+ get : function() {
+ var that = this;
+ return createCommand(function() {
+ that.tile = that.tile.getChildren()[2];
+ });
+ }
+ },
+
+ /**
+ * Gets the command to pick a tile
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ selectSE : {
+ get : function() {
+ var that = this;
+ return createCommand(function() {
+ that.tile = that.tile.getChildren()[3];
+ });
+ }
+ },
+
+ /**
+ * Gets or sets the current selected primitive
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ primitive: {
+ set : function(newPrimitive) {
+ var oldPrimitive = this._primitive;
+ if (newPrimitive !== oldPrimitive) {
+ this.hasPickedPrimitive = true;
+ if (defined(oldPrimitive)) {
+ oldPrimitive.debugShowBoundingVolume = false;
+ }
+ this._scene.debugCommandFilter = undefined;
+ if (defined(this._modelMatrixPrimitive)) {
+ this._scene.primitives.remove(this._modelMatrixPrimitive);
+ this._modelMatrixPrimitive = undefined;
+ }
+ this._primitive = newPrimitive;
+ newPrimitive.show = false;
+ setTimeout(function(){
+ newPrimitive.show = true;
+ }, 50);
+ this.showPrimitiveBoundingSphere();
+ this.showPrimitiveReferenceFrame();
+ this.doFilterPrimitive();
+ }
+ },
+
+ get : function() {
+ return this._primitive;
+ }
+ },
+
+ /**
+ * Gets or sets the current selected tile
+ * @memberof CesiumInspectorViewModel.prototype
+ *
+ * @type {Command}
+ */
+ tile: {
+ set : function(newTile) {
+ if (defined(newTile)) {
+ this.hasPickedTile = true;
+ var oldTile = this._tile;
+ if (newTile !== oldTile) {
+ this.tileText = 'L: ' + newTile.level + ' X: ' + newTile.x + ' Y: ' + newTile.y;
+ this.tileText += '
SW corner: ' + newTile.extent.west + ', ' + newTile.extent.south;
+ this.tileText += '
NE corner: ' + newTile.extent.east + ', ' + newTile.extent.north;
+ this.tileText += '
Min: ' + newTile.minimumHeight + ' Max: ' + newTile.maximumHeight;
+ }
+ this._tile = newTile;
+ this.showTileBoundingSphere();
+ this.doFilterTile();
+ } else {
+ this.hasPickedTile = false;
+ this._tile = undefined;
+ }
+ },
+
+ get : function() {
+ return this._tile;
+ }
+ },
+
+ update : {
+ get : function() {
+ var that = this;
+ return function() {
+ if (that.frustums) {
+ that.frustumStatisticText = frustumStatsToString(that._scene.debugFrustumStatistics);
+ }
+ if (that.performance) {
+ that._performanceDisplay.update();
+ }
+ if (that.primitiveReferenceFrame) {
+ that._modelMatrixPrimitive.modelMatrix = that._primitive.modelMatrix;
+ }
+ };
+ }
+ }
+ });
+
+ return CesiumInspectorViewModel;
+});
\ No newline at end of file
diff --git a/Source/Widgets/CesiumWidget/CesiumWidget.js b/Source/Widgets/CesiumWidget/CesiumWidget.js
index 9a4b59952a75..f40d786565d5 100644
--- a/Source/Widgets/CesiumWidget/CesiumWidget.js
+++ b/Source/Widgets/CesiumWidget/CesiumWidget.js
@@ -177,16 +177,16 @@ define([
widgetNode.appendChild(creditContainer);
var scene = new Scene(canvas, options.contextOptions, creditContainer);
- scene.getCamera().controller.constrainedAxis = Cartesian3.UNIT_Z;
+ scene.camera.controller.constrainedAxis = Cartesian3.UNIT_Z;
var ellipsoid = Ellipsoid.WGS84;
- var creditDisplay = scene.getFrameState().creditDisplay;
+ var creditDisplay = scene.frameState.creditDisplay;
var cesiumCredit = new Credit('Cesium', cesiumLogoData, 'http://cesiumjs.org/');
creditDisplay.addDefaultCredit(cesiumCredit);
var centralBody = new CentralBody(ellipsoid);
- scene.getPrimitives().setCentralBody(centralBody);
+ scene.primitives.centralBody = centralBody;
var skyBox = options.skyBox;
if (!defined(skyBox)) {
@@ -219,7 +219,7 @@ define([
}
if (imageryProvider !== false) {
- centralBody.getImageryLayers().addImageryProvider(imageryProvider);
+ centralBody.imageryLayerCollection.addImageryProvider(imageryProvider);
}
//Set the terrain provider if one is provided.
@@ -520,7 +520,7 @@ define([
this._canRender = canRender;
if (canRender) {
- var frustum = this._scene.getCamera().frustum;
+ var frustum = this._scene.camera.frustum;
if (defined(frustum.aspectRatio)) {
frustum.aspectRatio = width / height;
} else {
diff --git a/Source/Widgets/Command.js b/Source/Widgets/Command.js
index b2d7238d42d9..197352e88813 100644
--- a/Source/Widgets/Command.js
+++ b/Source/Widgets/Command.js
@@ -42,7 +42,7 @@ define([
*/
this.afterExecute = undefined;
- throw new DeveloperError('This type should not be instantiated directly.');
+ DeveloperError.throwInstantiationError();
};
return Command;
diff --git a/Source/Widgets/Geocoder/Geocoder.css b/Source/Widgets/Geocoder/Geocoder.css
index 7640df16b4b0..34635b552377 100644
--- a/Source/Widgets/Geocoder/Geocoder.css
+++ b/Source/Widgets/Geocoder/Geocoder.css
@@ -50,4 +50,4 @@
.cesium-geocoder-searchButton:hover {
background-color: #48b;
-}
+}
\ No newline at end of file
diff --git a/Source/Widgets/Geocoder/GeocoderViewModel.js b/Source/Widgets/Geocoder/GeocoderViewModel.js
index 5c7f04305c6c..cf3bb9872427 100644
--- a/Source/Widgets/Geocoder/GeocoderViewModel.js
+++ b/Source/Widgets/Geocoder/GeocoderViewModel.js
@@ -260,7 +260,7 @@ define([
var east = bbox[3];
var extent = Extent.fromDegrees(west, south, east, north);
- var camera = viewModel._scene.getCamera();
+ var camera = viewModel._scene.camera;
var position = camera.controller.getExtentCameraCoordinates(extent);
if (!defined(position)) {
// This can happen during a scene mode transition.
@@ -271,7 +271,7 @@ define([
destination : position,
duration : viewModel._flightDuration,
onComplete : function() {
- var screenSpaceCameraController = viewModel._scene.getScreenSpaceCameraController();
+ var screenSpaceCameraController = viewModel._scene.screenSpaceCameraController;
screenSpaceCameraController.setEllipsoid(viewModel._ellipsoid);
screenSpaceCameraController.columbusViewMode = CameraColumbusViewMode.FREE;
}
@@ -296,7 +296,7 @@ define([
}
var flight = CameraFlightPath.createAnimation(viewModel._scene, description);
- viewModel._scene.getAnimations().add(flight);
+ viewModel._scene.animations.add(flight);
}, function() {
if (geocodeInProgress.cancel) {
return;
diff --git a/Source/Widgets/HomeButton/HomeButtonViewModel.js b/Source/Widgets/HomeButton/HomeButtonViewModel.js
index 76c8a3f46a60..a97c2f122c32 100644
--- a/Source/Widgets/HomeButton/HomeButtonViewModel.js
+++ b/Source/Widgets/HomeButton/HomeButtonViewModel.js
@@ -36,15 +36,13 @@ define([
function viewHome(scene, ellipsoid, transitioner, flightDuration) {
var mode = scene.mode;
- var camera = scene.getCamera();
- camera.controller.constrainedAxis = Cartesian3.UNIT_Z;
-
- var controller = scene.getScreenSpaceCameraController();
+ var camera = scene.camera;
+ var controller = scene.screenSpaceCameraController;
controller.setEllipsoid(ellipsoid);
controller.columbusViewMode = CameraColumbusViewMode.FREE;
- var context = scene.getContext();
+ var context = scene.context;
if (defined(transitioner) && mode === SceneMode.MORPHING) {
transitioner.completeMorph();
}
@@ -61,7 +59,7 @@ define([
duration : flightDuration
};
flight = CameraFlightPath.createAnimationExtent(scene, description);
- scene.getAnimations().add(flight);
+ scene.animations.add(flight);
} else if (mode === SceneMode.SCENE3D) {
Cartesian3.add(camera.position, Matrix4.getTranslation(camera.transform), camera.position);
var rotation = Matrix4.getRotation(camera.transform);
@@ -77,13 +75,13 @@ define([
direction : defaultCamera.direction
};
flight = CameraFlightPath.createAnimation(scene, description);
- scene.getAnimations().add(flight);
+ scene.animations.add(flight);
} else if (mode === SceneMode.COLUMBUS_VIEW) {
camera.transform = new Matrix4(0.0, 0.0, 1.0, 0.0,
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0);
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
var position = Cartesian3.multiplyByScalar(Cartesian3.normalize(new Cartesian3(0.0, -1.0, 1.0)), 5.0 * maxRadii);
var direction = Cartesian3.normalize(Cartesian3.subtract(Cartesian3.ZERO, position));
var right = Cartesian3.cross(direction, Cartesian3.UNIT_Z);
@@ -97,7 +95,7 @@ define([
};
flight = CameraFlightPath.createAnimation(scene, description);
- scene.getAnimations().add(flight);
+ scene.animations.add(flight);
}
}
diff --git a/Source/Widgets/SelectionIndicator/SelectionIndicatorViewModel.js b/Source/Widgets/SelectionIndicator/SelectionIndicatorViewModel.js
index 95bc6dd8d690..11a4277a902d 100644
--- a/Source/Widgets/SelectionIndicator/SelectionIndicatorViewModel.js
+++ b/Source/Widgets/SelectionIndicator/SelectionIndicatorViewModel.js
@@ -48,7 +48,7 @@ define([
this._scene = scene;
this._screenPositionX = '-1000px';
this._screenPositionY = '0';
- this._animationCollection = scene.getAnimations();
+ this._animationCollection = scene.animations;
this._container = defaultValue(container, document.body);
this._selectionIndicatorElement = selectionIndicatorElement;
this._computeScreenSpacePosition = function(position, result) {
diff --git a/Source/Widgets/Viewer/Viewer.css b/Source/Widgets/Viewer/Viewer.css
index 8f7c0e5e0549..7fe62cb692f2 100644
--- a/Source/Widgets/Viewer/Viewer.css
+++ b/Source/Widgets/Viewer/Viewer.css
@@ -11,46 +11,53 @@
}
.cesium-viewer-cesiumWidgetContainer {
- width: 100%;
- height: 100%;
+ width: 100%;
+ height: 100%;
}
.cesium-viewer-timelineContainer {
- position: absolute;
- bottom: 0;
- left: 169px;
- right: 29px;
- height: 27px;
- padding: 0;
- margin: 0;
- overflow: hidden;
- font-size: 14px;
+ position: absolute;
+ bottom: 0;
+ left: 169px;
+ right: 29px;
+ height: 27px;
+ padding: 0;
+ margin: 0;
+ overflow: hidden;
+ font-size: 14px;
}
.cesium-viewer-animationContainer {
- position: absolute;
- bottom: 0;
- left: 0;
- padding: 0;
- width: 169px;
- height: 112px;
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ padding: 0;
+ width: 169px;
+ height: 112px;
}
.cesium-viewer-fullscreenContainer {
- position: absolute;
- bottom: 0;
- right: 0;
- padding: 0;
- width: 29px;
- height: 29px;
- overflow: hidden;
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ padding: 0;
+ width: 29px;
+ height: 29px;
+ overflow: hidden;
}
.cesium-viewer-toolbar {
- display: block;
- position: absolute;
- top: 5px;
- right: 5px;
+ display: block;
+ position: absolute;
+ top: 5px;
+ right: 5px;
+}
+
+.cesium-viewer-cesiumInspectorContainer {
+ display: block;
+ position: absolute;
+ top: 5px;
+ left: 5px;
}
.cesium-viewer-geocoderContainer {
diff --git a/Source/Widgets/Viewer/Viewer.js b/Source/Widgets/Viewer/Viewer.js
index d6bdd17ad002..69758856dae0 100644
--- a/Source/Widgets/Viewer/Viewer.js
+++ b/Source/Widgets/Viewer/Viewer.js
@@ -268,14 +268,14 @@ Either specify options.imageryProvider instead or set options.baseLayerPicker to
geocoder = new Geocoder({
container : geocoderContainer,
scene : cesiumWidget.scene,
- ellipsoid : cesiumWidget.centralBody.getEllipsoid()
+ ellipsoid : cesiumWidget.centralBody.ellipsoid
});
}
//HomeButton
var homeButton;
if (!defined(options.homeButton) || options.homeButton !== false) {
- homeButton = new HomeButton(toolbar, cesiumWidget.scene, cesiumWidget.sceneTransitioner, cesiumWidget.centralBody.getEllipsoid());
+ homeButton = new HomeButton(toolbar, cesiumWidget.scene, cesiumWidget.sceneTransitioner, cesiumWidget.centralBody.ellipsoid);
if (defined(geocoder)) {
eventHelper.add(homeButton.viewModel.command.afterExecute, function() {
var viewModel = geocoder.viewModel;
@@ -297,7 +297,7 @@ Either specify options.imageryProvider instead or set options.baseLayerPicker to
var baseLayerPicker;
if (createBaseLayerPicker) {
var providerViewModels = defaultValue(options.imageryProviderViewModels, createDefaultBaseLayers());
- baseLayerPicker = new BaseLayerPicker(toolbar, cesiumWidget.centralBody.getImageryLayers(), providerViewModels);
+ baseLayerPicker = new BaseLayerPicker(toolbar, cesiumWidget.centralBody.imageryLayerCollection, providerViewModels);
baseLayerPicker.viewModel.selectedItem = defaultValue(options.selectedImageryProviderViewModel, providerViewModels[0]);
//Grab the dropdown for resize code.
@@ -377,7 +377,7 @@ Either specify options.imageryProvider instead or set options.baseLayerPicker to
}));
var onDataSourceChanged = function(dataSource) {
- if (this.clockTrackedDataSource === dataSource) {
+ if (that.clockTrackedDataSource === dataSource) {
trackDataSourceClock(dataSource);
}
};
diff --git a/Source/Widgets/Viewer/viewerCesiumInspectorMixin.js b/Source/Widgets/Viewer/viewerCesiumInspectorMixin.js
new file mode 100644
index 000000000000..64ea65015653
--- /dev/null
+++ b/Source/Widgets/Viewer/viewerCesiumInspectorMixin.js
@@ -0,0 +1,97 @@
+/*global define*/
+define([
+ '../../Core/defaultValue',
+ '../../Core/defined',
+ '../../Core/requestAnimationFrame',
+ '../../Core/DeveloperError',
+ '../../Core/defineProperties',
+ '../../Core/Event',
+ '../../Core/wrapFunction',
+ '../../DynamicScene/CzmlDataSource',
+ '../../DynamicScene/GeoJsonDataSource',
+ '../CesiumInspector/CesiumInspector',
+ '../../ThirdParty/when',
+ '../getElement'
+ ], function(
+ defaultValue,
+ defined,
+ requestAnimationFrame,
+ DeveloperError,
+ defineProperties,
+ Event,
+ wrapFunction,
+ CzmlDataSource,
+ GeoJsonDataSource,
+ CesiumInspector,
+ when,
+ getElement) {
+ "use strict";
+ /*global console*/
+
+ function startRenderLoop(viewer) {
+ viewer._renderLoopRunning = true;
+
+ function render() {
+ if (viewer.isDestroyed()) {
+ return;
+ }
+ try {
+ viewer.resize();
+ viewer.render();
+ viewer.cesiumInspector.viewModel.update();
+ requestAnimationFrame(render);
+ } catch (e) {
+ viewer._useDefaultRenderLoop = false;
+ viewer._renderLoopRunning = false;
+ viewer._renderLoopError.raiseEvent(viewer, e);
+ if (viewer._showRenderLoopErrors) {
+ /*global console*/
+ viewer.cesiumWidget.showErrorPanel('An error occurred while rendering. Rendering has stopped.', e);
+ console.error(e);
+ }
+ }
+ }
+
+ requestAnimationFrame(render);
+ }
+
+ /**
+ * A mixin which adds the CesiumInspector widget to the Viewer widget.
+ * Rather than being called directly, this function is normally passed as
+ * a parameter to {@link Viewer#extend}, as shown in the example below.
+ * @exports viewerCesiumInspectorMixin
+ *
+ * @param {Viewer} viewer The viewer instance.
+ *
+ * @exception {DeveloperError} viewer is required.
+ *
+ * @example
+ * // Add basic drag and drop support and pop up an alert window on error.
+ * var viewer = new Cesium.Viewer('cesiumContainer');
+ * viewer.extend(Cesium.viewerCesiumInspectorMixin);
+ */
+ var viewerCesiumInspectorMixin = function(viewer) {
+ if (!defined(viewer)) {
+ throw new DeveloperError('viewer is required.');
+ }
+
+ var cesiumInspectorContainer = document.createElement('div');
+ cesiumInspectorContainer.className = 'cesium-viewer-cesiumInspectorContainer';
+ viewer.container.appendChild(cesiumInspectorContainer);
+ var cesiumInspector = new CesiumInspector(cesiumInspectorContainer, viewer.cesiumWidget.scene);
+
+ viewer.useDefaultRenderLoop = false;
+
+ defineProperties(viewer, {
+ cesiumInspector : {
+ get : function() {
+ return cesiumInspector;
+ }
+ }
+ });
+
+ startRenderLoop(viewer);
+ };
+
+ return viewerCesiumInspectorMixin;
+});
diff --git a/Source/Widgets/Viewer/viewerDynamicObjectMixin.js b/Source/Widgets/Viewer/viewerDynamicObjectMixin.js
index b5b38f1c546c..19fe1da6dbd2 100644
--- a/Source/Widgets/Viewer/viewerDynamicObjectMixin.js
+++ b/Source/Widgets/Viewer/viewerDynamicObjectMixin.js
@@ -6,6 +6,7 @@ define(['../../Core/BoundingSphere',
'../../Core/EventHelper',
'../../Core/ScreenSpaceEventType',
'../../Core/wrapFunction',
+ '../../DynamicScene/DynamicObject',
'../../Scene/SceneMode',
'../subscribeAndEvaluate',
'../../DynamicScene/DynamicObjectView',
@@ -18,6 +19,7 @@ define(['../../Core/BoundingSphere',
EventHelper,
ScreenSpaceEventType,
wrapFunction,
+ DynamicObject,
SceneMode,
subscribeAndEvaluate,
DynamicObjectView,
@@ -150,22 +152,33 @@ define(['../../Core/BoundingSphere',
}
eventHelper.add(viewer.clock.onTick, onTick);
- function pickAndTrackObject(e) {
+ function pickDynamicObject(e) {
var picked = viewer.scene.pick(e.position);
- if (defined(picked) && defined(picked.primitive) && defined(picked.primitive.dynamicObject)) {
- viewer.trackedObject = picked.primitive.dynamicObject;
+ if (defined(picked)) {
+ var id = defaultValue(picked.id, picked.primitive.id);
+ if (id instanceof DynamicObject) {
+ return id;
+ }
}
}
- function pickAndSelectObject(e) {
- var picked = viewer.scene.pick(e.position);
- if (defined(picked) && defined(picked.primitive) && defined(picked.primitive.dynamicObject)) {
- viewer.selectedObject = picked.primitive.dynamicObject;
- } else {
- viewer.selectedObject = undefined;
+ function trackObject(dynamicObject) {
+ if (defined(dynamicObject) && defined(dynamicObject.position)) {
+ viewer.trackedObject = dynamicObject;
}
}
+ function pickAndTrackObject(e) {
+ var dynamicObject = pickDynamicObject(e);
+ if (defined(dynamicObject)) {
+ trackObject(dynamicObject);
+ }
+ }
+
+ function pickAndSelectObject(e) {
+ viewer.selectedObject = pickDynamicObject(e);
+ }
+
// Subscribe to the home button beforeExecute event if it exists,
// so that we can clear the trackedObject.
if (defined(viewer.homeButton)) {
@@ -246,31 +259,34 @@ define(['../../Core/BoundingSphere',
knockout.track(viewer, ['trackedObject', 'selectedObject']);
- var trackedObjectSubscription = subscribeAndEvaluate(viewer, 'trackedObject', function(value) {
+ var knockoutSubscriptions = [];
+
+ knockoutSubscriptions.push(subscribeAndEvaluate(viewer, 'trackedObject', function(value) {
var scene = viewer.scene;
- var sceneMode = scene.getFrameState().mode;
+ var sceneMode = scene.frameState.mode;
var isTracking = defined(value);
if (sceneMode === SceneMode.COLUMBUS_VIEW || sceneMode === SceneMode.SCENE2D) {
- scene.getScreenSpaceCameraController().enableTranslate = !isTracking;
+ scene.screenSpaceCameraController.enableTranslate = !isTracking;
}
if (sceneMode === SceneMode.COLUMBUS_VIEW || sceneMode === SceneMode.SCENE3D) {
- scene.getScreenSpaceCameraController().enableTilt = !isTracking;
+ scene.screenSpaceCameraController.enableTilt = !isTracking;
}
if (isTracking && defined(value.position)) {
- dynamicObjectView = new DynamicObjectView(value, scene, viewer.centralBody.getEllipsoid());
+ dynamicObjectView = new DynamicObjectView(value, scene, viewer.centralBody.ellipsoid);
} else {
dynamicObjectView = undefined;
}
- });
+ }));
- var selectedObjectSubscription = subscribeAndEvaluate(viewer, 'selectedObject', function(value) {
+ knockoutSubscriptions.push(subscribeAndEvaluate(viewer, 'selectedObject', function(value) {
if (defined(value)) {
if (defined(infoBoxViewModel)) {
infoBoxViewModel.titleText = defined(value.name) ? value.name : value.id;
}
+
if (defined(selectionIndicatorViewModel)) {
selectionIndicatorViewModel.animateAppear();
}
@@ -280,20 +296,24 @@ define(['../../Core/BoundingSphere',
selectionIndicatorViewModel.animateDepart();
}
}
- });
+ }));
// Wrap destroy to clean up event subscriptions.
viewer.destroy = wrapFunction(viewer, viewer.destroy, function() {
eventHelper.removeAll();
- trackedObjectSubscription.dispose();
- selectedObjectSubscription.dispose();
+
+ var i;
+ for (i = 0; i < knockoutSubscriptions.length; i++) {
+ knockoutSubscriptions[i].dispose();
+ }
+
viewer.screenSpaceEventHandler.removeInputAction(ScreenSpaceEventType.LEFT_CLICK);
viewer.screenSpaceEventHandler.removeInputAction(ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
// Unsubscribe from data sources
var dataSources = viewer.dataSources;
var dataSourceLength = dataSources.getLength();
- for (var i = 0; i < dataSourceLength; i++) {
+ for (i = 0; i < dataSourceLength; i++) {
dataSourceRemoved(dataSources, dataSources.get(i));
}
});
diff --git a/Source/Widgets/widgets.css b/Source/Widgets/widgets.css
index 6648fc9a55e9..5095bdfbd59a 100644
--- a/Source/Widgets/widgets.css
+++ b/Source/Widgets/widgets.css
@@ -2,6 +2,7 @@
@import url(./Animation/Animation.css);
@import url(./BaseLayerPicker/BaseLayerPicker.css);
@import url(./CesiumWidget/CesiumWidget.css);
+@import url(./CesiumInspector/CesiumInspector.css);
@import url(./checkForChromeFrame.css);
@import url(./FullscreenButton/FullscreenButton.css);
@import url(./Geocoder/Geocoder.css);
diff --git a/Specs/Core/AssociativeArraySpec.js b/Specs/Core/AssociativeArraySpec.js
new file mode 100644
index 000000000000..eacf8e0e47b8
--- /dev/null
+++ b/Specs/Core/AssociativeArraySpec.js
@@ -0,0 +1,72 @@
+/*global defineSuite*/
+defineSuite(['Core/AssociativeArray'], function(AssociativeArray) {
+ "use strict";
+ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
+
+ it('constructor has expected default values', function() {
+ var associativeArray = new AssociativeArray();
+ expect(associativeArray.length).toEqual(0);
+ expect(associativeArray.values).toEqual([]);
+ });
+
+ it('can manipulate values', function() {
+ var associativeArray = new AssociativeArray();
+
+ associativeArray.set('key1', 1);
+ associativeArray.set('key2', 2);
+ associativeArray.set('key3', 3);
+
+ expect(associativeArray.get('key1')).toEqual(1);
+ expect(associativeArray.get('key2')).toEqual(2);
+ expect(associativeArray.get('key3')).toEqual(3);
+ expect(associativeArray.length).toEqual(3);
+
+ var values = associativeArray.values;
+ expect(values).toContain(1);
+ expect(values).toContain(2);
+ expect(values).toContain(3);
+ expect(values.length).toEqual(3);
+
+ associativeArray.set('key2', 4);
+ expect(associativeArray.length).toEqual(3);
+
+ expect(values).toContain(1);
+ expect(values).not.toContain(2);
+ expect(values).toContain(4);
+ expect(values).toContain(3);
+ expect(values.length).toEqual(3);
+
+ expect(associativeArray.remove('key1')).toBe(true);
+ expect(associativeArray.get('key1')).toBeUndefined();
+ expect(values).not.toContain(1);
+ expect(values).toContain(4);
+ expect(values).toContain(3);
+ expect(values.length).toEqual(2);
+ expect(associativeArray.remove('key1')).toBe(false);
+
+ associativeArray.removeAll();
+ expect(associativeArray.length).toEqual(0);
+ expect(associativeArray.values).toEqual([]);
+ });
+
+ it('set throws with undefined key', function() {
+ var associativeArray = new AssociativeArray();
+ expect(function() {
+ associativeArray.set(undefined, 1);
+ }).toThrowDeveloperError();
+ });
+
+ it('get throws with undefined key', function() {
+ var associativeArray = new AssociativeArray();
+ expect(function() {
+ associativeArray.get(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('remove throws with undefined key', function() {
+ var associativeArray = new AssociativeArray();
+ expect(function() {
+ associativeArray.remove(undefined);
+ }).toThrowDeveloperError();
+ });
+});
diff --git a/Specs/Core/BoundingSphereSpec.js b/Specs/Core/BoundingSphereSpec.js
index 66c61bf6d92a..2436e92a4018 100644
--- a/Specs/Core/BoundingSphereSpec.js
+++ b/Specs/Core/BoundingSphereSpec.js
@@ -287,7 +287,7 @@ defineSuite([
it('fromExtent3D', function() {
var extent = Extent.MAX_VALUE;
var ellipsoid = Ellipsoid.WGS84;
- var expected = new BoundingSphere(Cartesian3.ZERO, ellipsoid.getMaximumRadius());
+ var expected = new BoundingSphere(Cartesian3.ZERO, ellipsoid.maximumRadius);
expect(BoundingSphere.fromExtent3D(extent, ellipsoid)).toEqual(expected);
});
@@ -328,7 +328,7 @@ defineSuite([
var ellipsoid = Ellipsoid.WGS84;
var sphere = BoundingSphere.fromEllipsoid(ellipsoid);
expect(sphere.center).toEqual(Cartesian3.ZERO);
- expect(sphere.radius).toEqual(ellipsoid.getMaximumRadius());
+ expect(sphere.radius).toEqual(ellipsoid.maximumRadius);
});
it('fromEllipsoid with a result parameter', function() {
@@ -336,7 +336,7 @@ defineSuite([
var sphere = new BoundingSphere(new Cartesian3(1.0, 2.0, 3.0), 4.0);
var result = BoundingSphere.fromEllipsoid(ellipsoid, sphere);
expect(result).toBe(sphere);
- expect(result).toEqual(new BoundingSphere(Cartesian3.ZERO, ellipsoid.getMaximumRadius()));
+ expect(result).toEqual(new BoundingSphere(Cartesian3.ZERO, ellipsoid.maximumRadius));
});
it('fromEllipsoid throws without ellipsoid', function() {
diff --git a/Specs/Core/EllipsoidGeodesicSpec.js b/Specs/Core/EllipsoidGeodesicSpec.js
index 335dd8a9129f..3ec37b6f0c59 100644
--- a/Specs/Core/EllipsoidGeodesicSpec.js
+++ b/Specs/Core/EllipsoidGeodesicSpec.js
@@ -168,7 +168,7 @@ defineSuite([
var expectedMid = new Cartographic(thirtyDegrees, 0);
var geodesic = new EllipsoidGeodesic(start, end);
- var distance = Ellipsoid.WGS84.getRadii().x * fifteenDegrees;
+ var distance = Ellipsoid.WGS84.radii.x * fifteenDegrees;
var midpoint = geodesic.interpolateUsingSurfaceDistance(distance);
@@ -235,7 +235,7 @@ defineSuite([
var expectedMid = new Cartographic(thirtyDegrees, 0);
var geodesic = new EllipsoidGeodesic(start, end);
- var distance = Ellipsoid.WGS84.getRadii().x * fifteenDegrees;
+ var distance = Ellipsoid.WGS84.radii.x * fifteenDegrees;
var result = new Cartographic();
var midpoint = geodesic.interpolateUsingSurfaceDistance(distance, result);
diff --git a/Specs/Core/EllipsoidSpec.js b/Specs/Core/EllipsoidSpec.js
index ba98a65f9270..74f656062962 100644
--- a/Specs/Core/EllipsoidSpec.js
+++ b/Specs/Core/EllipsoidSpec.js
@@ -32,46 +32,46 @@ defineSuite([
it('default constructor creates zero Ellipsoid', function() {
var ellipsoid = new Ellipsoid();
- expect(ellipsoid.getRadii()).toEqual(Cartesian3.ZERO);
- expect(ellipsoid.getRadiiSquared()).toEqual(Cartesian3.ZERO);
- expect(ellipsoid.getRadiiToTheFourth()).toEqual(Cartesian3.ZERO);
- expect(ellipsoid.getOneOverRadii()).toEqual(Cartesian3.ZERO);
- expect(ellipsoid.getOneOverRadiiSquared()).toEqual(Cartesian3.ZERO);
- expect(ellipsoid.getMinimumRadius()).toEqual(0.0);
- expect(ellipsoid.getMaximumRadius()).toEqual(0.0);
+ expect(ellipsoid.radii).toEqual(Cartesian3.ZERO);
+ expect(ellipsoid.radiiSquared).toEqual(Cartesian3.ZERO);
+ expect(ellipsoid.radiiToTheFourth).toEqual(Cartesian3.ZERO);
+ expect(ellipsoid.oneOverRadii).toEqual(Cartesian3.ZERO);
+ expect(ellipsoid.oneOverRadiiSquared).toEqual(Cartesian3.ZERO);
+ expect(ellipsoid.minimumRadius).toEqual(0.0);
+ expect(ellipsoid.maximumRadius).toEqual(0.0);
});
it('fromCartesian3 creates zero Ellipsoid with no parameters', function() {
var ellipsoid = Ellipsoid.fromCartesian3();
- expect(ellipsoid.getRadii()).toEqual(Cartesian3.ZERO);
- expect(ellipsoid.getRadiiSquared()).toEqual(Cartesian3.ZERO);
- expect(ellipsoid.getRadiiToTheFourth()).toEqual(Cartesian3.ZERO);
- expect(ellipsoid.getOneOverRadii()).toEqual(Cartesian3.ZERO);
- expect(ellipsoid.getOneOverRadiiSquared()).toEqual(Cartesian3.ZERO);
- expect(ellipsoid.getMinimumRadius()).toEqual(0.0);
- expect(ellipsoid.getMaximumRadius()).toEqual(0.0);
+ expect(ellipsoid.radii).toEqual(Cartesian3.ZERO);
+ expect(ellipsoid.radiiSquared).toEqual(Cartesian3.ZERO);
+ expect(ellipsoid.radiiToTheFourth).toEqual(Cartesian3.ZERO);
+ expect(ellipsoid.oneOverRadii).toEqual(Cartesian3.ZERO);
+ expect(ellipsoid.oneOverRadiiSquared).toEqual(Cartesian3.ZERO);
+ expect(ellipsoid.minimumRadius).toEqual(0.0);
+ expect(ellipsoid.maximumRadius).toEqual(0.0);
});
it('constructor computes correct values', function() {
var ellipsoid = new Ellipsoid(radii.x, radii.y, radii.z);
- expect(ellipsoid.getRadii()).toEqual(radii);
- expect(ellipsoid.getRadiiSquared()).toEqual(radiiSquared);
- expect(ellipsoid.getRadiiToTheFourth()).toEqual(radiiToTheFourth);
- expect(ellipsoid.getOneOverRadii()).toEqual(oneOverRadii);
- expect(ellipsoid.getOneOverRadiiSquared()).toEqual(oneOverRadiiSquared);
- expect(ellipsoid.getMinimumRadius()).toEqual(minimumRadius);
- expect(ellipsoid.getMaximumRadius()).toEqual(maximumRadius);
+ expect(ellipsoid.radii).toEqual(radii);
+ expect(ellipsoid.radiiSquared).toEqual(radiiSquared);
+ expect(ellipsoid.radiiToTheFourth).toEqual(radiiToTheFourth);
+ expect(ellipsoid.oneOverRadii).toEqual(oneOverRadii);
+ expect(ellipsoid.oneOverRadiiSquared).toEqual(oneOverRadiiSquared);
+ expect(ellipsoid.minimumRadius).toEqual(minimumRadius);
+ expect(ellipsoid.maximumRadius).toEqual(maximumRadius);
});
it('fromCartesian3 computes correct values', function() {
var ellipsoid = Ellipsoid.fromCartesian3(radii);
- expect(ellipsoid.getRadii()).toEqual(radii);
- expect(ellipsoid.getRadiiSquared()).toEqual(radiiSquared);
- expect(ellipsoid.getRadiiToTheFourth()).toEqual(radiiToTheFourth);
- expect(ellipsoid.getOneOverRadii()).toEqual(oneOverRadii);
- expect(ellipsoid.getOneOverRadiiSquared()).toEqual(oneOverRadiiSquared);
- expect(ellipsoid.getMinimumRadius()).toEqual(minimumRadius);
- expect(ellipsoid.getMaximumRadius()).toEqual(maximumRadius);
+ expect(ellipsoid.radii).toEqual(radii);
+ expect(ellipsoid.radiiSquared).toEqual(radiiSquared);
+ expect(ellipsoid.radiiToTheFourth).toEqual(radiiToTheFourth);
+ expect(ellipsoid.oneOverRadii).toEqual(oneOverRadii);
+ expect(ellipsoid.oneOverRadiiSquared).toEqual(oneOverRadiiSquared);
+ expect(ellipsoid.minimumRadius).toEqual(minimumRadius);
+ expect(ellipsoid.maximumRadius).toEqual(maximumRadius);
});
it('geodeticSurfaceNormalCartographic works without a result parameter', function() {
diff --git a/Specs/Core/EllipsoidTangentPlaneSpec.js b/Specs/Core/EllipsoidTangentPlaneSpec.js
index 2f9233abaca2..b1a30717ebb6 100644
--- a/Specs/Core/EllipsoidTangentPlaneSpec.js
+++ b/Specs/Core/EllipsoidTangentPlaneSpec.js
@@ -15,7 +15,7 @@ defineSuite([
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
it('constructor defaults to WGS84', function() {
- var origin = new Cartesian3(Ellipsoid.WGS84.getRadii().x, 0, 0);
+ var origin = new Cartesian3(Ellipsoid.WGS84.radii.x, 0, 0);
var tangentPlane = new EllipsoidTangentPlane(origin);
expect(tangentPlane.getEllipsoid()).toBe(Ellipsoid.WGS84);
expect(tangentPlane.getOrigin()).toEqual(origin);
diff --git a/Specs/Core/EllipsoidalOccluderSpec.js b/Specs/Core/EllipsoidalOccluderSpec.js
index e2c63347498d..7ee701bf9032 100644
--- a/Specs/Core/EllipsoidalOccluderSpec.js
+++ b/Specs/Core/EllipsoidalOccluderSpec.js
@@ -27,7 +27,7 @@ defineSuite([
it('uses ellipsoid', function() {
var ellipsoid = new Ellipsoid(2.0, 3.0, 4.0);
var occluder = new EllipsoidalOccluder(ellipsoid);
- expect(occluder.getEllipsoid()).toEqual(ellipsoid);
+ expect(occluder.ellipsoid).toEqual(ellipsoid);
});
it('throws if ellipsoid is not provided to constructor', function() {
@@ -57,7 +57,7 @@ defineSuite([
it('reports not visible when point is directly behind ellipsoid', function() {
var ellipsoid = Ellipsoid.WGS84;
var occluder = new EllipsoidalOccluder(ellipsoid);
- occluder.setCameraPosition(new Cartesian3(7000000.0, 0.0, 0.0));
+ occluder.cameraPosition = new Cartesian3(7000000.0, 0.0, 0.0);
var point = new Cartesian3(-7000000, 0.0, 0.0);
expect(occluder.isPointVisible(point)).toEqual(false);
@@ -66,7 +66,7 @@ defineSuite([
it('reports visible when point is in front of ellipsoid', function() {
var ellipsoid = Ellipsoid.WGS84;
var occluder = new EllipsoidalOccluder(ellipsoid);
- occluder.setCameraPosition(new Cartesian3(7000000.0, 0.0, 0.0));
+ occluder.cameraPosition = new Cartesian3(7000000.0, 0.0, 0.0);
var point = new Cartesian3(6900000.0, 0.0, 0.0);
expect(occluder.isPointVisible(point)).toEqual(true);
@@ -75,7 +75,7 @@ defineSuite([
it('reports visible when point is in opposite direction from ellipsoid', function() {
var ellipsoid = Ellipsoid.WGS84;
var occluder = new EllipsoidalOccluder(ellipsoid);
- occluder.setCameraPosition(new Cartesian3(7000000.0, 0.0, 0.0));
+ occluder.cameraPosition = new Cartesian3(7000000.0, 0.0, 0.0);
var point = new Cartesian3(7100000.0, 0.0, 0.0);
expect(occluder.isPointVisible(point)).toEqual(true);
@@ -84,7 +84,7 @@ defineSuite([
it('reports not visible when point is over horizon', function() {
var ellipsoid = Ellipsoid.WGS84;
var occluder = new EllipsoidalOccluder(ellipsoid);
- occluder.setCameraPosition(new Cartesian3(7000000.0, 0.0, 0.0));
+ occluder.cameraPosition = new Cartesian3(7000000.0, 0.0, 0.0);
var point = new Cartesian3(4510635.0, 4510635.0, 0.0);
expect(occluder.isPointVisible(point)).toEqual(false);
@@ -148,7 +148,7 @@ defineSuite([
var firstPositionArray = [positions[0]];
var result = ellipsoidalOccluder.computeHorizonCullingPoint(boundingSphere.center, firstPositionArray);
- var unscaledResult = Cartesian3.multiplyComponents(result, ellipsoid.getRadii());
+ var unscaledResult = Cartesian3.multiplyComponents(result, ellipsoid.radii);
// The grazing altitude of the ray from the horizon culling point to the
// position used to compute it should be very nearly zero.
@@ -166,7 +166,7 @@ defineSuite([
var boundingSphere = BoundingSphere.fromPoints(positions);
var result = ellipsoidalOccluder.computeHorizonCullingPoint(boundingSphere.center, positions);
- var unscaledResult = Cartesian3.multiplyComponents(result, ellipsoid.getRadii());
+ var unscaledResult = Cartesian3.multiplyComponents(result, ellipsoid.radii);
// The grazing altitude of the ray from the horizon culling point to the
// position used to compute it should be very nearly zero.
@@ -269,7 +269,7 @@ defineSuite([
var extent = new Extent(0.1, 0.2, 0.3, 0.4);
var result = ellipsoidalOccluder.computeHorizonCullingPointFromExtent(extent, ellipsoid);
expect(result).toBeDefined();
- var unscaledResult = Cartesian3.multiplyComponents(result, ellipsoid.getRadii());
+ var unscaledResult = Cartesian3.multiplyComponents(result, ellipsoid.radii);
// The grazing altitude of the ray from the horizon culling point to the
// position used to compute it should be very nearly zero.
diff --git a/Specs/Core/GeographicProjectionSpec.js b/Specs/Core/GeographicProjectionSpec.js
index fdf6f50c2b1a..e1fa7e1304c0 100644
--- a/Specs/Core/GeographicProjectionSpec.js
+++ b/Specs/Core/GeographicProjectionSpec.js
@@ -35,7 +35,7 @@ defineSuite([
it('project1', function() {
var ellipsoid = Ellipsoid.WGS84;
var cartographic = new Cartographic(Math.PI, CesiumMath.PI_OVER_TWO, 0.0);
- var expected = new Cartesian3(Math.PI * ellipsoid.getRadii().x, CesiumMath.PI_OVER_TWO * ellipsoid.getRadii().x, 0.0);
+ var expected = new Cartesian3(Math.PI * ellipsoid.radii.x, CesiumMath.PI_OVER_TWO * ellipsoid.radii.x, 0.0);
var projection = new GeographicProjection(ellipsoid);
expect(projection.project(cartographic)).toEqual(expected);
});
@@ -51,7 +51,7 @@ defineSuite([
it('project3', function() {
var ellipsoid = Ellipsoid.WGS84;
var cartographic = new Cartographic(Math.PI, CesiumMath.PI_OVER_TWO, 0.0);
- var expected = new Cartesian3(Math.PI * ellipsoid.getRadii().x, CesiumMath.PI_OVER_TWO * ellipsoid.getRadii().x, 0.0);
+ var expected = new Cartesian3(Math.PI * ellipsoid.radii.x, CesiumMath.PI_OVER_TWO * ellipsoid.radii.x, 0.0);
var projection = new GeographicProjection(ellipsoid);
var result = new Cartesian3(0.0, 0.0, 0.0);
var returnValue = projection.project(cartographic, result);
diff --git a/Specs/Core/IntersectionTestsSpec.js b/Specs/Core/IntersectionTestsSpec.js
index b3b4e3d04fc9..e0f779e0c94c 100644
--- a/Specs/Core/IntersectionTestsSpec.js
+++ b/Specs/Core/IntersectionTestsSpec.js
@@ -132,7 +132,7 @@ defineSuite([
var expected = {
start : 0.0,
- stop : ellipsoid.getRadii().x + origin.x
+ stop : ellipsoid.radii.x + origin.x
};
var actual = IntersectionTests.rayEllipsoid(ray, ellipsoid);
@@ -150,7 +150,7 @@ defineSuite([
var expected = {
start : 0.0,
- stop : ellipsoid.getRadii().x - origin.x
+ stop : ellipsoid.radii.x - origin.x
};
var actual = IntersectionTests.rayEllipsoid(ray, ellipsoid);
diff --git a/Specs/Core/OccluderSpec.js b/Specs/Core/OccluderSpec.js
index 0d8cc904afa3..1b69b9b75adb 100644
--- a/Specs/Core/OccluderSpec.js
+++ b/Specs/Core/OccluderSpec.js
@@ -273,7 +273,7 @@ defineSuite([
var ellipsoid = Ellipsoid.WGS84;
var positions = extent.subsample(ellipsoid);
var bs = BoundingSphere.fromPoints(positions);
- var point = Occluder.getOccludeePoint(new BoundingSphere(Cartesian3.ZERO, ellipsoid.getMinimumRadius()), bs.center, positions);
+ var point = Occluder.getOccludeePoint(new BoundingSphere(Cartesian3.ZERO, ellipsoid.minimumRadius), bs.center, positions);
var actual = Occluder.computeOccludeePointFromExtent(extent);
expect(actual).toEqual(point);
});
diff --git a/Specs/Core/TimeIntervalCollectionSpec.js b/Specs/Core/TimeIntervalCollectionSpec.js
index 1a5bc3a99b43..08a226990eb9 100644
--- a/Specs/Core/TimeIntervalCollectionSpec.js
+++ b/Specs/Core/TimeIntervalCollectionSpec.js
@@ -28,6 +28,7 @@ defineSuite([
expect(intervals.getStart()).toBeUndefined();
expect(intervals.getStop()).toBeUndefined();
expect(intervals.isEmpty()).toEqual(true);
+ expect(intervals.getChangedEvent()).toBeDefined();
});
it('contains works for a simple interval collection.', function() {
@@ -567,4 +568,25 @@ defineSuite([
intervals.intersectInterval(undefined);
}).toThrowDeveloperError();
});
+
+ it('changed event is raised as expected', function() {
+ var interval = new TimeInterval(new JulianDate(10, 0), new JulianDate(12, 0), true, true);
+
+ var intervals = new TimeIntervalCollection();
+
+ var listener = jasmine.createSpy('listener');
+ intervals.getChangedEvent().addEventListener(listener);
+
+ intervals.addInterval(interval);
+ expect(listener).toHaveBeenCalledWith(intervals);
+ listener.reset();
+
+ intervals.removeInterval(interval);
+ expect(listener).toHaveBeenCalledWith(intervals);
+
+ intervals.addInterval(interval);
+ listener.reset();
+ intervals.clear();
+ expect(listener).toHaveBeenCalledWith(intervals);
+ });
});
diff --git a/Specs/Core/WallGeometrySpec.js b/Specs/Core/WallGeometrySpec.js
index 93b83cc0db88..3cc845184f1d 100644
--- a/Specs/Core/WallGeometrySpec.js
+++ b/Specs/Core/WallGeometrySpec.js
@@ -63,6 +63,17 @@ defineSuite([
}).toThrowDeveloperError();
});
+ it('does not throw when positions are unique but close', function() {
+ expect(function() {
+ return WallGeometry.createGeometry(new WallGeometry({
+ vertexFormat : VertexFormat.POSITION_ONLY,
+ positions : ellipsoid.cartographicArrayToCartesianArray([
+ Cartographic.fromDegrees(-47.93121266896352,-15.771192496304398),
+ Cartographic.fromDegrees(-47.93119792786269,-15.771148001875085)])
+ }));
+ }).not.toThrowDeveloperError();
+ });
+
it('creates positions relative to ellipsoid', function() {
var coords = [
Cartographic.fromDegrees(49.0, 18.0, 1000.0),
diff --git a/Specs/Core/WebMercatorProjectionSpec.js b/Specs/Core/WebMercatorProjectionSpec.js
index c383e9f0b3d1..749114be9c60 100644
--- a/Specs/Core/WebMercatorProjectionSpec.js
+++ b/Specs/Core/WebMercatorProjectionSpec.js
@@ -41,8 +41,8 @@ defineSuite([
// expected equations from Wolfram MathWorld:
// http://mathworld.wolfram.com/MercatorProjection.html
var expected = new Cartesian3(
- ellipsoid.getMaximumRadius() * cartographic.longitude,
- ellipsoid.getMaximumRadius() * Math.log(Math.tan(Math.PI / 4.0 + cartographic.latitude / 2.0)),
+ ellipsoid.maximumRadius * cartographic.longitude,
+ ellipsoid.maximumRadius * Math.log(Math.tan(Math.PI / 4.0 + cartographic.latitude / 2.0)),
0.0);
var projection = new WebMercatorProjection(ellipsoid);
@@ -56,8 +56,8 @@ defineSuite([
// expected equations from Wolfram MathWorld:
// http://mathworld.wolfram.com/MercatorProjection.html
var expected = new Cartesian3(
- ellipsoid.getMaximumRadius() * cartographic.longitude,
- ellipsoid.getMaximumRadius() * Math.log(Math.tan(Math.PI / 4.0 + cartographic.latitude / 2.0)),
+ ellipsoid.maximumRadius * cartographic.longitude,
+ ellipsoid.maximumRadius * Math.log(Math.tan(Math.PI / 4.0 + cartographic.latitude / 2.0)),
0.0);
var projection = new WebMercatorProjection(ellipsoid);
@@ -71,8 +71,8 @@ defineSuite([
// expected equations from Wolfram MathWorld:
// http://mathworld.wolfram.com/MercatorProjection.html
var expected = new Cartesian3(
- ellipsoid.getMaximumRadius() * cartographic.longitude,
- ellipsoid.getMaximumRadius() * Math.log(Math.tan(Math.PI / 4.0 + cartographic.latitude / 2.0)),
+ ellipsoid.maximumRadius * cartographic.longitude,
+ ellipsoid.maximumRadius * Math.log(Math.tan(Math.PI / 4.0 + cartographic.latitude / 2.0)),
0.0);
var projection = new WebMercatorProjection(ellipsoid);
diff --git a/Specs/Core/combineSpec.js b/Specs/Core/combineSpec.js
index bd4804789734..ad6573d1e08b 100644
--- a/Specs/Core/combineSpec.js
+++ b/Specs/Core/combineSpec.js
@@ -63,4 +63,21 @@ defineSuite([
}
});
});
+
+ it('can accept undefined as either object', function() {
+ var object = {
+ one : 1,
+ deep : {
+ value1 : 10
+ }
+ };
+
+ expect(combine(undefined, object)).toEqual(object);
+ expect(combine(undefined, object, true)).toEqual(object);
+ expect(combine(object, undefined)).toEqual(object);
+ expect(combine(object, undefined, true)).toEqual(object);
+
+ expect(combine(undefined, undefined)).toEqual({});
+ expect(combine(undefined, undefined, true)).toEqual({});
+ });
});
\ No newline at end of file
diff --git a/Specs/DynamicScene/ColorMaterialPropertySpec.js b/Specs/DynamicScene/ColorMaterialPropertySpec.js
index 505b08cc67c2..b08f77699e3f 100644
--- a/Specs/DynamicScene/ColorMaterialPropertySpec.js
+++ b/Specs/DynamicScene/ColorMaterialPropertySpec.js
@@ -1,30 +1,34 @@
/*global defineSuite*/
-defineSuite([
- 'DynamicScene/ColorMaterialProperty',
+defineSuite(['DynamicScene/ColorMaterialProperty',
'DynamicScene/ConstantProperty',
'DynamicScene/TimeIntervalCollectionProperty',
'Core/Color',
'Core/JulianDate',
- 'Core/TimeInterval',
- 'Specs/UndefinedProperty'
+ 'Core/TimeInterval'
], function(
ColorMaterialProperty,
ConstantProperty,
TimeIntervalCollectionProperty,
Color,
JulianDate,
- TimeInterval,
- UndefinedProperty) {
+ TimeInterval) {
"use strict";
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
- it('works with basic types', function() {
+ it('constructor provides the expected defaults', function() {
var property = new ColorMaterialProperty();
- expect(property.color).toBeDefined();
+ expect(property.color).toEqual(new ConstantProperty(Color.WHITE));
expect(property.getType()).toEqual('Color');
+ expect(property.isConstant).toBe(true);
- var result = property.getValue();
- expect(result.color).toEqual(Color.WHITE);
+ var colorProperty = new ConstantProperty(Color.BLUE);
+ property = new ColorMaterialProperty(colorProperty);
+ expect(property.color).toBe(colorProperty);
+ expect(property.getType()).toEqual('Color');
+ expect(property.isConstant).toBe(true);
+
+ property = ColorMaterialProperty.fromColor(Color.BLUE);
+ expect(property.color).toEqual(colorProperty);
});
it('works with constant values', function() {
@@ -37,7 +41,7 @@ defineSuite([
it('works with undefined values', function() {
var property = new ColorMaterialProperty();
- property.color = new UndefinedProperty();
+ property.color = new ConstantProperty();
var result = property.getValue();
expect(result.hasOwnProperty('color')).toEqual(true);
@@ -52,6 +56,8 @@ defineSuite([
var stop = new JulianDate(2, 0);
property.color.intervals.addInterval(new TimeInterval(start, stop, true, true, Color.BLUE));
+ expect(property.isConstant).toBe(false);
+
var result = property.getValue(start);
expect(result.color).toEqual(Color.BLUE);
});
@@ -79,4 +85,23 @@ defineSuite([
right.color = new ConstantProperty(Color.BLACK);
expect(left.equals(right)).toEqual(false);
});
+
+ it('raises definitionChanged when a color property is assigned or modified', function() {
+ var property = new ColorMaterialProperty();
+
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
+ var oldValue = property.color;
+ property.color = new ConstantProperty(Color.WHITE);
+ expect(listener).toHaveBeenCalledWith(property, 'color', property.color, oldValue);
+ listener.reset();
+
+ property.color.setValue(Color.BLACK);
+ expect(listener).toHaveBeenCalledWith(property, 'color', property.color, property.color);
+ listener.reset();
+
+ property.color = property.color;
+ expect(listener.callCount).toEqual(0);
+ });
});
\ No newline at end of file
diff --git a/Specs/DynamicScene/CompositeDynamicObjectCollectionSpec.js b/Specs/DynamicScene/CompositeDynamicObjectCollectionSpec.js
index 6ce3de381629..a911c15d08a0 100644
--- a/Specs/DynamicScene/CompositeDynamicObjectCollectionSpec.js
+++ b/Specs/DynamicScene/CompositeDynamicObjectCollectionSpec.js
@@ -553,6 +553,35 @@ defineSuite([
expect(composite2.getById(id).position).toBe(dynamicObject2.position);
});
+ it('suspend events suspends recompositing', function() {
+ var id = 'test';
+ var collection1 = new DynamicObjectCollection();
+ var dynamicObject1 = new DynamicObject(id);
+ collection1.add(dynamicObject1);
+
+ var collection2 = new DynamicObjectCollection();
+ var dynamicObject2 = new DynamicObject(id);
+ collection2.add(dynamicObject2);
+ //Add collections in reverse order to lower numbers of priority
+ var composite = new CompositeDynamicObjectCollection();
+ composite.addCollection(collection2);
+
+ // suspend events
+ composite.suspendEvents();
+ composite.addCollection(collection1);
+
+ // add a billboard
+ var compositeObject = composite.getById(id);
+ dynamicObject1.billboard = new DynamicBillboard();
+ dynamicObject1.billboard.show = new ConstantProperty(false);
+ // should be undefined because we haven't recomposited
+ expect(compositeObject.billboard).toBeUndefined();
+ // resume events
+ composite.resumeEvents();
+
+ expect(compositeObject.billboard.show).toBe(dynamicObject1.billboard.show);
+ });
+
it('prevents names from colliding between property events and object events', function() {
var id = 'test';
var collection1 = new DynamicObjectCollection();
diff --git a/Specs/DynamicScene/CompositeMaterialPropertySpec.js b/Specs/DynamicScene/CompositeMaterialPropertySpec.js
index cd36375bf641..ba77e739be17 100644
--- a/Specs/DynamicScene/CompositeMaterialPropertySpec.js
+++ b/Specs/DynamicScene/CompositeMaterialPropertySpec.js
@@ -1,17 +1,16 @@
/*global defineSuite*/
-defineSuite([
- 'DynamicScene/CompositeMaterialProperty',
- 'DynamicScene/ConstantProperty',
+defineSuite(['DynamicScene/CompositeMaterialProperty',
'DynamicScene/ColorMaterialProperty',
'DynamicScene/GridMaterialProperty',
+ 'Core/Color',
'Core/JulianDate',
'Core/TimeInterval',
'Core/TimeIntervalCollection'
], function(
CompositeMaterialProperty,
- ConstantProperty,
ColorMaterialProperty,
GridMaterialProperty,
+ Color,
JulianDate,
TimeInterval,
TimeIntervalCollection) {
@@ -21,6 +20,7 @@ defineSuite([
it('default constructor has expected values', function() {
var property = new CompositeMaterialProperty();
expect(property.intervals).toBeInstanceOf(TimeIntervalCollection);
+ expect(property.isConstant).toBe(true);
expect(property.getType(new JulianDate())).toBeUndefined();
expect(property.getValue(new JulianDate())).toBeUndefined();
});
@@ -32,6 +32,7 @@ defineSuite([
var property = new CompositeMaterialProperty();
property.intervals.addInterval(interval1);
property.intervals.addInterval(interval2);
+ expect(property.isConstant).toBe(false);
var result1 = property.getValue(interval1.start);
expect(property.getType(interval1.start)).toEqual('Color');
@@ -51,6 +52,7 @@ defineSuite([
var property = new CompositeMaterialProperty();
property.intervals.addInterval(interval1);
property.intervals.addInterval(interval2);
+ expect(property.isConstant).toBe(false);
var expected = {};
var result1 = property.getValue(interval1.start, expected);
@@ -79,6 +81,52 @@ defineSuite([
expect(left.equals(right)).toEqual(true);
});
+ it('raises definitionChanged event in all cases', function() {
+ var interval1 = new TimeInterval(new JulianDate(10, 0), new JulianDate(12, 0), true, true, ColorMaterialProperty.fromColor(Color.RED));
+ var interval2 = new TimeInterval(new JulianDate(12, 0), new JulianDate(14, 0), false, true, ColorMaterialProperty.fromColor(Color.YELLOW));
+
+ var property = new CompositeMaterialProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
+ property.intervals.addInterval(interval1);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ property.intervals.addInterval(interval2);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ property.intervals.removeInterval(interval2);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ interval1.data.color.setValue(Color.BLUE);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ property.intervals.clear();
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+ });
+
+ it('does not raise definitionChanged for an overwritten interval', function() {
+ var interval1 = new TimeInterval(new JulianDate(11, 0), new JulianDate(13, 0), true, true, ColorMaterialProperty.fromColor(Color.RED));
+ var interval2 = new TimeInterval(new JulianDate(10, 0), new JulianDate(14, 0), false, true, ColorMaterialProperty.fromColor(Color.YELLOW));
+
+ var property = new CompositeMaterialProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
+ property.intervals.addInterval(interval1);
+ property.intervals.addInterval(interval2);
+ expect(listener.callCount).toBe(2);
+
+ //interval2 overwrites interval1, so callCount should not increase.
+ interval1.data.color.setValue(Color.BLUE);
+ expect(listener.callCount).toBe(2);
+ });
+
it('getValue throws with no time parameter', function() {
var property = new CompositeMaterialProperty();
expect(function() {
diff --git a/Specs/DynamicScene/CompositePositionPropertySpec.js b/Specs/DynamicScene/CompositePositionPropertySpec.js
index e93edc93dd83..ea5149fa2286 100644
--- a/Specs/DynamicScene/CompositePositionPropertySpec.js
+++ b/Specs/DynamicScene/CompositePositionPropertySpec.js
@@ -1,6 +1,5 @@
/*global defineSuite*/
-defineSuite([
- 'DynamicScene/CompositePositionProperty',
+defineSuite(['DynamicScene/CompositePositionProperty',
'DynamicScene/ConstantPositionProperty',
'DynamicScene/PositionProperty',
'Core/Cartesian3',
@@ -25,6 +24,7 @@ defineSuite([
expect(property.intervals).toBeInstanceOf(TimeIntervalCollection);
expect(property.getValue(new JulianDate())).toBeUndefined();
expect(property.referenceFrame).toBe(ReferenceFrame.FIXED);
+ expect(property.isConstant).toBe(true);
});
it('constructor sets expected values', function() {
@@ -46,6 +46,7 @@ defineSuite([
var property = new CompositePositionProperty();
property.intervals.addInterval(interval1);
property.intervals.addInterval(interval2);
+ expect(property.isConstant).toBe(false);
var result1 = property.getValue(interval1.start);
expect(result1).not.toBe(interval1.data.getValue(interval1.start));
@@ -63,6 +64,7 @@ defineSuite([
var property = new CompositePositionProperty();
property.intervals.addInterval(interval1);
property.intervals.addInterval(interval2);
+ expect(property.isConstant).toBe(false);
var expected = new Cartesian3();
var result1 = property.getValue(interval1.start, expected);
@@ -173,4 +175,50 @@ defineSuite([
property.getValueInReferenceFrame(time, undefined);
}).toThrowDeveloperError();
});
+
+ it('raises definitionChanged event in all cases', function() {
+ var interval1 = new TimeInterval(new JulianDate(10, 0), new JulianDate(12, 0), true, true, new ConstantPositionProperty(new Cartesian3(1, 2, 3)));
+ var interval2 = new TimeInterval(new JulianDate(12, 0), new JulianDate(14, 0), false, true, new ConstantPositionProperty(new Cartesian3(4, 5, 6)));
+
+ var property = new CompositePositionProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
+ property.intervals.addInterval(interval1);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ property.intervals.addInterval(interval2);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ property.intervals.removeInterval(interval2);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ interval1.data.setValue(new Cartesian3());
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ property.intervals.clear();
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+ });
+
+ it('does not raise definitionChanged for an overwritten interval', function() {
+ var interval1 = new TimeInterval(new JulianDate(11, 0), new JulianDate(13, 0), true, true, new ConstantPositionProperty(new Cartesian3(1, 2, 3)));
+ var interval2 = new TimeInterval(new JulianDate(10, 0), new JulianDate(14, 0), false, true, new ConstantPositionProperty(new Cartesian3(4, 5, 6)));
+
+ var property = new CompositePositionProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
+ property.intervals.addInterval(interval1);
+ property.intervals.addInterval(interval2);
+ expect(listener.callCount).toBe(2);
+
+ //interval2 overwrites interval1, so callCount should not increase.
+ interval1.data.setValue(new Cartesian3());
+ expect(listener.callCount).toBe(2);
+ });
});
\ No newline at end of file
diff --git a/Specs/DynamicScene/CompositePropertySpec.js b/Specs/DynamicScene/CompositePropertySpec.js
index 0e6cdbbc5338..7a3dbda34b28 100644
--- a/Specs/DynamicScene/CompositePropertySpec.js
+++ b/Specs/DynamicScene/CompositePropertySpec.js
@@ -1,6 +1,5 @@
/*global defineSuite*/
-defineSuite([
- 'DynamicScene/CompositeProperty',
+defineSuite(['DynamicScene/CompositeProperty',
'DynamicScene/ConstantProperty',
'Core/Cartesian3',
'Core/JulianDate',
@@ -20,6 +19,7 @@ defineSuite([
var property = new CompositeProperty();
expect(property.intervals).toBeInstanceOf(TimeIntervalCollection);
expect(property.getValue(new JulianDate())).toBeUndefined();
+ expect(property.isConstant).toBe(true);
});
it('works without a result parameter', function() {
@@ -29,6 +29,7 @@ defineSuite([
var property = new CompositeProperty();
property.intervals.addInterval(interval1);
property.intervals.addInterval(interval2);
+ expect(property.isConstant).toBe(false);
var result1 = property.getValue(interval1.start);
expect(result1).not.toBe(interval1.data.getValue(interval1.start));
@@ -46,6 +47,7 @@ defineSuite([
var property = new CompositeProperty();
property.intervals.addInterval(interval1);
property.intervals.addInterval(interval2);
+ expect(property.isConstant).toBe(false);
var expected = new Cartesian3();
var result1 = property.getValue(interval1.start, expected);
@@ -73,6 +75,52 @@ defineSuite([
expect(left.equals(right)).toEqual(true);
});
+ it('raises definitionChanged event in all cases', function() {
+ var interval1 = new TimeInterval(new JulianDate(10, 0), new JulianDate(12, 0), true, true, new ConstantProperty(new Cartesian3(1, 2, 3)));
+ var interval2 = new TimeInterval(new JulianDate(12, 0), new JulianDate(14, 0), false, true, new ConstantProperty(new Cartesian3(4, 5, 6)));
+
+ var property = new CompositeProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
+ property.intervals.addInterval(interval1);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ property.intervals.addInterval(interval2);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ property.intervals.removeInterval(interval2);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ interval1.data.setValue(new Cartesian3());
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ property.intervals.clear();
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+ });
+
+ it('does not raise definitionChanged for an overwritten interval', function() {
+ var interval1 = new TimeInterval(new JulianDate(11, 0), new JulianDate(13, 0), true, true, new ConstantProperty(new Cartesian3(1, 2, 3)));
+ var interval2 = new TimeInterval(new JulianDate(10, 0), new JulianDate(14, 0), false, true, new ConstantProperty(new Cartesian3(4, 5, 6)));
+
+ var property = new CompositeProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
+ property.intervals.addInterval(interval1);
+ property.intervals.addInterval(interval2);
+ expect(listener.callCount).toBe(2);
+
+ //interval2 overwrites interval1, so callCount should not increase.
+ interval1.data.setValue(new Cartesian3());
+ expect(listener.callCount).toBe(2);
+ });
+
it('getValue throws with no time parameter', function() {
var property = new CompositeProperty();
expect(function() {
diff --git a/Specs/DynamicScene/ConstantPositionPropertySpec.js b/Specs/DynamicScene/ConstantPositionPropertySpec.js
index ea12530c5946..38bb8bf395c3 100644
--- a/Specs/DynamicScene/ConstantPositionPropertySpec.js
+++ b/Specs/DynamicScene/ConstantPositionPropertySpec.js
@@ -1,6 +1,5 @@
/*global defineSuite*/
-defineSuite([
- 'DynamicScene/ConstantPositionProperty',
+defineSuite(['DynamicScene/ConstantPositionProperty',
'DynamicScene/PositionProperty',
'Core/Cartesian3',
'Core/JulianDate',
@@ -17,7 +16,7 @@ defineSuite([
var time = new JulianDate();
it('Constructor sets expected defaults', function() {
- var property = new ConstantPositionProperty(new Cartesian3(1, 2, 3));
+ var property = new ConstantPositionProperty();
expect(property.referenceFrame).toBe(ReferenceFrame.FIXED);
property = new ConstantPositionProperty(new Cartesian3(1, 2, 3), ReferenceFrame.INERTIAL);
@@ -52,6 +51,16 @@ defineSuite([
expect(result).toEqual(valueFixed);
});
+ it('getValue works with undefined fixed value', function() {
+ var property = new ConstantPositionProperty(undefined);
+ expect(property.getValue(time)).toBeUndefined();
+ });
+
+ it('getValue work swith undefined inertial value', function() {
+ var property = new ConstantPositionProperty(undefined, ReferenceFrame.INERTIAL);
+ expect(property.getValue(time)).toBeUndefined();
+ });
+
it('getValueInReferenceFrame works without a result parameter', function() {
var value = new Cartesian3(1, 2, 3);
var property = new ConstantPositionProperty(value);
@@ -71,6 +80,30 @@ defineSuite([
expect(expected).toEqual(PositionProperty.convertToReferenceFrame(time, value, ReferenceFrame.INERTIAL, ReferenceFrame.FIXED));
});
+ it('setValue rasies definitionChanged event', function() {
+ var property = new ConstantPositionProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+ property.setValue(new Cartesian3(1, 2, 3));
+ expect(listener).toHaveBeenCalledWith(property);
+ });
+
+ it('setValue does not raise definitionChanged event with equal data', function() {
+ var property = new ConstantPositionProperty(new Cartesian3(0, 0, 0));
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+ property.setValue(new Cartesian3(0, 0, 0));
+ expect(listener.callCount).toBe(0);
+ });
+
+ it('setValue raises definitionChanged when referenceFrame changes', function() {
+ var property = new ConstantPositionProperty(new Cartesian3(0, 0, 0), ReferenceFrame.FIXED);
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+ property.setValue(new Cartesian3(0, 0, 0), ReferenceFrame.INERTIAL);
+ expect(listener).toHaveBeenCalledWith(property);
+ });
+
it('equals works', function() {
var left = new ConstantPositionProperty(new Cartesian3(1, 2, 3), ReferenceFrame.INERTIAL);
var right = new ConstantPositionProperty(new Cartesian3(1, 2, 3), ReferenceFrame.INERTIAL);
@@ -84,12 +117,6 @@ defineSuite([
expect(left.equals(right)).toEqual(false);
});
- it('constructor throws with undefined value', function() {
- expect(function() {
- return new ConstantPositionProperty(undefined);
- }).toThrowDeveloperError();
- });
-
it('getValue throws without time parameter', function() {
var property = new ConstantPositionProperty(new Cartesian3(1, 2, 3));
expect(function() {
@@ -99,7 +126,6 @@ defineSuite([
it('getValueInReferenceFrame throws with no referenceFrame parameter', function() {
var property = new ConstantPositionProperty(new Cartesian3(1, 2, 3));
- var time = new JulianDate();
expect(function() {
property.getValueInReferenceFrame(time, undefined);
}).toThrowDeveloperError();
diff --git a/Specs/DynamicScene/ConstantPropertySpec.js b/Specs/DynamicScene/ConstantPropertySpec.js
index a24d5e23e72d..9a63e0ef34c2 100644
--- a/Specs/DynamicScene/ConstantPropertySpec.js
+++ b/Specs/DynamicScene/ConstantPropertySpec.js
@@ -1,6 +1,5 @@
/*global defineSuite*/
-defineSuite([
- 'DynamicScene/ConstantProperty',
+defineSuite(['DynamicScene/ConstantProperty',
'Core/Cartesian3',
'Core/JulianDate'
], function(
@@ -18,7 +17,7 @@ defineSuite([
expect(property.getValue(time)).toBe(expected);
});
- it('works with clonable objects', function() {
+ it('works with objects', function() {
var value = new Cartesian3(1, 2, 3);
var property = new ConstantProperty(value);
@@ -27,7 +26,23 @@ defineSuite([
expect(result).toEqual(value);
});
- it('works with clonable objects with result parameter', function() {
+ it('setValue rasies definitionChanged event', function() {
+ var property = new ConstantProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+ property.setValue(5);
+ expect(listener).toHaveBeenCalledWith(property);
+ });
+
+ it('setValue does not raise definitionChanged event with equal data', function() {
+ var property = new ConstantProperty(new Cartesian3(0, 0, 0));
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+ property.setValue(new Cartesian3(0, 0, 0));
+ expect(listener.callCount).toBe(0);
+ });
+
+ it('works with objects with result parameter', function() {
var value = new Cartesian3(1, 2, 3);
var property = new ConstantProperty(value);
@@ -37,10 +52,9 @@ defineSuite([
expect(expected).toEqual(value);
});
- it('constructor throws with undefined value', function() {
- expect(function() {
- return new ConstantProperty(undefined);
- }).toThrowDeveloperError();
+ it('works with undefined value', function() {
+ var property = new ConstantProperty(undefined);
+ expect(property.getValue()).toBeUndefined();
});
it('constructor throws with undefined clone function on non-basic type', function() {
diff --git a/Specs/DynamicScene/CzmlDataSourceSpec.js b/Specs/DynamicScene/CzmlDataSourceSpec.js
index a19598090a7f..7af6354ebc69 100644
--- a/Specs/DynamicScene/CzmlDataSourceSpec.js
+++ b/Specs/DynamicScene/CzmlDataSourceSpec.js
@@ -11,6 +11,7 @@ defineSuite([
'Core/defined',
'Core/Ellipsoid',
'Core/Quaternion',
+ 'Core/ReferenceFrame',
'Core/Spherical',
'DynamicScene/DynamicBillboard',
'DynamicScene/DynamicObject',
@@ -35,6 +36,7 @@ defineSuite([
defined,
Ellipsoid,
Quaternion,
+ ReferenceFrame,
Spherical,
DynamicBillboard,
DynamicObject,
@@ -771,6 +773,62 @@ defineSuite([
expect(resultCartesian).toEqual(Ellipsoid.WGS84.cartographicToCartesian(cartographic));
});
+ it('Can set reference frame', function() {
+ var epoch = new JulianDate();
+ var dataSource = new CzmlDataSource();
+
+ var czml = {
+ position : {
+ referenceFrame : "INERTIAL",
+ epoch : epoch.toIso8601(),
+ cartesian : [1.0, 2.0, 3.0]
+ }
+ };
+
+ dataSource.load(czml);
+ var dynamicObject = dataSource.getDynamicObjectCollection().getObjects()[0];
+ expect(dynamicObject.position.referenceFrame).toBe(ReferenceFrame.INERTIAL);
+
+ czml = {
+ position : {
+ referenceFrame : "FIXED",
+ epoch : epoch.toIso8601(),
+ cartesian : [1.0, 2.0, 3.0]
+ }
+ };
+
+ dataSource.load(czml);
+ dynamicObject = dataSource.getDynamicObjectCollection().getObjects()[0];
+ expect(dynamicObject.position.referenceFrame).toBe(ReferenceFrame.FIXED);
+ });
+
+ it('Default reference frame on existing interval does not reset value to FIXED.', function() {
+ var epoch = new JulianDate();
+ var dataSource = new CzmlDataSource();
+
+ var czml = {
+ position : {
+ referenceFrame : "INERTIAL",
+ epoch : epoch.toIso8601(),
+ cartesian : [1.0, 2.0, 3.0]
+ }
+ };
+
+ dataSource.process(czml);
+ var dynamicObject = dataSource.getDynamicObjectCollection().getObjects()[0];
+ expect(dynamicObject.position.referenceFrame).toBe(ReferenceFrame.INERTIAL);
+
+ var czml2 = {
+ position : {
+ epoch : epoch.toIso8601(),
+ cartesian : [1.0, 2.0, 3.0]
+ }
+ };
+ dataSource.process(czml2);
+
+ expect(dynamicObject.position.referenceFrame).toBe(ReferenceFrame.INERTIAL);
+ });
+
it('CZML sampled cartographicRadians positions work.', function() {
var epoch = new JulianDate();
@@ -1305,6 +1363,10 @@ defineSuite([
}
}
},
+ height : 1,
+ extrudedHeight : 2,
+ granularity : 3,
+ stRotation : 4,
show : true
}
};
@@ -1316,6 +1378,10 @@ defineSuite([
expect(dynamicObject.polygon).toBeDefined();
expect(dynamicObject.polygon.material.getValue(Iso8601.MINIMUM_VALUE).color).toEqual(new Color(0.1, 0.1, 0.1, 0.1));
expect(dynamicObject.polygon.show.getValue(Iso8601.MINIMUM_VALUE)).toEqual(true);
+ expect(dynamicObject.polygon.height.getValue(Iso8601.MINIMUM_VALUE)).toEqual(1);
+ expect(dynamicObject.polygon.extrudedHeight.getValue(Iso8601.MINIMUM_VALUE)).toEqual(2);
+ expect(dynamicObject.polygon.granularity.getValue(Iso8601.MINIMUM_VALUE)).toEqual(3);
+ expect(dynamicObject.polygon.stRotation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(4);
});
it('CZML adds data for constrained polygon.', function() {
diff --git a/Specs/DynamicScene/DataSourceDisplaySpec.js b/Specs/DynamicScene/DataSourceDisplaySpec.js
index 31cd4dade441..03099612d6e4 100644
--- a/Specs/DynamicScene/DataSourceDisplaySpec.js
+++ b/Specs/DynamicScene/DataSourceDisplaySpec.js
@@ -65,11 +65,13 @@ defineSuite([
this.destroyed = true;
};
+ var visualizerCallback = function() {
+ return [new MockVisualizer()];
+ };
+
it('constructor sets expected values', function() {
- var visualizerTypes = [MockVisualizer];
- var display = new DataSourceDisplay(scene, dataSourceCollection, visualizerTypes);
+ var display = new DataSourceDisplay(scene, dataSourceCollection, visualizerCallback);
expect(display.getScene()).toBe(scene);
- expect(display.getVisualizerTypes()).toEqual(visualizerTypes);
expect(display.getDataSources()).toBe(dataSourceCollection);
expect(display.isDestroyed()).toEqual(false);
display.destroy();
@@ -94,14 +96,14 @@ defineSuite([
var dynamicSource = new MockDataSource();
dynamicSource.isTimeVarying = true;
- var display = new DataSourceDisplay(scene, dataSourceCollection, [MockVisualizer]);
+ var display = new DataSourceDisplay(scene, dataSourceCollection, visualizerCallback);
dataSourceCollection.add(staticSource);
dataSourceCollection.add(dynamicSource);
- var staticSourceVisualizer = staticSource._visualizerCollection.getVisualizers()[0];
+ var staticSourceVisualizer = staticSource._visualizers[0];
expect(staticSourceVisualizer).toBeInstanceOf(MockVisualizer);
- var dynamicSourceVisualizer = dynamicSource._visualizerCollection.getVisualizers()[0];
+ var dynamicSourceVisualizer = dynamicSource._visualizers[0];
expect(dynamicSourceVisualizer).toBeInstanceOf(MockVisualizer);
//Nothing should have happened yet because we haven't called update.
@@ -139,9 +141,9 @@ defineSuite([
var source = new MockDataSource();
dataSourceCollection.add(source);
- var display = new DataSourceDisplay(scene, dataSourceCollection, [MockVisualizer]);
+ var display = new DataSourceDisplay(scene, dataSourceCollection, visualizerCallback);
- var sourceVisualizer = source._visualizerCollection.getVisualizers()[0];
+ var sourceVisualizer = source._visualizers[0];
expect(sourceVisualizer).toBeInstanceOf(MockVisualizer);
//Nothing should have happened yet because we haven't called update.
diff --git a/Specs/DynamicScene/DynamicBillboardVisualizerSpec.js b/Specs/DynamicScene/DynamicBillboardVisualizerSpec.js
index f2d6ae1fa2e0..99a23c209eee 100644
--- a/Specs/DynamicScene/DynamicBillboardVisualizerSpec.js
+++ b/Specs/DynamicScene/DynamicBillboardVisualizerSpec.js
@@ -62,7 +62,7 @@ defineSuite([
visualizer = new DynamicBillboardVisualizer(scene, dynamicObjectCollection);
expect(visualizer.getScene()).toEqual(scene);
expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection);
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection instanceof BillboardCollection).toEqual(true);
});
@@ -94,7 +94,7 @@ defineSuite([
var testObject = dynamicObjectCollection.getOrCreateObject('test');
testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
visualizer.update(new JulianDate());
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection.getLength()).toEqual(0);
});
@@ -108,7 +108,7 @@ defineSuite([
billboard.image = new ConstantProperty('Data/Images/Blue.png');
visualizer.update(new JulianDate());
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection.getLength()).toEqual(0);
});
@@ -122,7 +122,7 @@ defineSuite([
billboard.show = new ConstantProperty(true);
visualizer.update(new JulianDate());
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection.getLength()).toEqual(0);
});
@@ -130,7 +130,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicBillboardVisualizer(scene, dynamicObjectCollection);
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection.getLength()).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
@@ -239,7 +239,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicBillboardVisualizer(scene, dynamicObjectCollection);
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection.getLength()).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
@@ -271,7 +271,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicBillboardVisualizer(scene, dynamicObjectCollection);
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection.getLength()).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
@@ -285,7 +285,7 @@ defineSuite([
visualizer.update(time);
expect(billboardCollection.getLength()).toEqual(1);
var bb = billboardCollection.get(0);
- expect(bb.dynamicObject).toEqual(testObject);
+ expect(bb.id).toEqual(testObject);
});
it('setDynamicObjectCollection removes old objects and add new ones.', function() {
@@ -306,17 +306,17 @@ defineSuite([
visualizer = new DynamicBillboardVisualizer(scene, dynamicObjectCollection);
var time = new JulianDate();
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
visualizer.update(time);
expect(billboardCollection.getLength()).toEqual(1);
var bb = billboardCollection.get(0);
- expect(bb.dynamicObject).toEqual(testObject);
+ expect(bb.id).toEqual(testObject);
visualizer.setDynamicObjectCollection(dynamicObjectCollection2);
visualizer.update(time);
expect(billboardCollection.getLength()).toEqual(1);
bb = billboardCollection.get(0);
- expect(bb.dynamicObject).toEqual(testObject2);
+ expect(bb.id).toEqual(testObject2);
});
}, 'WebGL');
diff --git a/Specs/DynamicScene/DynamicConeSpec.js b/Specs/DynamicScene/DynamicConeSpec.js
index 2804e0bea475..0190f117b970 100644
--- a/Specs/DynamicScene/DynamicConeSpec.js
+++ b/Specs/DynamicScene/DynamicConeSpec.js
@@ -3,13 +3,11 @@ defineSuite([
'DynamicScene/DynamicCone',
'DynamicScene/ColorMaterialProperty',
'DynamicScene/ConstantProperty',
- 'DynamicScene/DynamicVertexPositionsProperty',
'Core/Color'
], function(
DynamicCone,
ColorMaterialProperty,
ConstantProperty,
- DynamicVertexPositionsProperty,
Color) {
"use strict";
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
diff --git a/Specs/DynamicScene/DynamicConeVisualizerUsingCustomSensorSpec.js b/Specs/DynamicScene/DynamicConeVisualizerUsingCustomSensorSpec.js
index 4639c684cfe6..c2cc1f975765 100644
--- a/Specs/DynamicScene/DynamicConeVisualizerUsingCustomSensorSpec.js
+++ b/Specs/DynamicScene/DynamicConeVisualizerUsingCustomSensorSpec.js
@@ -93,7 +93,7 @@ defineSuite([
testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
testObject.orientation = new ConstantProperty(new Quaternion(0, 0, 0, 1));
visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
});
it('object with no position does not create a primitive.', function() {
@@ -106,7 +106,7 @@ defineSuite([
cone.maximumClockAngle = new ConstantProperty(1);
cone.outerHalfAngle = new ConstantProperty(1);
visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
});
it('object with no orientation does not create a primitive.', function() {
@@ -119,7 +119,7 @@ defineSuite([
cone.maximumClockAngle = new ConstantProperty(1);
cone.outerHalfAngle = new ConstantProperty(1);
visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
});
it('A DynamicCone causes a ComplexConicSensor to be created and updated.', function() {
@@ -145,8 +145,8 @@ defineSuite([
cone.outerMaterial = new ColorMaterialProperty();
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var c = scene.getPrimitives().get(0);
+ expect(scene.primitives.length).toEqual(1);
+ var c = scene.primitives.get(0);
expect(c.minimumClockAngle).toEqual(testObject.cone.minimumClockAngle.getValue(time));
expect(c.maximumClockAngle).toEqual(testObject.cone.maximumClockAngle.getValue(time));
expect(c.innerHalfAngle).toEqual(testObject.cone.innerHalfAngle.getValue(time));
@@ -185,11 +185,11 @@ defineSuite([
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(2);
- var c = scene.getPrimitives().get(0);
+ expect(scene.primitives.length).toEqual(2);
+ var c = scene.primitives.get(0);
expect(c.intersectionColor).toEqual(testObject.cone.intersectionColor.getValue(time));
- c = scene.getPrimitives().get(1);
+ c = scene.primitives.get(1);
expect(c.intersectionColor).toEqual(testObject2.cone.intersectionColor.getValue(time));
});
@@ -205,8 +205,8 @@ defineSuite([
testObject.cone = new DynamicCone();
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var c = scene.getPrimitives().get(0);
+ expect(scene.primitives.length).toEqual(1);
+ var c = scene.primitives.get(0);
expect(c.minimumClockAngle).toEqual(0.0);
expect(c.maximumClockAngle).toEqual(CesiumMath.TWO_PI);
expect(c.innerHalfAngle).toEqual(0);
@@ -227,14 +227,14 @@ defineSuite([
cone.outerHalfAngle = new ConstantProperty(1);
var time = new JulianDate();
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- expect(scene.getPrimitives().get(0).show).toEqual(true);
+ expect(scene.primitives.length).toEqual(1);
+ expect(scene.primitives.get(0).show).toEqual(true);
dynamicObjectCollection.removeAll();
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- expect(scene.getPrimitives().get(0).show).toEqual(false);
+ expect(scene.primitives.length).toEqual(1);
+ expect(scene.primitives.get(0).show).toEqual(false);
});
it('Visualizer sets dynamicObject property.', function() {
@@ -250,7 +250,7 @@ defineSuite([
var time = new JulianDate();
visualizer.update(time);
- expect(scene.getPrimitives().get(0).dynamicObject).toEqual(testObject);
+ expect(scene.primitives.get(0).id).toEqual(testObject);
});
it('setDynamicObjectCollection removes old objects and add new ones.', function() {
@@ -275,14 +275,14 @@ defineSuite([
var time = new JulianDate();
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var conePrimitive = scene.getPrimitives().get(0);
- expect(conePrimitive.dynamicObject).toEqual(testObject);
+ 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.getPrimitives().getLength()).toEqual(1);
- conePrimitive = scene.getPrimitives().get(0);
- expect(conePrimitive.dynamicObject).toEqual(testObject2);
+ expect(scene.primitives.length).toEqual(1);
+ conePrimitive = scene.primitives.get(0);
+ expect(conePrimitive.id).toEqual(testObject2);
});
}, 'WebGL');
diff --git a/Specs/DynamicScene/DynamicDirectionsPropertySpec.js b/Specs/DynamicScene/DynamicDirectionsPropertySpec.js
deleted file mode 100644
index 5c8ac4d5a862..000000000000
--- a/Specs/DynamicScene/DynamicDirectionsPropertySpec.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/*global defineSuite*/
-defineSuite([
- 'DynamicScene/DynamicDirectionsProperty',
- 'Core/JulianDate',
- 'Core/Cartesian3',
- 'Core/Spherical'
- ], function(
- DynamicDirectionsProperty,
- JulianDate,
- Cartesian3,
- Spherical) {
- "use strict";
- /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
-
- var sphericals;
- var cartesians;
- var sphericalInterval;
- var cartesianInterval;
-
- beforeAll(function() {
- cartesians = [new Cartesian3(1, 0, 0), new Cartesian3(0, 1, 0), new Cartesian3(0, 0, 1)];
- sphericals = [Spherical.fromCartesian3(cartesians[0]), Spherical.fromCartesian3(cartesians[1]), Spherical.fromCartesian3(cartesians[2])];
-
- sphericalInterval = {
- unitSpherical : [sphericals[0].clock, sphericals[0].cone, sphericals[1].clock, sphericals[1].cone, sphericals[2].clock, sphericals[2].cone]
- };
-
- cartesianInterval = {
- unitCartesian : [cartesians[0].x, cartesians[0].y, cartesians[0].z, cartesians[1].x, cartesians[1].y, cartesians[1].z, cartesians[2].x, cartesians[2].y, cartesians[2].z]
- };
- });
-
- it('getValue returns undefined if no data exists', function() {
- var property = new DynamicDirectionsProperty();
- expect(property.getValue(new JulianDate())).toBeUndefined();
- });
-
- it('getValue throw if no time supplied', function() {
- var property = new DynamicDirectionsProperty();
- expect(function() {
- property.getValue();
- }).toThrow();
- });
-
- it('getValue works for cartesian data', function() {
- var property = new DynamicDirectionsProperty();
- property.processCzmlIntervals(cartesianInterval);
- var result = property.getValue(new JulianDate());
- expect(result.length).toEqual(cartesians.length);
- expect(result[0]).toEqual(sphericals[0]);
- expect(result[1]).toEqual(sphericals[1]);
- expect(result[2]).toEqual(sphericals[2]);
- });
-
- it('getValue works for spherical data', function() {
- var property = new DynamicDirectionsProperty();
- property.processCzmlIntervals(sphericalInterval);
- var result = property.getValue(new JulianDate());
- expect(result.length).toEqual(sphericals.length);
- expect(result[0]).toEqual(sphericals[0]);
- expect(result[1]).toEqual(sphericals[1]);
- expect(result[2]).toEqual(sphericals[2]);
- });
-
- it('getValue returns undefined if no data exists', function() {
- var property = new DynamicDirectionsProperty();
- expect(property.getValue(new JulianDate())).toBeUndefined();
- });
-
- it('getValue throws if no time supplied', function() {
- var property = new DynamicDirectionsProperty();
- expect(function() {
- property.getValue();
- }).toThrow();
- });
-});
diff --git a/Specs/DynamicScene/DynamicEllipsoidSpec.js b/Specs/DynamicScene/DynamicEllipsoidSpec.js
index 187b5368a242..1960f015b509 100644
--- a/Specs/DynamicScene/DynamicEllipsoidSpec.js
+++ b/Specs/DynamicScene/DynamicEllipsoidSpec.js
@@ -3,14 +3,12 @@ defineSuite([
'DynamicScene/DynamicEllipsoid',
'DynamicScene/ColorMaterialProperty',
'DynamicScene/ConstantProperty',
- 'DynamicScene/DynamicVertexPositionsProperty',
'Core/Cartesian3',
'Core/Color'
], function(
DynamicEllipsoid,
ColorMaterialProperty,
ConstantProperty,
- DynamicVertexPositionsProperty,
Cartesian3,
Color) {
"use strict";
@@ -21,6 +19,9 @@ defineSuite([
source.material = new ColorMaterialProperty();
source.radii = new ConstantProperty(new Cartesian3());
source.show = new ConstantProperty(true);
+ source.stackPartitions = new ConstantProperty(16);
+ source.slicePartitions = new ConstantProperty(32);
+ source.subdivisions = new ConstantProperty(64);
var target = new DynamicEllipsoid();
target.merge(source);
@@ -28,6 +29,9 @@ defineSuite([
expect(target.material).toBe(source.material);
expect(target.radii).toBe(source.radii);
expect(target.show).toBe(source.show);
+ expect(target.stackPartitions).toBe(source.stackPartitions);
+ expect(target.slicePartitions).toBe(source.slicePartitions);
+ expect(target.subdivisions).toBe(source.subdivisions);
});
it('merge does not assign assigned properties', function() {
@@ -35,21 +39,33 @@ defineSuite([
source.material = new ColorMaterialProperty();
source.radii = new ConstantProperty(new Cartesian3());
source.show = new ConstantProperty(true);
+ source.stackPartitions = new ConstantProperty(16);
+ source.slicePartitions = new ConstantProperty(32);
+ source.subdivisions = new ConstantProperty(64);
var material = new ColorMaterialProperty();
var radii = new ConstantProperty(new Cartesian3());
var show = new ConstantProperty(true);
+ var stackPartitions = new ConstantProperty(1);
+ var slicePartitions = new ConstantProperty(2);
+ var subdivisions = new ConstantProperty(3);
var target = new DynamicEllipsoid();
target.material = material;
target.radii = radii;
target.show = show;
+ target.stackPartitions = stackPartitions;
+ target.slicePartitions = slicePartitions;
+ target.subdivisions = subdivisions;
target.merge(source);
expect(target.material).toBe(material);
expect(target.radii).toBe(radii);
expect(target.show).toBe(show);
+ expect(target.stackPartitions).toBe(stackPartitions);
+ expect(target.slicePartitions).toBe(slicePartitions);
+ expect(target.subdivisions).toBe(subdivisions);
});
it('clone works', function() {
@@ -57,11 +73,17 @@ defineSuite([
source.material = new ColorMaterialProperty();
source.radii = new ConstantProperty(new Cartesian3());
source.show = new ConstantProperty(true);
+ source.stackPartitions = new ConstantProperty(16);
+ source.slicePartitions = new ConstantProperty(32);
+ source.subdivisions = new ConstantProperty(64);
var result = source.clone();
expect(result.material).toBe(source.material);
expect(result.radii).toBe(source.radii);
expect(result.show).toBe(source.show);
+ expect(result.stackPartitions).toBe(source.stackPartitions);
+ expect(result.slicePartitions).toBe(source.slicePartitions);
+ expect(result.subdivisions).toBe(source.subdivisions);
});
it('merge throws if source undefined', function() {
diff --git a/Specs/DynamicScene/DynamicEllipsoidVisualizerSpec.js b/Specs/DynamicScene/DynamicEllipsoidVisualizerSpec.js
deleted file mode 100644
index 214800fdfc72..000000000000
--- a/Specs/DynamicScene/DynamicEllipsoidVisualizerSpec.js
+++ /dev/null
@@ -1,227 +0,0 @@
-/*global defineSuite*/
-defineSuite([
- 'DynamicScene/DynamicEllipsoidVisualizer',
- 'Specs/createScene',
- 'Specs/destroyScene',
- 'DynamicScene/ConstantProperty',
- 'Core/JulianDate',
- 'Core/Math',
- 'Core/Matrix3',
- 'Core/Matrix4',
- 'Core/Quaternion',
- 'Core/Cartesian3',
- 'Core/Spherical',
- 'Core/Color',
- 'DynamicScene/DynamicEllipsoid',
- 'DynamicScene/DynamicObjectCollection',
- 'DynamicScene/ColorMaterialProperty'
- ], function(
- DynamicEllipsoidVisualizer,
- createScene,
- destroyScene,
- ConstantProperty,
- JulianDate,
- CesiumMath,
- Matrix3,
- Matrix4,
- Quaternion,
- Cartesian3,
- Spherical,
- Color,
- DynamicEllipsoid,
- DynamicObjectCollection,
- ColorMaterialProperty) {
- "use strict";
- /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
-
- var scene;
- var visualizer;
-
- beforeAll(function() {
- scene = createScene();
- });
-
- afterAll(function() {
- destroyScene(scene);
- });
-
- afterEach(function() {
- visualizer = visualizer && visualizer.destroy();
- });
-
- it('constructor throws if no scene is passed.', function() {
- expect(function() {
- return new DynamicEllipsoidVisualizer();
- }).toThrowDeveloperError();
- });
-
- it('constructor sets expected parameters.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicEllipsoidVisualizer(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 DynamicEllipsoidVisualizer(scene, dynamicObjectCollection);
- expect(function() {
- visualizer.update();
- }).toThrowDeveloperError();
- });
-
- it('update does nothing if no dynamicObjectCollection.', function() {
- visualizer = new DynamicEllipsoidVisualizer(scene);
- visualizer.update(new JulianDate());
- });
-
- it('isDestroy returns false until destroyed.', function() {
- visualizer = new DynamicEllipsoidVisualizer(scene);
- expect(visualizer.isDestroyed()).toEqual(false);
- visualizer.destroy();
- expect(visualizer.isDestroyed()).toEqual(true);
- visualizer = undefined;
- });
-
- it('object with no ellipsoid does not create a primitive.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicEllipsoidVisualizer(scene, 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));
- visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
- });
-
- it('object with no position does not create a primitive.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicEllipsoidVisualizer(scene, dynamicObjectCollection);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.orientation = new ConstantProperty(new Quaternion(0, 0, 0, 1));
- var ellipsoid = testObject.ellipsoid = new DynamicEllipsoid();
- ellipsoid.radii = new ConstantProperty(new Cartesian3(1, 2, 3));
- visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
- });
-
- it('object with no radii does not create a primitive.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicEllipsoidVisualizer(scene, 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));
- testObject.ellipsoid = new DynamicEllipsoid();
- visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
- });
-
- it('object with no orientation does not create a primitive.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicEllipsoidVisualizer(scene, dynamicObjectCollection);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
- testObject.ellipsoid = new DynamicEllipsoid();
- testObject.ellipsoid.radii = new ConstantProperty(new Cartesian3(1, 2, 3));
- visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
- });
-
- it('A DynamicEllipsoid causes a EllipsoidPrimitive to be created and updated.', function() {
- var time = new JulianDate();
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicEllipsoidVisualizer(scene, dynamicObjectCollection);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
- testObject.orientation = new ConstantProperty(new Quaternion(0, 0, Math.sin(CesiumMath.PI_OVER_FOUR), Math.cos(CesiumMath.PI_OVER_FOUR)));
-
- var ellipsoid = testObject.ellipsoid = new DynamicEllipsoid();
- ellipsoid.directions = new ConstantProperty([new Spherical(0, 0, 0), new Spherical(1, 0, 0), new Spherical(2, 0, 0), new Spherical(3, 0, 0)]);
- ellipsoid.radii = new ConstantProperty(123.5);
- ellipsoid.show = new ConstantProperty(true);
- ellipsoid.material = new ColorMaterialProperty();
- visualizer.update(time);
-
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var p = scene.getPrimitives().get(0);
- expect(p.radii).toEqual(testObject.ellipsoid.radii.getValue(time));
- expect(p.show).toEqual(testObject.ellipsoid.show.getValue(time));
- expect(p.material.uniforms).toEqual(testObject.ellipsoid.material.getValue(time));
- expect(p.modelMatrix).toEqual(Matrix4.fromRotationTranslation(Matrix3.fromQuaternion(testObject.orientation.getValue(time)), testObject.position.getValue(time)));
-
- ellipsoid.show.value = false;
- visualizer.update(time);
- expect(p.show).toEqual(testObject.ellipsoid.show.getValue(time));
- });
-
- it('clear hides ellipsoids.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicEllipsoidVisualizer(scene, 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 ellipsoid = testObject.ellipsoid = new DynamicEllipsoid();
- ellipsoid.radii = new ConstantProperty(new Cartesian3(1, 2, 3));
-
- var time = new JulianDate();
- expect(scene.getPrimitives().getLength()).toEqual(0);
- visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- expect(scene.getPrimitives().get(0).show).toEqual(true);
- dynamicObjectCollection.removeAll();
- visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- expect(scene.getPrimitives().get(0).show).toEqual(false);
- });
-
- it('Visualizer sets dynamicObject property.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicEllipsoidVisualizer(scene, 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 ellipsoid = testObject.ellipsoid = new DynamicEllipsoid();
- ellipsoid.radii = new ConstantProperty(new Cartesian3(1, 2, 3));
-
- var time = new JulianDate();
- visualizer.update(time);
- expect(scene.getPrimitives().get(0).dynamicObject).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 ellipsoid = testObject.ellipsoid = new DynamicEllipsoid();
- ellipsoid.radii = new ConstantProperty(new Cartesian3(1, 2, 3));
-
- 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 ellipsoid2 = testObject2.ellipsoid = new DynamicEllipsoid();
- ellipsoid2.radii = new ConstantProperty(new Cartesian3(4, 5, 6));
-
- visualizer = new DynamicEllipsoidVisualizer(scene, dynamicObjectCollection);
-
- var time = new JulianDate();
-
- visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var ellipsoidPrimitive = scene.getPrimitives().get(0);
- expect(ellipsoidPrimitive.dynamicObject).toEqual(testObject);
-
- visualizer.setDynamicObjectCollection(dynamicObjectCollection2);
- visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- ellipsoidPrimitive = scene.getPrimitives().get(0);
- expect(ellipsoidPrimitive.dynamicObject).toEqual(testObject2);
- });
-}, 'WebGL');
diff --git a/Specs/DynamicScene/DynamicLabelVisualizerSpec.js b/Specs/DynamicScene/DynamicLabelVisualizerSpec.js
index f69018e54673..ae3f248d2c1e 100644
--- a/Specs/DynamicScene/DynamicLabelVisualizerSpec.js
+++ b/Specs/DynamicScene/DynamicLabelVisualizerSpec.js
@@ -60,7 +60,7 @@ defineSuite([
visualizer = new DynamicLabelVisualizer(scene, dynamicObjectCollection);
expect(visualizer.getScene()).toEqual(scene);
expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection);
- var labelCollection = scene.getPrimitives().get(0);
+ var labelCollection = scene.primitives.get(0);
expect(labelCollection instanceof LabelCollection).toEqual(true);
});
@@ -92,7 +92,7 @@ defineSuite([
var testObject = dynamicObjectCollection.getOrCreateObject('test');
testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
visualizer.update(new JulianDate());
- var labelCollection = scene.getPrimitives().get(0);
+ var labelCollection = scene.primitives.get(0);
expect(labelCollection.getLength()).toEqual(0);
});
@@ -106,7 +106,7 @@ defineSuite([
label.text = new ConstantProperty('lorum ipsum');
visualizer.update(new JulianDate());
- var labelCollection = scene.getPrimitives().get(0);
+ var labelCollection = scene.primitives.get(0);
expect(labelCollection.getLength()).toEqual(0);
});
@@ -120,7 +120,7 @@ defineSuite([
label.show = new ConstantProperty(true);
visualizer.update(new JulianDate());
- var labelCollection = scene.getPrimitives().get(0);
+ var labelCollection = scene.primitives.get(0);
expect(labelCollection.getLength()).toEqual(0);
});
@@ -128,7 +128,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicLabelVisualizer(scene, dynamicObjectCollection);
- var labelCollection = scene.getPrimitives().get(0);
+ var labelCollection = scene.primitives.get(0);
expect(labelCollection.getLength()).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
@@ -217,7 +217,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicLabelVisualizer(scene, dynamicObjectCollection);
- var labelCollection = scene.getPrimitives().get(0);
+ var labelCollection = scene.primitives.get(0);
expect(labelCollection.getLength()).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
@@ -245,7 +245,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicLabelVisualizer(scene, dynamicObjectCollection);
- var labelCollection = scene.getPrimitives().get(0);
+ var labelCollection = scene.primitives.get(0);
expect(labelCollection.getLength()).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
@@ -259,7 +259,7 @@ defineSuite([
visualizer.update(time);
expect(labelCollection.getLength()).toEqual(1);
var l = labelCollection.get(0);
- expect(l.dynamicObject).toEqual(testObject);
+ expect(l.id).toEqual(testObject);
});
it('setDynamicObjectCollection removes old objects and add new ones.', function() {
@@ -280,17 +280,17 @@ defineSuite([
visualizer = new DynamicLabelVisualizer(scene, dynamicObjectCollection);
var time = new JulianDate();
- var labelCollection = scene.getPrimitives().get(0);
+ var labelCollection = scene.primitives.get(0);
visualizer.update(time);
expect(labelCollection.getLength()).toEqual(1);
var l = labelCollection.get(0);
- expect(l.dynamicObject).toEqual(testObject);
+ expect(l.id).toEqual(testObject);
visualizer.setDynamicObjectCollection(dynamicObjectCollection2);
visualizer.update(time);
expect(labelCollection.getLength()).toEqual(1);
l = labelCollection.get(0);
- expect(l.dynamicObject).toEqual(testObject2);
+ expect(l.id).toEqual(testObject2);
});
}, 'WebGL');
\ No newline at end of file
diff --git a/Specs/DynamicScene/DynamicObjectSpec.js b/Specs/DynamicScene/DynamicObjectSpec.js
index 599c42875dd6..1dd239f9f0ad 100644
--- a/Specs/DynamicScene/DynamicObjectSpec.js
+++ b/Specs/DynamicScene/DynamicObjectSpec.js
@@ -52,12 +52,13 @@ defineSuite([
expect(dynamicObject.isAvailable(interval.stop.addSeconds(1))).toEqual(false);
});
- it('propertyChanged works for all properties', function() {
+ it('definitionChanged works for all properties', function() {
var dynamicObject = new DynamicObject();
var propertyNames = dynamicObject.propertyNames;
var propertyNamesLength = propertyNames.length;
- spyOn(dynamicObject.propertyChanged, 'raiseEvent');
+ var listener = jasmine.createSpy('listener');
+ dynamicObject.definitionChanged.addEventListener(listener);
var i;
var name;
@@ -70,7 +71,7 @@ defineSuite([
newValue = new ConstantProperty(1);
oldValue = dynamicObject[propertyNames[i]];
dynamicObject[name] = newValue;
- expect(dynamicObject.propertyChanged.raiseEvent).toHaveBeenCalledWith(dynamicObject, name, newValue, oldValue);
+ expect(listener).toHaveBeenCalledWith(dynamicObject, name, newValue, oldValue);
}
}
});
diff --git a/Specs/DynamicScene/DynamicPathVisualizerSpec.js b/Specs/DynamicScene/DynamicPathVisualizerSpec.js
index 8ca71e986606..a93f2978cf31 100644
--- a/Specs/DynamicScene/DynamicPathVisualizerSpec.js
+++ b/Specs/DynamicScene/DynamicPathVisualizerSpec.js
@@ -50,7 +50,7 @@ defineSuite([
visualizer = new DynamicPathVisualizer(scene, dynamicObjectCollection);
expect(visualizer.getScene()).toEqual(scene);
expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
});
it('update throws if no time specified.', function() {
@@ -81,7 +81,7 @@ defineSuite([
var testObject = dynamicObjectCollection.getOrCreateObject('test');
testObject.position = new ConstantProperty([new Cartesian3(1234, 5678, 9101112), new Cartesian3(5678, 1234, 1101112)]);
visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
});
it('object with no position does not create a polyline.', function() {
@@ -93,7 +93,7 @@ defineSuite([
path.show = new ConstantProperty(true);
visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
});
it('A DynamicPath causes a primtive to be created and updated.', function() {
@@ -104,7 +104,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicPathVisualizer(scene, dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
var position = new SampledPositionProperty();
@@ -122,9 +122,9 @@ defineSuite([
visualizer.update(updateTime);
- expect(scene.getPrimitives().getLength()).toEqual(1);
+ expect(scene.primitives.length).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
+ var polylineCollection = scene.primitives.get(0);
var primitive = polylineCollection.get(0);
expect(primitive.getPositions()[0]).toEqual(testObject.position.getValue(updateTime.addSeconds(-path.trailTime.getValue())));
expect(primitive.getPositions()[1]).toEqual(testObject.position.getValue(updateTime));
@@ -150,7 +150,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicPathVisualizer(scene, dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
var position = new SampledPositionProperty();
@@ -168,9 +168,9 @@ defineSuite([
visualizer.update(updateTime);
- expect(scene.getPrimitives().getLength()).toEqual(1);
+ expect(scene.primitives.length).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
+ var polylineCollection = scene.primitives.get(0);
var primitive = polylineCollection.get(0);
visualizer.update(updateTime);
@@ -188,7 +188,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicPathVisualizer(scene, dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
var position = new SampledPositionProperty();
@@ -205,9 +205,9 @@ defineSuite([
path.trailTime = new ConstantProperty(10);
visualizer.update(updateTime);
- var polylineCollection = scene.getPrimitives().get(0);
+ var polylineCollection = scene.primitives.get(0);
var primitive = polylineCollection.get(0);
- expect(primitive.dynamicObject).toEqual(testObject);
+ expect(primitive.id).toEqual(testObject);
});
it('setDynamicObjectCollection removes old objects and add new ones.', function() {
@@ -218,7 +218,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicPathVisualizer(scene, dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
var position = new SampledPositionProperty();
@@ -251,17 +251,17 @@ defineSuite([
path2.leadTime = new ConstantProperty(25);
path2.trailTime = new ConstantProperty(10);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
+ expect(scene.primitives.length).toEqual(1);
+ var polylineCollection = scene.primitives.get(0);
expect(polylineCollection.getLength()).toEqual(1);
var primitive = polylineCollection.get(0);
- expect(primitive.dynamicObject).toEqual(testObject);
+ expect(primitive.id).toEqual(testObject);
visualizer.setDynamicObjectCollection(dynamicObjectCollection2);
visualizer.update(updateTime);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- polylineCollection = scene.getPrimitives().get(0);
+ expect(scene.primitives.length).toEqual(1);
+ polylineCollection = scene.primitives.get(0);
primitive = polylineCollection.get(0);
- expect(primitive.dynamicObject).toEqual(testObject2);
+ expect(primitive.id).toEqual(testObject2);
});
}, 'WebGL');
\ No newline at end of file
diff --git a/Specs/DynamicScene/DynamicPointVisualizerSpec.js b/Specs/DynamicScene/DynamicPointVisualizerSpec.js
index 278e7ddce04e..62616d175f0c 100644
--- a/Specs/DynamicScene/DynamicPointVisualizerSpec.js
+++ b/Specs/DynamicScene/DynamicPointVisualizerSpec.js
@@ -52,8 +52,8 @@ defineSuite([
visualizer = new DynamicPointVisualizer(scene, dynamicObjectCollection);
expect(visualizer.getScene()).toEqual(scene);
expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var billboardCollection = scene.getPrimitives().get(0);
+ expect(scene.primitives.length).toEqual(1);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection instanceof BillboardCollection).toEqual(true);
});
@@ -85,7 +85,7 @@ defineSuite([
var testObject = dynamicObjectCollection.getOrCreateObject('test');
testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
visualizer.update(new JulianDate());
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection.getLength()).toEqual(0);
});
@@ -98,7 +98,7 @@ defineSuite([
point.show = new ConstantProperty(true);
visualizer.update(new JulianDate());
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection.getLength()).toEqual(0);
});
@@ -108,7 +108,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicPointVisualizer(scene, dynamicObjectCollection);
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection.getLength()).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
@@ -163,7 +163,7 @@ defineSuite([
it('clear hides billboards.', function() {
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicPointVisualizer(scene, dynamicObjectCollection);
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection.getLength()).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
var time = new JulianDate();
@@ -187,7 +187,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicPointVisualizer(scene, dynamicObjectCollection);
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
expect(billboardCollection.getLength()).toEqual(0);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
@@ -201,7 +201,7 @@ defineSuite([
visualizer.update(time);
expect(billboardCollection.getLength()).toEqual(1);
var bb = billboardCollection.get(0);
- expect(bb.dynamicObject).toEqual(testObject);
+ expect(bb.id).toEqual(testObject);
});
it('setDynamicObjectCollection removes old objects and add new ones.', function() {
@@ -220,17 +220,17 @@ defineSuite([
visualizer = new DynamicPointVisualizer(scene, dynamicObjectCollection);
var time = new JulianDate();
- var billboardCollection = scene.getPrimitives().get(0);
+ var billboardCollection = scene.primitives.get(0);
visualizer.update(time);
expect(billboardCollection.getLength()).toEqual(1);
var bb = billboardCollection.get(0);
- expect(bb.dynamicObject).toEqual(testObject);
+ expect(bb.id).toEqual(testObject);
visualizer.setDynamicObjectCollection(dynamicObjectCollection2);
visualizer.update(time);
expect(billboardCollection.getLength()).toEqual(1);
bb = billboardCollection.get(0);
- expect(bb.dynamicObject).toEqual(testObject2);
+ expect(bb.id).toEqual(testObject2);
});
}, 'WebGL');
\ No newline at end of file
diff --git a/Specs/DynamicScene/DynamicPolygonSpec.js b/Specs/DynamicScene/DynamicPolygonSpec.js
index 8118be9fe392..017f78ef86e4 100644
--- a/Specs/DynamicScene/DynamicPolygonSpec.js
+++ b/Specs/DynamicScene/DynamicPolygonSpec.js
@@ -3,13 +3,11 @@ defineSuite([
'DynamicScene/DynamicPolygon',
'DynamicScene/ColorMaterialProperty',
'DynamicScene/ConstantProperty',
- 'DynamicScene/DynamicVertexPositionsProperty',
'Core/Color'
], function(
DynamicPolygon,
ColorMaterialProperty,
ConstantProperty,
- DynamicVertexPositionsProperty,
Color) {
"use strict";
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
@@ -18,12 +16,20 @@ defineSuite([
var source = new DynamicPolygon();
source.material = new ColorMaterialProperty();
source.show = new ConstantProperty(true);
+ source.height = new ConstantProperty(1);
+ source.extrudedHeight = new ConstantProperty(2);
+ source.granularity = new ConstantProperty(3);
+ source.stRotation = new ConstantProperty(4);
var target = new DynamicPolygon();
target.merge(source);
expect(target.material).toBe(source.material);
expect(target.show).toBe(source.show);
+ expect(target.height).toBe(source.height);
+ expect(target.extrudedHeight).toBe(source.extrudedHeight);
+ expect(target.granularity).toBe(source.granularity);
+ expect(target.stRotation).toBe(source.stRotation);
});
it('merge does not assign assigned properties', function() {
@@ -33,25 +39,45 @@ defineSuite([
var material = new ColorMaterialProperty();
var show = new ConstantProperty(true);
+ var height = new ConstantProperty(1);
+ var extrudedHeight = new ConstantProperty(2);
+ var granularity = new ConstantProperty(3);
+ var stRotation = new ConstantProperty(4);
var target = new DynamicPolygon();
target.material = material;
target.show = show;
+ target.height = height;
+ target.extrudedHeight = extrudedHeight;
+ target.granularity = granularity;
+ target.stRotation = stRotation;
target.merge(source);
expect(target.material).toBe(material);
expect(target.show).toBe(show);
+ expect(target.height).toBe(height);
+ expect(target.extrudedHeight).toBe(extrudedHeight);
+ expect(target.granularity).toBe(granularity);
+ expect(target.stRotation).toBe(stRotation);
});
it('clone works', function() {
var source = new DynamicPolygon();
source.material = new ColorMaterialProperty();
source.show = new ConstantProperty(true);
+ source.height = new ConstantProperty(1);
+ source.extrudedHeight = new ConstantProperty(2);
+ source.granularity = new ConstantProperty(3);
+ source.stRotation = new ConstantProperty(4);
var result = source.clone();
expect(result.material).toBe(source.material);
expect(result.show).toBe(source.show);
+ expect(result.height).toBe(source.height);
+ expect(result.extrudedHeight).toBe(source.extrudedHeight);
+ expect(result.granularity).toBe(source.granularity);
+ expect(result.stRotation).toBe(source.stRotation);
});
it('merge throws if source undefined', function() {
diff --git a/Specs/DynamicScene/DynamicPolygonVisualizerSpec.js b/Specs/DynamicScene/DynamicPolygonVisualizerSpec.js
deleted file mode 100644
index b4c60b7ef344..000000000000
--- a/Specs/DynamicScene/DynamicPolygonVisualizerSpec.js
+++ /dev/null
@@ -1,267 +0,0 @@
-/*global defineSuite*/
-defineSuite([
- 'DynamicScene/DynamicPolygonVisualizer',
- 'Specs/createScene',
- 'Specs/destroyScene',
- 'DynamicScene/ConstantProperty',
- 'Core/Cartesian3',
- 'Core/Color',
- 'Core/JulianDate',
- 'DynamicScene/DynamicEllipse',
- 'DynamicScene/DynamicPolygon',
- 'DynamicScene/DynamicObjectCollection',
- 'DynamicScene/ColorMaterialProperty'
- ], function(
- DynamicPolygonVisualizer,
- createScene,
- destroyScene,
- ConstantProperty,
- Cartesian3,
- Color,
- JulianDate,
- DynamicEllipse,
- DynamicPolygon,
- DynamicObjectCollection,
- ColorMaterialProperty) {
- "use strict";
- /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
-
- var scene;
- var visualizer;
-
- beforeAll(function() {
- scene = createScene();
- });
-
- afterAll(function() {
- destroyScene(scene);
- });
-
- afterEach(function() {
- visualizer = visualizer && visualizer.destroy();
- });
-
- it('constructor throws if no scene is passed.', function() {
- expect(function() {
- return new DynamicPolygonVisualizer();
- }).toThrowDeveloperError();
- });
-
- it('constructor sets expected parameters and adds collection to scene.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolygonVisualizer(scene, dynamicObjectCollection);
- expect(visualizer.getScene()).toEqual(scene);
- expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(0);
- });
-
- it('update throws if no time specified.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolygonVisualizer(scene, dynamicObjectCollection);
- expect(function() {
- visualizer.update();
- }).toThrowDeveloperError();
- });
-
- it('update does nothing if no dynamicObjectCollection.', function() {
- visualizer = new DynamicPolygonVisualizer(scene);
- visualizer.update(new JulianDate());
- });
-
- it('isDestroy returns false until destroyed.', function() {
- visualizer = new DynamicPolygonVisualizer(scene);
- expect(visualizer.isDestroyed()).toEqual(false);
- visualizer.destroy();
- expect(visualizer.isDestroyed()).toEqual(true);
- visualizer = undefined;
- });
-
- it('object with no polygon does not create one.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolygonVisualizer(scene, dynamicObjectCollection);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.vertexPositions = new ConstantProperty([new Cartesian3(1234, 5678, 9101112), new Cartesian3(5678, 1234, 1101112), new Cartesian3(1234, 5678, 910111)]);
- visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
- });
-
- it('object with no vertexPosition does not create a polygon.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolygonVisualizer(scene, dynamicObjectCollection);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- var polygon = testObject.polygon = new DynamicPolygon();
- polygon.show = new ConstantProperty(true);
-
- visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
- });
-
- it('object with ellipse and no position does not create a polygon.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolygonVisualizer(scene, dynamicObjectCollection);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.ellipse = new DynamicEllipse();
- var polygon = testObject.polygon = new DynamicPolygon();
- polygon.show = new ConstantProperty(true);
-
- visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
- });
-
- it('object with ellipse and position properties and no ellipse properties does not create positions.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolygonVisualizer(scene, dynamicObjectCollection);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
- testObject.ellipse = new DynamicEllipse();
- var polygon = testObject.polygon = new DynamicPolygon();
- polygon.show = new ConstantProperty(true);
-
- visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var primitive = scene.getPrimitives().get(0);
- expect(primitive.getPositions()).toBeUndefined();
- });
-
- it('DynamicPolygon with ellipse and position creates a primitive and updates it.', function() {
- var time = new JulianDate();
-
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolygonVisualizer(scene, dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(0);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
- var polygon = testObject.polygon = new DynamicPolygon();
- polygon.show = new ConstantProperty(true);
- polygon.material = new ColorMaterialProperty();
-
- var ellipse = testObject.ellipse = new DynamicEllipse();
- ellipse.rotation = new ConstantProperty(0);
- ellipse.semiMajorAxis = new ConstantProperty(1000);
- ellipse.semiMinorAxis = new ConstantProperty(1000);
- visualizer.update(new JulianDate());
-
- expect(scene.getPrimitives().getLength()).toEqual(1);
-
- var primitive = scene.getPrimitives().get(0);
-
- visualizer.update(time);
- expect(primitive.show).toEqual(testObject.polygon.show.getValue(time));
- expect(primitive.material.uniforms).toEqual(testObject.polygon.material.getValue(time));
- expect(primitive.getPositions().length > 0);
-
- });
-
- it('A DynamicPolygon causes a primtive to be created and updated.', function() {
- var time = new JulianDate();
-
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolygonVisualizer(scene, dynamicObjectCollection);
-
- expect(scene.getPrimitives().getLength()).toEqual(0);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.vertexPositions = new ConstantProperty([new Cartesian3(1234, 5678, 9101112), new Cartesian3(5678, 1234, 1101112), new Cartesian3(1234, 5678, 910111)]);
-
- var polygon = testObject.polygon = new DynamicPolygon();
- polygon.show = new ConstantProperty(true);
- polygon.material = new ColorMaterialProperty();
-
- visualizer.update(time);
-
- expect(scene.getPrimitives().getLength()).toEqual(1);
-
- var primitive = scene.getPrimitives().get(0);
-
- visualizer.update(time);
- expect(primitive.show).toEqual(testObject.polygon.show.getValue(time));
- expect(primitive.material.uniforms).toEqual(testObject.polygon.material.getValue(time));
-
- testObject.vertexPositions = new ConstantProperty([new Cartesian3(5678, 1234, 1101112), new Cartesian3(1234, 5678, 9101112), new Cartesian3(1234, 5678, 910111)]);
- polygon.material = new ColorMaterialProperty();
-
- visualizer.update(time);
- expect(primitive.show).toEqual(testObject.polygon.show.getValue(time));
- expect(primitive.material.uniforms).toEqual(testObject.polygon.material.getValue(time));
-
- polygon.show = new ConstantProperty(false);
- visualizer.update(time);
- expect(primitive.show).toEqual(testObject.polygon.show.getValue(time));
- });
-
- it('clear hides primitives.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolygonVisualizer(scene, dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(0);
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- var time = new JulianDate();
-
- testObject.vertexPositions = new ConstantProperty([new Cartesian3(5678, 1234, 1101112), new Cartesian3(1234, 5678, 9101112), new Cartesian3(1234, 5678, 910111)]);
- var polygon = testObject.polygon = new DynamicPolygon();
- polygon.show = new ConstantProperty(true);
- visualizer.update(time);
-
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var primitive = scene.getPrimitives().get(0);
-
- visualizer.update(time);
- //Clearing won't actually remove the primitive because of the
- //internal cache used by the visualizer, instead it just hides it.
- dynamicObjectCollection.removeAll();
- expect(primitive.show).toEqual(false);
- });
-
- it('Visualizer sets dynamicObject property.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolygonVisualizer(scene, dynamicObjectCollection);
-
- expect(scene.getPrimitives().getLength()).toEqual(0);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
-
- var time = new JulianDate();
- var polygon = testObject.polygon = new DynamicPolygon();
-
- testObject.vertexPositions = new ConstantProperty([new Cartesian3(5678, 1234, 1101112), new Cartesian3(1234, 5678, 9101112), new Cartesian3(1234, 5678, 910111)]);
- polygon.show = new ConstantProperty(true);
-
- visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var primitive = scene.getPrimitives().get(0);
- expect(primitive.dynamicObject).toEqual(testObject);
- });
-
- it('setDynamicObjectCollection removes old objects and add new ones.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.vertexPositions = new ConstantProperty([new Cartesian3(5678, 1234, 1101112), new Cartesian3(1234, 5678, 9101112), new Cartesian3(1234, 5678, 910111)]);
- testObject.polygon = new DynamicPolygon();
- testObject.polygon.show = new ConstantProperty(true);
-
- var dynamicObjectCollection2 = new DynamicObjectCollection();
- var testObject2 = dynamicObjectCollection2.getOrCreateObject('test2');
- testObject2.vertexPositions = new ConstantProperty([new Cartesian3(1234, 5678, 9101112), new Cartesian3(5678, 1234, 1101112), new Cartesian3(1234, 5678, 910111)]);
- testObject2.polygon = new DynamicPolygon();
- testObject2.polygon.show = new ConstantProperty(true);
-
- visualizer = new DynamicPolygonVisualizer(scene, dynamicObjectCollection);
-
- var time = new JulianDate();
-
- visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var primitive = scene.getPrimitives().get(0);
- expect(primitive.dynamicObject).toEqual(testObject);
-
- visualizer.setDynamicObjectCollection(dynamicObjectCollection2);
- visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- primitive = scene.getPrimitives().get(0);
- expect(primitive.dynamicObject).toEqual(testObject2);
- });
-}, 'WebGL');
\ No newline at end of file
diff --git a/Specs/DynamicScene/DynamicPolylineVisualizerSpec.js b/Specs/DynamicScene/DynamicPolylineVisualizerSpec.js
deleted file mode 100644
index 6b572c610731..000000000000
--- a/Specs/DynamicScene/DynamicPolylineVisualizerSpec.js
+++ /dev/null
@@ -1,296 +0,0 @@
-/*global defineSuite*/
-defineSuite([
- 'DynamicScene/DynamicPolylineVisualizer',
- 'Specs/createScene',
- 'Specs/destroyScene',
- 'DynamicScene/ConstantProperty',
- 'DynamicScene/DynamicEllipse',
- 'DynamicScene/DynamicPolyline',
- 'DynamicScene/DynamicObjectCollection',
- 'DynamicScene/DynamicObject',
- 'DynamicScene/ColorMaterialProperty',
- 'Core/JulianDate',
- 'Core/Cartesian2',
- 'Core/Cartesian3',
- 'Scene/Scene'
- ], function(
- DynamicPolylineVisualizer,
- createScene,
- destroyScene,
- ConstantProperty,
- DynamicEllipse,
- DynamicPolyline,
- DynamicObjectCollection,
- DynamicObject,
- ColorMaterialProperty,
- JulianDate,
- Cartesian2,
- Cartesian3,
- Scene) {
- "use strict";
- /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
-
- var scene;
- var visualizer;
-
- beforeAll(function() {
- scene = createScene();
- });
-
- afterAll(function() {
- destroyScene(scene);
- });
-
- afterEach(function() {
- visualizer = visualizer && visualizer.destroy();
- });
-
- it('constructor throws if no scene is passed.', function() {
- expect(function() {
- return new DynamicPolylineVisualizer();
- }).toThrowDeveloperError();
- });
-
- it('constructor sets expected parameters and adds collection to scene.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolylineVisualizer(scene, dynamicObjectCollection);
- expect(visualizer.getScene()).toEqual(scene);
- expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- });
-
- it('update throws if no time specified.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolylineVisualizer(scene, dynamicObjectCollection);
- expect(function() {
- visualizer.update();
- }).toThrowDeveloperError();
- });
-
- it('update does nothing if no dynamicObjectCollection.', function() {
- visualizer = new DynamicPolylineVisualizer(scene);
- visualizer.update(new JulianDate());
- });
-
- it('isDestroy returns false until destroyed.', function() {
- visualizer = new DynamicPolylineVisualizer(scene);
- expect(visualizer.isDestroyed()).toEqual(false);
- visualizer.destroy();
- expect(visualizer.isDestroyed()).toEqual(true);
- visualizer = undefined;
- });
-
- it('object with no polyline does not create one.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolylineVisualizer(scene, dynamicObjectCollection);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.vertexPositions = new ConstantProperty([new Cartesian3(1234, 5678, 9101112), new Cartesian3(5678, 1234, 1101112)]);
- visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
- expect(polylineCollection.getLength()).toEqual(0);
- });
-
- it('object with no vertexPosition does not create a polyline.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolylineVisualizer(scene, dynamicObjectCollection);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- var polyline = testObject.polyline = new DynamicPolyline();
- polyline.show = new ConstantProperty(true);
-
- visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
- expect(polylineCollection.getLength()).toEqual(0);
- });
-
- it('object with ellipse and no position does not create a polyline.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolylineVisualizer(scene, dynamicObjectCollection);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.ellipse = new DynamicEllipse();
- var polyline = testObject.polyline = new DynamicPolyline();
- polyline.show = new ConstantProperty(true);
-
- visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
- expect(polylineCollection.getLength()).toEqual(0);
- });
-
- it('object with ellipse and position properties and no ellipse properties does not create positions.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolylineVisualizer(scene, dynamicObjectCollection);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
- testObject.ellipse = new DynamicEllipse();
- var polyline = testObject.polyline = new DynamicPolyline();
- polyline.show = new ConstantProperty(true);
-
- visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
- var primitive = polylineCollection.get(0);
- expect(primitive.getPositions().length).toEqual(0);
- });
-
- it('DynamicPolyline with ellipse and position creates a primitive and updates it.', function() {
- var time = new JulianDate();
-
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolylineVisualizer(scene, dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(1);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
- var polyline = testObject.polyline = new DynamicPolyline();
- polyline.show = new ConstantProperty(true);
-
- var ellipse = testObject.ellipse = new DynamicEllipse();
- ellipse.rotation = new ConstantProperty(0);
- ellipse.semiMajorAxis = new ConstantProperty(1000);
- ellipse.semiMinorAxis = new ConstantProperty(1000);
- visualizer.update(new JulianDate());
-
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
- expect(polylineCollection.getLength()).toEqual(1);
- var primitive = polylineCollection.get(0);
- expect(primitive.getPositions().length).toBeGreaterThan(0);
-
-
- visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- polylineCollection = scene.getPrimitives().get(0);
- primitive = polylineCollection.get(0);
- expect(primitive.getShow()).toEqual(testObject.polyline.show.getValue(time));
- expect(primitive.getPositions().length > 0);
-
- });
-
- it('A DynamicPolyline causes a primtive to be created and updated.', function() {
- var time = new JulianDate();
-
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolylineVisualizer(scene, dynamicObjectCollection);
-
- expect(scene.getPrimitives().getLength()).toEqual(1);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.vertexPositions = new ConstantProperty([new Cartesian3(1234, 5678, 9101112), new Cartesian3(5678, 1234, 1101112)]);
-
- var polyline = testObject.polyline = new DynamicPolyline();
- polyline.show = new ConstantProperty(true);
- polyline.material = new ColorMaterialProperty();
- polyline.width = new ConstantProperty(12.5);
-
- visualizer.update(time);
-
- expect(scene.getPrimitives().getLength()).toEqual(1);
-
- var polylineCollection = scene.getPrimitives().get(0);
- var primitive = polylineCollection.get(0);
- visualizer.update(time);
- expect(primitive.getShow()).toEqual(testObject.polyline.show.getValue(time));
- expect(primitive.getPositions()).toEqual(testObject.vertexPositions.getValue(time));
- expect(primitive.getWidth()).toEqual(testObject.polyline.width.getValue(time));
-
- var material = primitive.getMaterial();
- expect(material.uniforms).toEqual(testObject.polyline.material.getValue(time));
-
- testObject.vertexPositions = new ConstantProperty([new Cartesian3(5678, 1234, 1101112), new Cartesian3(1234, 5678, 9101112)]);
- polyline.material = new ColorMaterialProperty();
- polyline.width = new ConstantProperty(2.5);
-
- visualizer.update(time);
- expect(primitive.getShow()).toEqual(testObject.polyline.show.getValue(time));
- expect(primitive.getPositions()).toEqual(testObject.vertexPositions.getValue(time));
- expect(primitive.getWidth()).toEqual(testObject.polyline.width.getValue(time));
-
- material = primitive.getMaterial();
- expect(material.uniforms).toEqual(testObject.polyline.material.getValue(time));
-
- polyline.show = new ConstantProperty(false);
- visualizer.update(time);
- expect(primitive.getShow()).toEqual(testObject.polyline.show.getValue(time));
- });
-
- it('clear hides primitives.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolylineVisualizer(scene, dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- var time = new JulianDate();
-
- testObject.vertexPositions = new ConstantProperty([new Cartesian3(5678, 1234, 1101112), new Cartesian3(1234, 5678, 9101112)]);
- var polyline = testObject.polyline = new DynamicPolyline();
- polyline.show = new ConstantProperty(true);
- visualizer.update(time);
-
- var polylineCollection = scene.getPrimitives().get(0);
- expect(polylineCollection.getLength()).toEqual(1);
- var primitive = polylineCollection.get(0);
-
- visualizer.update(time);
- //Clearing won't actually remove the primitive because of the
- //internal cache used by the visualizer, instead it just hides it.
- dynamicObjectCollection.removeAll();
- expect(primitive.getShow()).toEqual(false);
- });
-
- it('Visualizer sets dynamicObject property.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- visualizer = new DynamicPolylineVisualizer(scene, dynamicObjectCollection);
-
- expect(scene.getPrimitives().getLength()).toEqual(1);
-
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
-
- var time = new JulianDate();
- var polyline = testObject.polyline = new DynamicPolyline();
-
- testObject.vertexPositions = new ConstantProperty([new Cartesian3(5678, 1234, 1101112), new Cartesian3(1234, 5678, 9101112)]);
- polyline.show = new ConstantProperty(true);
-
- visualizer.update(time);
- var polylineCollection = scene.getPrimitives().get(0);
- expect(polylineCollection.getLength()).toEqual(1);
- var primitive = polylineCollection.get(0);
- expect(primitive.dynamicObject).toEqual(testObject);
- });
-
- it('setDynamicObjectCollection removes old objects and add new ones.', function() {
- var dynamicObjectCollection = new DynamicObjectCollection();
- var testObject = dynamicObjectCollection.getOrCreateObject('test');
- testObject.vertexPositions = new ConstantProperty([new Cartesian3(5678, 1234, 1101112), new Cartesian3(1234, 5678, 9101112)]);
- testObject.polyline = new DynamicPolyline();
- testObject.polyline.show = new ConstantProperty(true);
-
- var dynamicObjectCollection2 = new DynamicObjectCollection();
- var testObject2 = dynamicObjectCollection2.getOrCreateObject('test2');
- testObject2.vertexPositions = new ConstantProperty([new Cartesian3(1234, 5678, 9101112), new Cartesian3(5678, 1234, 1101112)]);
- testObject2.polyline = new DynamicPolyline();
- testObject2.polyline.show = new ConstantProperty(true);
-
- visualizer = new DynamicPolylineVisualizer(scene, dynamicObjectCollection);
-
- var time = new JulianDate();
-
- visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
- expect(polylineCollection.getLength()).toEqual(1);
- var primitive = polylineCollection.get(0);
- expect(primitive.dynamicObject).toEqual(testObject);
-
- visualizer.setDynamicObjectCollection(dynamicObjectCollection2);
- visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- primitive = polylineCollection.get(0);
- expect(primitive.dynamicObject).toEqual(testObject2);
- });
-}, 'WebGL');
\ No newline at end of file
diff --git a/Specs/DynamicScene/DynamicPyramidSpec.js b/Specs/DynamicScene/DynamicPyramidSpec.js
index db13c145981b..58594f9f0448 100644
--- a/Specs/DynamicScene/DynamicPyramidSpec.js
+++ b/Specs/DynamicScene/DynamicPyramidSpec.js
@@ -3,13 +3,11 @@ defineSuite([
'DynamicScene/DynamicPyramid',
'DynamicScene/ColorMaterialProperty',
'DynamicScene/ConstantProperty',
- 'DynamicScene/DynamicVertexPositionsProperty',
'Core/Color'
], function(
DynamicPyramid,
ColorMaterialProperty,
ConstantProperty,
- DynamicVertexPositionsProperty,
Color) {
"use strict";
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
diff --git a/Specs/DynamicScene/DynamicPyramidVisualizerSpec.js b/Specs/DynamicScene/DynamicPyramidVisualizerSpec.js
index 67570b49ab9c..68faee020d1b 100644
--- a/Specs/DynamicScene/DynamicPyramidVisualizerSpec.js
+++ b/Specs/DynamicScene/DynamicPyramidVisualizerSpec.js
@@ -91,7 +91,7 @@ defineSuite([
testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
testObject.orientation = new ConstantProperty(new Quaternion(0, 0, 0, 1));
visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
});
it('object with no position does not create a primitive.', function() {
@@ -103,7 +103,7 @@ defineSuite([
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)]);
visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
});
it('object with no orientation does not create a primitive.', function() {
@@ -115,7 +115,7 @@ defineSuite([
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)]);
visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
});
it('A DynamicPyramid causes a CustomSensor to be created and updated.', function() {
@@ -137,8 +137,8 @@ defineSuite([
pyramid.material = new ColorMaterialProperty();
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var p = scene.getPrimitives().get(0);
+ expect(scene.primitives.length).toEqual(1);
+ var p = scene.primitives.get(0);
expect(p.intersectionColor).toEqual(testObject.pyramid.intersectionColor.getValue(time));
expect(p.intersectionWidth).toEqual(testObject.pyramid.intersectionWidth.getValue(time));
expect(p.showIntersection).toEqual(testObject.pyramid.showIntersection.getValue(time));
@@ -163,14 +163,14 @@ defineSuite([
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 time = new JulianDate();
- expect(scene.getPrimitives().getLength()).toEqual(0);
+ expect(scene.primitives.length).toEqual(0);
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- expect(scene.getPrimitives().get(0).show).toEqual(true);
+ expect(scene.primitives.length).toEqual(1);
+ expect(scene.primitives.get(0).show).toEqual(true);
dynamicObjectCollection.removeAll();
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- expect(scene.getPrimitives().get(0).show).toEqual(false);
+ expect(scene.primitives.length).toEqual(1);
+ expect(scene.primitives.get(0).show).toEqual(false);
});
it('Visualizer sets dynamicObject property.', function() {
@@ -185,7 +185,7 @@ defineSuite([
var time = new JulianDate();
visualizer.update(time);
- expect(scene.getPrimitives().get(0).dynamicObject).toEqual(testObject);
+ expect(scene.primitives.get(0).id).toEqual(testObject);
});
it('setDynamicObjectCollection removes old objects and add new ones.', function() {
@@ -208,14 +208,14 @@ defineSuite([
var time = new JulianDate();
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var pyramidPrimitive = scene.getPrimitives().get(0);
- expect(pyramidPrimitive.dynamicObject).toEqual(testObject);
+ 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.getPrimitives().getLength()).toEqual(1);
- pyramidPrimitive = scene.getPrimitives().get(0);
- expect(pyramidPrimitive.dynamicObject).toEqual(testObject2);
+ 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 453afc9f60d7..3d4afc0376fd 100644
--- a/Specs/DynamicScene/DynamicVectorVisualizerSpec.js
+++ b/Specs/DynamicScene/DynamicVectorVisualizerSpec.js
@@ -58,7 +58,7 @@ defineSuite([
visualizer = new DynamicVectorVisualizer(scene, dynamicObjectCollection);
expect(visualizer.getScene()).toEqual(scene);
expect(visualizer.getDynamicObjectCollection()).toEqual(dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(1);
+ expect(scene.primitives.length).toEqual(1);
});
it('update throws if no time specified.', function() {
@@ -89,8 +89,8 @@ defineSuite([
var testObject = dynamicObjectCollection.getOrCreateObject('test');
testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
+ expect(scene.primitives.length).toEqual(1);
+ var polylineCollection = scene.primitives.get(0);
expect(polylineCollection.getLength()).toEqual(0);
});
@@ -103,8 +103,8 @@ defineSuite([
vector.show = new ConstantProperty(true);
visualizer.update(new JulianDate());
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
+ expect(scene.primitives.length).toEqual(1);
+ var polylineCollection = scene.primitives.get(0);
expect(polylineCollection.getLength()).toEqual(0);
});
@@ -114,7 +114,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicVectorVisualizer(scene, dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(1);
+ expect(scene.primitives.length).toEqual(1);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
testObject.position = new ConstantPositionProperty(new Cartesian3(1234, 5678, 9101112));
@@ -128,9 +128,9 @@ defineSuite([
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
+ expect(scene.primitives.length).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
+ var polylineCollection = scene.primitives.get(0);
var primitive = polylineCollection.get(0);
visualizer.update(time);
expect(primitive.getShow()).toEqual(testObject.vector.show.getValue(time));
@@ -161,7 +161,7 @@ defineSuite([
it('clear hides primitives.', function() {
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicVectorVisualizer(scene, dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(1);
+ expect(scene.primitives.length).toEqual(1);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
var time = new JulianDate();
@@ -174,7 +174,7 @@ defineSuite([
vector.direction = new ConstantProperty(new Cartesian3(1, 2, 3));
visualizer.update(time);
- var polylineCollection = scene.getPrimitives().get(0);
+ var polylineCollection = scene.primitives.get(0);
expect(polylineCollection.getLength()).toEqual(1);
var primitive = polylineCollection.get(0);
@@ -189,7 +189,7 @@ defineSuite([
var dynamicObjectCollection = new DynamicObjectCollection();
visualizer = new DynamicVectorVisualizer(scene, dynamicObjectCollection);
- expect(scene.getPrimitives().getLength()).toEqual(1);
+ expect(scene.primitives.length).toEqual(1);
var testObject = dynamicObjectCollection.getOrCreateObject('test');
@@ -204,10 +204,10 @@ defineSuite([
vector.direction = new ConstantProperty(new Cartesian3(1, 2, 3));
visualizer.update(time);
- var polylineCollection = scene.getPrimitives().get(0);
+ var polylineCollection = scene.primitives.get(0);
expect(polylineCollection.getLength()).toEqual(1);
var primitive = polylineCollection.get(0);
- expect(primitive.dynamicObject).toEqual(testObject);
+ expect(primitive.id).toEqual(testObject);
});
it('setDynamicObjectCollection removes old objects and add new ones.', function() {
@@ -236,16 +236,16 @@ defineSuite([
var time = new JulianDate();
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
- var polylineCollection = scene.getPrimitives().get(0);
+ expect(scene.primitives.length).toEqual(1);
+ var polylineCollection = scene.primitives.get(0);
expect(polylineCollection.getLength()).toEqual(1);
var primitive = polylineCollection.get(0);
- expect(primitive.dynamicObject).toEqual(testObject);
+ expect(primitive.id).toEqual(testObject);
visualizer.setDynamicObjectCollection(dynamicObjectCollection2);
visualizer.update(time);
- expect(scene.getPrimitives().getLength()).toEqual(1);
+ expect(scene.primitives.length).toEqual(1);
primitive = polylineCollection.get(0);
- expect(primitive.dynamicObject).toEqual(testObject2);
+ expect(primitive.id).toEqual(testObject2);
});
}, 'WebGL');
diff --git a/Specs/DynamicScene/DynamicVertexPositionsPropertySpec.js b/Specs/DynamicScene/DynamicVertexPositionsPropertySpec.js
deleted file mode 100644
index 3322599322f9..000000000000
--- a/Specs/DynamicScene/DynamicVertexPositionsPropertySpec.js
+++ /dev/null
@@ -1,151 +0,0 @@
-/*global defineSuite*/
-defineSuite([
- 'DynamicScene/DynamicVertexPositionsProperty',
- 'DynamicScene/DynamicObjectCollection',
- 'DynamicScene/CzmlDataSource',
- 'Core/Cartographic',
- 'Core/JulianDate',
- 'Core/Math',
- 'Core/Ellipsoid'
- ], function(
- DynamicVertexPositionsProperty,
- DynamicObjectCollection,
- CzmlDataSource,
- Cartographic,
- JulianDate,
- CesiumMath,
- Ellipsoid) {
- "use strict";
- /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
-
- var cartographicRadiansInterval = {
- cartographicRadians : [1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9]
- };
-
- var cartographicDegreesInterval = {
- cartographicDegrees : [10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9]
- };
-
- var cartesianInterval = {
- cartesian : [10000, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009]
- };
-
- var testObjects = [{
- id : 'test1',
- position : {
- cartesian : [100000, 100001, 100003]
- }
- }, {
- id : 'test2',
- position : {
- cartesian : [100004, 100005, 100006]
- }
- }, {
- id : 'test3',
- position : {
- interval : '2012-04-18T15:59:00Z/2012-04-18T15:59:00Z',
- cartesian : [100007, 100008, 100009]
- }
- }];
-
- var referenceInterval = {
- references : ['test1.position', 'test2.position', 'test3.position']
- };
-
- it('getValue returns undefined if no data exists', function() {
- var property = new DynamicVertexPositionsProperty();
- expect(property.getValue(new JulianDate())).toBeUndefined();
- });
-
- it('getValue throw if no time supplied', function() {
- var property = new DynamicVertexPositionsProperty();
- expect(function() {
- property.getValue();
- }).toThrow();
- });
-
- it('getValue works for cartesian data', function() {
- var property = new DynamicVertexPositionsProperty();
- property.processCzmlIntervals(cartesianInterval);
- var result = property.getValue(new JulianDate());
- expect(result.length).toEqual(3);
- expect(result[0].x).toEqual(cartesianInterval.cartesian[0]);
- expect(result[0].y).toEqual(cartesianInterval.cartesian[1]);
- expect(result[0].z).toEqual(cartesianInterval.cartesian[2]);
-
- expect(result[1].x).toEqual(cartesianInterval.cartesian[3]);
- expect(result[1].y).toEqual(cartesianInterval.cartesian[4]);
- expect(result[1].z).toEqual(cartesianInterval.cartesian[5]);
-
- expect(result[2].x).toEqual(cartesianInterval.cartesian[6]);
- expect(result[2].y).toEqual(cartesianInterval.cartesian[7]);
- expect(result[2].z).toEqual(cartesianInterval.cartesian[8]);
- });
-
- it('getValue works for cartographic degrees data', function() {
- var property = new DynamicVertexPositionsProperty();
- property.processCzmlIntervals(cartographicDegreesInterval);
- var result = property.getValue(new JulianDate());
-
- var expected = Ellipsoid.WGS84.cartographicArrayToCartesianArray([new Cartographic(CesiumMath.toRadians(10.1), CesiumMath.toRadians(10.2), 10.3), new Cartographic(CesiumMath.toRadians(10.4), CesiumMath.toRadians(10.5), 10.6), new Cartographic(CesiumMath.toRadians(10.7), CesiumMath.toRadians(10.8), 10.9)]);
-
- expect(result.length).toEqual(3);
- expect(result[0].x).toEqual(expected[0].x);
- expect(result[0].y).toEqual(expected[0].y);
- expect(result[0].z).toEqual(expected[0].z);
-
- expect(result[1].x).toEqual(expected[1].x);
- expect(result[1].y).toEqual(expected[1].y);
- expect(result[1].z).toEqual(expected[1].z);
-
- expect(result[2].x).toEqual(expected[2].x);
- expect(result[2].y).toEqual(expected[2].y);
- expect(result[2].z).toEqual(expected[2].z);
- });
-
- it('getValue works for cartographic radians data', function() {
- var property = new DynamicVertexPositionsProperty();
- property.processCzmlIntervals(cartographicRadiansInterval);
- var result = property.getValue(new JulianDate());
-
- var expected = Ellipsoid.WGS84.cartographicArrayToCartesianArray([new Cartographic(1.1, 1.2, 1.3), new Cartographic(1.4, 1.5, 1.6), new Cartographic(1.7, 1.8, 1.9)]);
-
- expect(result.length).toEqual(3);
- expect(result[0].x).toEqual(expected[0].x);
- expect(result[0].y).toEqual(expected[0].y);
- expect(result[0].z).toEqual(expected[0].z);
-
- expect(result[1].x).toEqual(expected[1].x);
- expect(result[1].y).toEqual(expected[1].y);
- expect(result[1].z).toEqual(expected[1].z);
-
- expect(result[2].x).toEqual(expected[2].x);
- expect(result[2].y).toEqual(expected[2].y);
- expect(result[2].z).toEqual(expected[2].z);
- });
-
- it('getValue works for reference data', function() {
- var source = new CzmlDataSource();
- var objects = source.getDynamicObjectCollection();
- source.load(testObjects);
- var test1 = objects.getById('test1');
- var test2 = objects.getById('test2');
- var test3 = objects.getById('test3');
-
- var property = new DynamicVertexPositionsProperty();
- property.processCzmlIntervals(referenceInterval, undefined, objects);
-
- var time = JulianDate.fromIso8601('2011-04-18T15:59:00Z');
- var result = property.getValue(time);
- expect(result.length).toEqual(2);
- expect(result[0]).toEqual(test1.position.getValue(time));
- expect(result[1]).toEqual(test2.position.getValue(time));
-
- time = JulianDate.fromIso8601('2012-04-18T15:59:00Z');
- result = property.getValue(time);
- expect(result.length).toEqual(3);
- expect(result[0]).toEqual(test1.position.getValue(time));
- expect(result[1]).toEqual(test2.position.getValue(time));
- expect(result[2]).toEqual(test3.position.getValue(time));
- });
-});
diff --git a/Specs/DynamicScene/EllipseGeometryUpdaterSpec.js b/Specs/DynamicScene/EllipseGeometryUpdaterSpec.js
new file mode 100644
index 000000000000..34d948f5bc69
--- /dev/null
+++ b/Specs/DynamicScene/EllipseGeometryUpdaterSpec.js
@@ -0,0 +1,497 @@
+/*global defineSuite*/
+defineSuite(['DynamicScene/EllipseGeometryUpdater',
+ 'DynamicScene/DynamicObject',
+ 'DynamicScene/DynamicEllipse',
+ 'Core/Cartesian3',
+ 'Core/Color',
+ 'Core/JulianDate',
+ 'Core/TimeInterval',
+ 'Core/TimeIntervalCollection',
+ 'Core/ColorGeometryInstanceAttribute',
+ 'Core/ShowGeometryInstanceAttribute',
+ 'DynamicScene/ColorMaterialProperty',
+ 'DynamicScene/ConstantProperty',
+ 'DynamicScene/ConstantPositionProperty',
+ 'DynamicScene/GridMaterialProperty',
+ 'DynamicScene/SampledProperty',
+ 'DynamicScene/SampledPositionProperty',
+ 'DynamicScene/TimeIntervalCollectionProperty',
+ 'Scene/CompositePrimitive'
+ ], function(
+ EllipseGeometryUpdater,
+ DynamicObject,
+ DynamicEllipse,
+ Cartesian3,
+ Color,
+ JulianDate,
+ TimeInterval,
+ TimeIntervalCollection,
+ ColorGeometryInstanceAttribute,
+ ShowGeometryInstanceAttribute,
+ ColorMaterialProperty,
+ ConstantProperty,
+ ConstantPositionProperty,
+ GridMaterialProperty,
+ SampledProperty,
+ SampledPositionProperty,
+ TimeIntervalCollectionProperty,
+ CompositePrimitive) {
+ "use strict";
+ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
+
+ var time = new JulianDate();
+
+ function createBasicEllipse() {
+ var ellipse = new DynamicEllipse();
+ ellipse.semiMajorAxis = new ConstantProperty(2);
+ ellipse.semiMinorAxis = new ConstantProperty(1);
+
+ var dynamicObject = new DynamicObject();
+ dynamicObject.position = new ConstantPositionProperty(Cartesian3.ZERO);
+ dynamicObject.ellipse = ellipse;
+ return dynamicObject;
+ }
+
+ it('Constructor sets expected defaults', function() {
+ var dynamicObject = new DynamicObject();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+
+ expect(updater.isDestroyed()).toBe(false);
+ expect(updater.dynamicObject).toBe(dynamicObject);
+ expect(updater.isClosed).toBe(false);
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.fillMaterialProperty).toBe(undefined);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.hasConstantFill).toBe(true);
+ expect(updater.hasConstantOutline).toBe(true);
+ expect(updater.outlineColorProperty).toBe(undefined);
+ expect(updater.isDynamic).toBe(false);
+ expect(updater.isOutlineVisible(time)).toBe(false);
+ expect(updater.isFilled(time)).toBe(false);
+ updater.destroy();
+ expect(updater.isDestroyed()).toBe(true);
+ });
+
+ it('No geometry available when ellipse is undefined ', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse = undefined;
+
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('No geometry available when semiMajorAxis is undefined', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.semiMajorAxis = undefined;
+
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('No geometry available when semiMinorAxis is undefined', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.semiMinorAxis = undefined;
+
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('No geometry available when not filled or outline.', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.fill = new ConstantProperty(false);
+ dynamicObject.ellipse.outline = new ConstantProperty(false);
+
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('Values correct when using default graphics', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+
+ expect(updater.isClosed).toBe(false);
+ expect(updater.fillEnabled).toBe(true);
+ expect(updater.fillMaterialProperty).toEqual(ColorMaterialProperty.fromColor(Color.WHITE));
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.hasConstantFill).toBe(true);
+ expect(updater.hasConstantOutline).toBe(true);
+ expect(updater.outlineColorProperty).toBe(undefined);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('Ellipse material is correctly exposed.', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.material = new GridMaterialProperty(Color.BLUE);
+ expect(updater.fillMaterialProperty).toBe(dynamicObject.ellipse.material);
+ });
+
+ it('Settings extrudedHeight causes geometry to be closed.', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.extrudedHeight = new ConstantProperty(1000);
+ expect(updater.isClosed).toBe(true);
+ });
+
+ it('A time-varying position causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.position = new SampledPositionProperty();
+ dynamicObject.position.addSample(time, Cartesian3.ZERO);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying semiMinorAxis causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.semiMinorAxis = new SampledProperty(Number);
+ dynamicObject.ellipse.semiMinorAxis.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying semiMajorAxis causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.semiMajorAxis = new SampledProperty(Number);
+ dynamicObject.ellipse.semiMajorAxis.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying rotation causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.rotation = new SampledProperty(Number);
+ dynamicObject.ellipse.rotation.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying height causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.height = new SampledProperty(Number);
+ dynamicObject.ellipse.height.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying extrudedHeight causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.extrudedHeight = new SampledProperty(Number);
+ dynamicObject.ellipse.extrudedHeight.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying granularity causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.granularity = new SampledProperty(Number);
+ dynamicObject.ellipse.granularity.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying stRotation causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.stRotation = new SampledProperty(Number);
+ dynamicObject.ellipse.stRotation.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying numberOfVerticalLines causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ dynamicObject.ellipse.numberOfVerticalLines = new SampledProperty(Number);
+ dynamicObject.ellipse.numberOfVerticalLines.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ function validateGeometryInstance(options) {
+ var dynamicObject = new DynamicObject();
+ dynamicObject.position = new ConstantPositionProperty(options.center);
+
+ var ellipse = new DynamicEllipse();
+ ellipse.show = new ConstantProperty(options.show);
+ ellipse.fill = new ConstantProperty(options.fill);
+ ellipse.material = options.material;
+ ellipse.outline = new ConstantProperty(options.outline);
+ ellipse.outlineColor = new ConstantProperty(options.outlineColor);
+ ellipse.numberOfVerticalLines = new ConstantProperty(options.numberOfVerticalLines);
+
+ ellipse.semiMajorAxis = new ConstantProperty(options.semiMajorAxis);
+ ellipse.semiMinorAxis = new ConstantProperty(options.semiMinorAxis);
+ ellipse.rotation = new ConstantProperty(options.rotation);
+ ellipse.stRotation = new ConstantProperty(options.stRotation);
+ ellipse.height = new ConstantProperty(options.height);
+ ellipse.extrudedHeight = new ConstantProperty(options.extrudedHeight);
+ ellipse.granularity = new ConstantProperty(options.granularity);
+ dynamicObject.ellipse = ellipse;
+
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+
+ var instance;
+ var geometry;
+ var attributes;
+ if (options.fill) {
+ instance = updater.createFillGeometryInstance(time);
+ geometry = instance.geometry;
+ expect(geometry._center).toEqual(options.center);
+ expect(geometry._semiMajorAxis).toEqual(options.semiMajorAxis);
+ expect(geometry._semiMinorAxis).toEqual(options.semiMinorAxis);
+ expect(geometry._rotation).toEqual(options.rotation);
+ expect(geometry._stRotation).toEqual(options.stRotation);
+ expect(geometry._height).toEqual(options.height);
+ expect(geometry._granularity).toEqual(options.granularity);
+ expect(geometry._extrudedHeight).toEqual(options.extrudedHeight);
+
+ attributes = instance.attributes;
+ if (options.material instanceof ColorMaterialProperty) {
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(options.material.color.getValue(time)));
+ } else {
+ expect(attributes.color).toBeUndefined();
+ }
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(options.fill));
+ }
+
+ if (options.outline) {
+ instance = updater.createOutlineGeometryInstance(time);
+ geometry = instance.geometry;
+ expect(geometry._center).toEqual(options.center);
+ expect(geometry._semiMajorAxis).toEqual(options.semiMajorAxis);
+ expect(geometry._semiMinorAxis).toEqual(options.semiMinorAxis);
+ expect(geometry._rotation).toEqual(options.rotation);
+ expect(geometry._height).toEqual(options.height);
+ expect(geometry._granularity).toEqual(options.granularity);
+ expect(geometry._extrudedHeight).toEqual(options.extrudedHeight);
+ expect(geometry._numberOfVerticalLines).toEqual(options.numberOfVerticalLines);
+
+ attributes = instance.attributes;
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(options.outlineColor));
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(options.fill));
+ }
+ }
+
+ it('Creates expected per-color geometry', function() {
+ validateGeometryInstance({
+ center : new Cartesian3(4, 5, 6),
+ rotation : 1,
+ semiMajorAxis : 3,
+ semiMinorAxis : 2,
+ show : true,
+ material : ColorMaterialProperty.fromColor(Color.RED),
+ height : 123,
+ extrudedHeight : 431,
+ granularity : 0.97,
+ stRotation : 12,
+ fill : true,
+ outline : true,
+ outlineColor : Color.BLUE,
+ numberOfVerticalLines : 15
+ });
+ });
+
+ it('Creates expected per-material geometry', function() {
+ validateGeometryInstance({
+ center : new Cartesian3(4, 5, 6),
+ rotation : 1,
+ semiMajorAxis : 3,
+ semiMinorAxis : 2,
+ show : true,
+ material : new GridMaterialProperty(),
+ height : 123,
+ extrudedHeight : 431,
+ granularity : 0.97,
+ stRotation : 12,
+ fill : true,
+ outline : true,
+ outlineColor : Color.BLUE,
+ numberOfVerticalLines : 15
+ });
+ });
+
+ it('Attributes have expected values at creation time', function() {
+ var time1 = new JulianDate(0, 0);
+ var time2 = new JulianDate(10, 0);
+ var time3 = new JulianDate(20, 0);
+
+ var fill = new TimeIntervalCollectionProperty();
+ fill.intervals.addInterval(new TimeInterval(time1, time2, true, true, false));
+ fill.intervals.addInterval(new TimeInterval(time2, time3, false, true, true));
+
+ var colorMaterial = new ColorMaterialProperty();
+ colorMaterial.color = new SampledProperty(Color);
+ colorMaterial.color.addSample(time, Color.YELLOW);
+ colorMaterial.color.addSample(time2, Color.BLUE);
+ colorMaterial.color.addSample(time3, Color.RED);
+
+ var outline = new TimeIntervalCollectionProperty();
+ outline.intervals.addInterval(new TimeInterval(time1, time2, true, true, false));
+ outline.intervals.addInterval(new TimeInterval(time2, time3, false, true, true));
+
+ var outlineColor = new SampledProperty(Color);
+ outlineColor.addSample(time, Color.BLUE);
+ outlineColor.addSample(time2, Color.RED);
+ outlineColor.addSample(time3, Color.YELLOW);
+
+ var dynamicObject = createBasicEllipse();
+ dynamicObject.ellipse.fill = fill;
+ dynamicObject.ellipse.material = colorMaterial;
+ dynamicObject.ellipse.outline = outline;
+ dynamicObject.ellipse.outlineColor = outlineColor;
+
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+
+ var instance = updater.createFillGeometryInstance(time2);
+ var attributes = instance.attributes;
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(colorMaterial.color.getValue(time2)));
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(fill.getValue(time2)));
+
+ instance = updater.createOutlineGeometryInstance(time2);
+ attributes = instance.attributes;
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(outlineColor.getValue(time2)));
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(outline.getValue(time2)));
+ });
+
+ it('dynamic updater sets properties', function() {
+ //This test is mostly a smoke screen for now.
+ var time1 = new JulianDate(0, 0);
+ var time2 = new JulianDate(1, 0);
+ var time3 = new JulianDate(2, 0);
+
+ function makeProperty(value1, value2) {
+ var property = new TimeIntervalCollectionProperty();
+ property.intervals.addInterval(new TimeInterval(time1, time2, true, false, value1));
+ property.intervals.addInterval(new TimeInterval(time2, time3, true, false, value2));
+ return property;
+ }
+
+ var ellipse = new DynamicEllipse();
+ ellipse.semiMajorAxis = makeProperty(2, 12);
+ ellipse.semiMinorAxis = makeProperty(1, 11);
+ ellipse.outline = makeProperty(true, false);
+ ellipse.fill = makeProperty(false, true);
+
+ var dynamicObject = new DynamicObject();
+ dynamicObject.availability = new TimeIntervalCollection();
+ dynamicObject.availability.addInterval(new TimeInterval(time1, time3, true, false));
+ dynamicObject.position = makeProperty(Cartesian3.UNIT_Z, Cartesian3.UNIT_Y);
+ dynamicObject.ellipse = ellipse;
+
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ var primitives = new CompositePrimitive();
+ var dynamicUpdater = updater.createDynamicUpdater(primitives);
+ expect(dynamicUpdater.isDestroyed()).toBe(false);
+ expect(primitives.length).toBe(0);
+ dynamicUpdater.update(time1);
+ expect(primitives.length).toBe(1);
+ dynamicUpdater.destroy();
+ expect(primitives.length).toBe(0);
+ updater.destroy();
+ });
+
+ it('geometryChanged event is raised when expected', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ var listener = jasmine.createSpy('listener');
+ updater.geometryChanged.addEventListener(listener);
+
+ dynamicObject.position = new ConstantPositionProperty(Cartesian3.UNIT_Z);
+ expect(listener.callCount).toEqual(1);
+
+ dynamicObject.ellipse.semiMajorAxis = new ConstantProperty(82);
+ expect(listener.callCount).toEqual(2);
+
+ dynamicObject.availability = new TimeIntervalCollection();
+ expect(listener.callCount).toEqual(3);
+
+ dynamicObject.ellipse.semiMajorAxis = undefined;
+ expect(listener.callCount).toEqual(4);
+
+ //Since there's no valid geometry, changing another property should not raise the event.
+ dynamicObject.ellipse.semiMinorAxis = undefined;
+
+ //Modifying an unrelated property should not have any effect.
+ dynamicObject.viewFrom = new ConstantProperty(Cartesian3.UNIT_X);
+ expect(listener.callCount).toEqual(4);
+
+ dynamicObject.ellipse.semiMajorAxis = new SampledProperty(Number);
+ dynamicObject.ellipse.semiMinorAxis = new SampledProperty(Number);
+ expect(listener.callCount).toEqual(5);
+ });
+
+ it('createFillGeometryInstance throws if object is not filled', function() {
+ var dynamicObject = new DynamicObject();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createFillGeometryInstance(time);
+ }).toThrowDeveloperError();
+ });
+
+ it('createFillGeometryInstance throws if no time provided', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createFillGeometryInstance(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('createOutlineGeometryInstance throws if object is not outlined', function() {
+ var dynamicObject = new DynamicObject();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createOutlineGeometryInstance(time);
+ }).toThrowDeveloperError();
+ });
+
+ it('createOutlineGeometryInstance throws if no time provided', function() {
+ var dynamicObject = createBasicEllipse();
+ dynamicObject.ellipse.outline = new ConstantProperty(true);
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createOutlineGeometryInstance(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('createDynamicUpdater throws if not dynamic', function() {
+ var dynamicObject = createBasicEllipse();
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createDynamicUpdater(new CompositePrimitive());
+ }).toThrowDeveloperError();
+ });
+
+ it('createDynamicUpdater throws if primitives undefined', function() {
+ var dynamicObject = createBasicEllipse();
+ dynamicObject.ellipse.semiMajorAxis = new SampledProperty(Number);
+ dynamicObject.ellipse.semiMajorAxis.addSample(time, 4);
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ expect(updater.isDynamic).toBe(true);
+ expect(function() {
+ return updater.createDynamicUpdater(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('dynamicUpdater.update throws if no time specified', function() {
+ var dynamicObject = createBasicEllipse();
+ dynamicObject.ellipse.semiMajorAxis = new SampledProperty(Number);
+ dynamicObject.ellipse.semiMajorAxis.addSample(time, 4);
+ var updater = new EllipseGeometryUpdater(dynamicObject);
+ var dynamicUpdater = updater.createDynamicUpdater(new CompositePrimitive());
+ expect(function() {
+ dynamicUpdater.update(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('Constructor throws if no DynamicObject supplied', function() {
+ expect(function() {
+ return new EllipseGeometryUpdater(undefined);
+ }).toThrowDeveloperError();
+ });
+});
\ No newline at end of file
diff --git a/Specs/DynamicScene/EllipsoidGeometryUpdaterSpec.js b/Specs/DynamicScene/EllipsoidGeometryUpdaterSpec.js
new file mode 100644
index 000000000000..33e934f1fdec
--- /dev/null
+++ b/Specs/DynamicScene/EllipsoidGeometryUpdaterSpec.js
@@ -0,0 +1,441 @@
+/*global defineSuite*/
+defineSuite(['DynamicScene/EllipsoidGeometryUpdater',
+ 'DynamicScene/DynamicObject',
+ 'DynamicScene/DynamicEllipsoid',
+ 'Core/Cartesian3',
+ 'Core/Color',
+ 'Core/JulianDate',
+ 'Core/Quaternion',
+ 'Core/TimeInterval',
+ 'Core/TimeIntervalCollection',
+ 'Core/ColorGeometryInstanceAttribute',
+ 'Core/ShowGeometryInstanceAttribute',
+ 'DynamicScene/ColorMaterialProperty',
+ 'DynamicScene/ConstantProperty',
+ 'DynamicScene/ConstantPositionProperty',
+ 'DynamicScene/GridMaterialProperty',
+ 'DynamicScene/SampledProperty',
+ 'DynamicScene/SampledPositionProperty',
+ 'DynamicScene/TimeIntervalCollectionProperty',
+ 'Scene/CompositePrimitive',
+ 'Specs/createScene',
+ 'Specs/destroyScene'
+ ], function(
+ EllipsoidGeometryUpdater,
+ DynamicObject,
+ DynamicEllipsoid,
+ Cartesian3,
+ Color,
+ JulianDate,
+ Quaternion,
+ TimeInterval,
+ TimeIntervalCollection,
+ ColorGeometryInstanceAttribute,
+ ShowGeometryInstanceAttribute,
+ ColorMaterialProperty,
+ ConstantProperty,
+ ConstantPositionProperty,
+ GridMaterialProperty,
+ SampledProperty,
+ SampledPositionProperty,
+ TimeIntervalCollectionProperty,
+ CompositePrimitive,
+ createScene,
+ destroyScene) {
+ "use strict";
+ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
+
+ var time = new JulianDate();
+ var scene;
+ beforeEach(function() {
+ scene = createScene();
+ });
+
+ afterEach(function() {
+ destroyScene(scene);
+ });
+ function createBasicEllipsoid() {
+ var ellipsoid = new DynamicEllipsoid();
+ ellipsoid.radii = new ConstantProperty(new Cartesian3(1, 2, 3));
+
+ var dynamicObject = new DynamicObject();
+ dynamicObject.position = new ConstantPositionProperty(Cartesian3.ZERO);
+ dynamicObject.orientation = new ConstantProperty(Quaternion.IDENTITY);
+ dynamicObject.ellipsoid = ellipsoid;
+ return dynamicObject;
+ }
+
+ it('Constructor sets expected defaults', function() {
+ var dynamicObject = new DynamicObject();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+
+ expect(updater.isDestroyed()).toBe(false);
+ expect(updater.dynamicObject).toBe(dynamicObject);
+ expect(updater.isClosed).toBe(true);
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.fillMaterialProperty).toBe(undefined);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.hasConstantFill).toBe(true);
+ expect(updater.hasConstantOutline).toBe(true);
+ expect(updater.outlineColorProperty).toBe(undefined);
+ expect(updater.isDynamic).toBe(false);
+ expect(updater.isOutlineVisible(time)).toBe(false);
+ expect(updater.isFilled(time)).toBe(false);
+ updater.destroy();
+ expect(updater.isDestroyed()).toBe(true);
+ });
+
+ it('No geometry available when ellipsoid is undefined ', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ dynamicObject.ellipsoid = undefined;
+
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('No geometry available when radii is undefined', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ dynamicObject.ellipsoid.radii = undefined;
+
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('No geometry available when not filled or outline.', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ dynamicObject.ellipsoid.fill = new ConstantProperty(false);
+ dynamicObject.ellipsoid.outline = new ConstantProperty(false);
+
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('Values correct when using default graphics', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+
+ expect(updater.fillEnabled).toBe(true);
+ expect(updater.fillMaterialProperty).toEqual(ColorMaterialProperty.fromColor(Color.WHITE));
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.hasConstantFill).toBe(true);
+ expect(updater.hasConstantOutline).toBe(true);
+ expect(updater.outlineColorProperty).toBe(undefined);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('Ellipsoid material is correctly exposed.', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ dynamicObject.ellipsoid.material = new GridMaterialProperty(Color.BLUE);
+ expect(updater.fillMaterialProperty).toBe(dynamicObject.ellipsoid.material);
+ });
+
+ it('A time-varying position causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ dynamicObject.position = new SampledPositionProperty();
+ dynamicObject.position.addSample(time, Cartesian3.ZERO);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying radii causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ dynamicObject.ellipsoid.radii = new SampledProperty(Cartesian3);
+ dynamicObject.ellipsoid.radii.addSample(time, new Cartesian3(1, 2, 3));
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying stackPartitions causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ dynamicObject.ellipsoid.stackPartitions = new SampledProperty(Number);
+ dynamicObject.ellipsoid.stackPartitions.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying slicePartitions causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ dynamicObject.ellipsoid.slicePartitions = new SampledProperty(Number);
+ dynamicObject.ellipsoid.slicePartitions.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying subdivisions causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ dynamicObject.ellipsoid.subdivisions = new SampledProperty(Number);
+ dynamicObject.ellipsoid.subdivisions.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ function validateGeometryInstance(options) {
+ var dynamicObject = new DynamicObject();
+ dynamicObject.position = new ConstantPositionProperty(options.position);
+ dynamicObject.orientation = new ConstantProperty(options.orientation);
+
+ var ellipsoid = new DynamicEllipsoid();
+ ellipsoid.show = new ConstantProperty(options.show);
+ ellipsoid.fill = new ConstantProperty(options.fill);
+ ellipsoid.material = options.material;
+ ellipsoid.outline = new ConstantProperty(options.outline);
+ ellipsoid.outlineColor = new ConstantProperty(options.outlineColor);
+ ellipsoid.numberOfVerticalLines = new ConstantProperty(options.numberOfVerticalLines);
+ ellipsoid.radii = new ConstantProperty(options.radii);
+ ellipsoid.stackPartitions = new ConstantProperty(options.stackPartitions);
+ ellipsoid.slicePartitions = new ConstantProperty(options.slicePartitions);
+ ellipsoid.subdivisions = new ConstantProperty(options.subdivisions);
+ dynamicObject.ellipsoid = ellipsoid;
+
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+
+ var instance;
+ var geometry;
+ var attributes;
+ if (options.fill) {
+ instance = updater.createFillGeometryInstance(time);
+ geometry = instance.geometry;
+ expect(geometry._center).toEqual(options.center);
+ expect(geometry._radii).toEqual(options.radii);
+ expect(geometry._stackPartitions).toEqual(options.stackPartitions);
+ expect(geometry._slicePartitions).toEqual(options.slicePartitions);
+
+ attributes = instance.attributes;
+ if (options.material instanceof ColorMaterialProperty) {
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(options.material.color.getValue(time)));
+ } else {
+ expect(attributes.color).toBeUndefined();
+ }
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(options.fill));
+ }
+
+ if (options.outline) {
+ instance = updater.createOutlineGeometryInstance(time);
+ geometry = instance.geometry;
+ expect(geometry._center).toEqual(options.center);
+ expect(geometry._radii).toEqual(options.radii);
+ expect(geometry._stackPartitions).toEqual(options.stackPartitions);
+ expect(geometry._slicePartitions).toEqual(options.slicePartitions);
+ expect(geometry._subdivisions).toEqual(options.subdivisions);
+
+ attributes = instance.attributes;
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(options.outlineColor));
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(options.fill));
+ }
+ }
+
+ it('Creates expected per-color geometry', function() {
+ validateGeometryInstance({
+ position : new Cartesian3(4, 5, 6),
+ orientation : Quaternion.IDENTITY,
+ radii : new Cartesian3(1, 2, 3),
+ show : true,
+ material : ColorMaterialProperty.fromColor(Color.RED),
+ fill : true,
+ outline : true,
+ outlineColor : Color.BLUE,
+ stackPartitions : 32,
+ slicePartitions : 64,
+ subdivisions : 15
+ });
+ });
+
+ it('Creates expected per-material geometry', function() {
+ validateGeometryInstance({
+ position : new Cartesian3(4, 5, 6),
+ orientation : Quaternion.IDENTITY,
+ radii : new Cartesian3(1, 2, 3),
+ show : true,
+ material : new GridMaterialProperty(),
+ fill : true,
+ outline : true,
+ outlineColor : Color.BLUE,
+ stackPartitions : 32,
+ slicePartitions : 64,
+ subdivisions : 15
+ });
+ });
+
+ it('Attributes have expected values at creation time', function() {
+ var time1 = new JulianDate(0, 0);
+ var time2 = new JulianDate(10, 0);
+ var time3 = new JulianDate(20, 0);
+
+ var fill = new TimeIntervalCollectionProperty();
+ fill.intervals.addInterval(new TimeInterval(time1, time2, true, true, false));
+ fill.intervals.addInterval(new TimeInterval(time2, time3, false, true, true));
+
+ var colorMaterial = new ColorMaterialProperty();
+ colorMaterial.color = new SampledProperty(Color);
+ colorMaterial.color.addSample(time, Color.YELLOW);
+ colorMaterial.color.addSample(time2, Color.BLUE);
+ colorMaterial.color.addSample(time3, Color.RED);
+
+ var outline = new TimeIntervalCollectionProperty();
+ outline.intervals.addInterval(new TimeInterval(time1, time2, true, true, false));
+ outline.intervals.addInterval(new TimeInterval(time2, time3, false, true, true));
+
+ var outlineColor = new SampledProperty(Color);
+ outlineColor.addSample(time, Color.BLUE);
+ outlineColor.addSample(time2, Color.RED);
+ outlineColor.addSample(time3, Color.YELLOW);
+
+ var dynamicObject = createBasicEllipsoid();
+ dynamicObject.ellipsoid.fill = fill;
+ dynamicObject.ellipsoid.material = colorMaterial;
+ dynamicObject.ellipsoid.outline = outline;
+ dynamicObject.ellipsoid.outlineColor = outlineColor;
+
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+
+ var instance = updater.createFillGeometryInstance(time2);
+ var attributes = instance.attributes;
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(colorMaterial.color.getValue(time2)));
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(fill.getValue(time2)));
+
+ instance = updater.createOutlineGeometryInstance(time2);
+ attributes = instance.attributes;
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(outlineColor.getValue(time2)));
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(outline.getValue(time2)));
+ });
+
+ it('dynamic updater sets properties', function() {
+ //This test is mostly a smoke screen for now.
+ var time1 = new JulianDate(0, 0);
+ var time2 = new JulianDate(1, 0);
+ var time3 = new JulianDate(2, 0);
+
+ function makeProperty(value1, value2) {
+ var property = new TimeIntervalCollectionProperty();
+ property.intervals.addInterval(new TimeInterval(time1, time2, true, false, value1));
+ property.intervals.addInterval(new TimeInterval(time2, time3, true, false, value2));
+ return property;
+ }
+
+ var ellipsoid = new DynamicEllipsoid();
+ ellipsoid.radii = makeProperty(new Cartesian3(1, 2, 3), new Cartesian3(4, 5, 6));
+ ellipsoid.outline = makeProperty(true, false);
+ ellipsoid.fill = makeProperty(false, true);
+
+ var dynamicObject = new DynamicObject();
+ dynamicObject.availability = new TimeIntervalCollection();
+ dynamicObject.availability.addInterval(new TimeInterval(time1, time3, true, false));
+ dynamicObject.position = makeProperty(Cartesian3.UNIT_Z, Cartesian3.UNIT_Y);
+ dynamicObject.orientation = makeProperty(Quaternion.IDENTITY, new Quaternion(0, 1, 0, 0));
+ dynamicObject.ellipsoid = ellipsoid;
+
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ var primitives = new CompositePrimitive();
+ var dynamicUpdater = updater.createDynamicUpdater(primitives);
+ expect(dynamicUpdater.isDestroyed()).toBe(false);
+ expect(primitives.length).toBe(0);
+ dynamicUpdater.update(time1);
+ expect(primitives.length).toBe(2); //Ellipsoid always has both fill and outline primitives.
+ dynamicUpdater.destroy();
+ expect(primitives.length).toBe(0);
+ updater.destroy();
+ });
+
+ it('geometryChanged event is raised when expected', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+
+ var listener = jasmine.createSpy('listener');
+ updater.geometryChanged.addEventListener(listener);
+
+ dynamicObject.position = new ConstantPositionProperty(Cartesian3.UNIT_Z);
+ expect(listener.callCount).toEqual(1);
+
+ dynamicObject.ellipsoid.radii = new ConstantProperty(new Cartesian3(1, 2, 3));
+ expect(listener.callCount).toEqual(2);
+
+ dynamicObject.availability = new TimeIntervalCollection();
+ expect(listener.callCount).toEqual(3);
+
+ dynamicObject.ellipsoid.radii = undefined;
+ expect(listener.callCount).toEqual(4);
+
+ //Modifying an unrelated property should not have any effect.
+ dynamicObject.viewFrom = new ConstantProperty(Cartesian3.UNIT_X);
+ expect(listener.callCount).toEqual(4);
+
+ dynamicObject.ellipsoid.radii = new SampledProperty(Cartesian3);
+ expect(listener.callCount).toEqual(5);
+ });
+
+ it('createFillGeometryInstance throws if object is not filled', function() {
+ var dynamicObject = new DynamicObject();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ expect(function() {
+ return updater.createFillGeometryInstance(time);
+ }).toThrowDeveloperError();
+ });
+
+ it('createFillGeometryInstance throws if no time provided', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ expect(function() {
+ return updater.createFillGeometryInstance(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('createOutlineGeometryInstance throws if object is not outlined', function() {
+ var dynamicObject = new DynamicObject();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ expect(function() {
+ return updater.createOutlineGeometryInstance(time);
+ }).toThrowDeveloperError();
+ });
+
+ it('createOutlineGeometryInstance throws if no time provided', function() {
+ var dynamicObject = createBasicEllipsoid();
+ dynamicObject.ellipsoid.outline = new ConstantProperty(true);
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ expect(function() {
+ return updater.createOutlineGeometryInstance(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('createDynamicUpdater throws if not dynamic', function() {
+ var dynamicObject = createBasicEllipsoid();
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ expect(function() {
+ return updater.createDynamicUpdater(new CompositePrimitive());
+ }).toThrowDeveloperError();
+ });
+
+ it('createDynamicUpdater throws if primitives undefined', function() {
+ var dynamicObject = createBasicEllipsoid();
+ dynamicObject.ellipsoid.radii = new SampledProperty(Number);
+ dynamicObject.ellipsoid.radii.addSample(time, 4);
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ expect(updater.isDynamic).toBe(true);
+ expect(function() {
+ return updater.createDynamicUpdater(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('dynamicUpdater.update throws if no time specified', function() {
+ var dynamicObject = createBasicEllipsoid();
+ dynamicObject.ellipsoid.radii = new SampledProperty(Number);
+ dynamicObject.ellipsoid.radii.addSample(time, 4);
+ var updater = new EllipsoidGeometryUpdater(dynamicObject, scene);
+ var dynamicUpdater = updater.createDynamicUpdater(new CompositePrimitive());
+ expect(function() {
+ dynamicUpdater.update(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('Constructor throws if no DynamicObject supplied', function() {
+ expect(function() {
+ return new EllipsoidGeometryUpdater(undefined);
+ }).toThrowDeveloperError();
+ });
+});
\ No newline at end of file
diff --git a/Specs/DynamicScene/GeometryVisualizerSpec.js b/Specs/DynamicScene/GeometryVisualizerSpec.js
new file mode 100644
index 000000000000..2e60d3e70d99
--- /dev/null
+++ b/Specs/DynamicScene/GeometryVisualizerSpec.js
@@ -0,0 +1,393 @@
+/*global defineSuite*/
+defineSuite(['DynamicScene/GeometryVisualizer',
+ 'DynamicScene/DynamicEllipse',
+ 'DynamicScene/DynamicObjectCollection',
+ 'DynamicScene/EllipseGeometryUpdater',
+ 'DynamicScene/ColorMaterialProperty',
+ 'DynamicScene/ConstantProperty',
+ 'DynamicScene/ConstantPositionProperty',
+ 'DynamicScene/DynamicObject',
+ 'DynamicScene/GridMaterialProperty',
+ 'DynamicScene/SampledProperty',
+ 'Core/Cartesian3',
+ 'Core/Color',
+ 'Core/ColorGeometryInstanceAttribute',
+ 'Core/ShowGeometryInstanceAttribute',
+ 'Core/JulianDate',
+ 'Scene/PrimitiveState',
+ 'Specs/createScene',
+ 'Specs/destroyScene'
+ ], function(
+ GeometryVisualizer,
+ DynamicEllipse,
+ DynamicObjectCollection,
+ EllipseGeometryUpdater,
+ ColorMaterialProperty,
+ ConstantProperty,
+ ConstantPositionProperty,
+ DynamicObject,
+ GridMaterialProperty,
+ SampledProperty,
+ Cartesian3,
+ Color,
+ ColorGeometryInstanceAttribute,
+ ShowGeometryInstanceAttribute,
+ JulianDate,
+ PrimitiveState,
+ createScene,
+ destroyScene) {
+ "use strict";
+ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
+
+ var time = new JulianDate();
+
+ var scene;
+ beforeAll(function() {
+ scene = createScene();
+ });
+
+ afterAll(function() {
+ destroyScene(scene);
+ });
+
+ it('Constructor sets expected values', function() {
+ var objects = new DynamicObjectCollection();
+ var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, objects);
+ expect(visualizer.getScene()).toBe(scene);
+ expect(visualizer.getDynamicObjectCollection()).toBe(objects);
+ visualizer.update(time);
+ expect(scene.primitives.length).toBe(0);
+ expect(visualizer.isDestroyed()).toBe(false);
+ visualizer.destroy();
+ expect(visualizer.isDestroyed()).toBe(true);
+
+ visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene);
+ expect(visualizer.getDynamicObjectCollection()).toBeUndefined();
+ visualizer.update(time);
+ expect(scene.primitives.length).toBe(0);
+ visualizer.destroy();
+ });
+
+ it('Creates and removes static color open geometry', function() {
+ var objects = new DynamicObjectCollection();
+ var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, objects);
+
+ var ellipse = new DynamicEllipse();
+ ellipse.semiMajorAxis = new ConstantProperty(2);
+ ellipse.semiMinorAxis = new ConstantProperty(1);
+ ellipse.material = new ColorMaterialProperty();
+
+ var dynamicObject = new DynamicObject();
+ dynamicObject.position = new ConstantPositionProperty(new Cartesian3(1234, 5678, 9101112));
+ dynamicObject.ellipse = ellipse;
+ objects.add(dynamicObject);
+
+ waitsFor(function() {
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+ return scene.primitives.get(0)._state === PrimitiveState.COMPLETE;
+ });
+
+ runs(function() {
+ var primitive = scene.primitives.get(0);
+ var attributes = primitive.getGeometryInstanceAttributes(dynamicObject);
+ expect(attributes).toBeDefined();
+ expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(true));
+ expect(attributes.color).toEqual(ColorGeometryInstanceAttribute.toValue(Color.WHITE));
+ expect(primitive.appearance).toBeInstanceOf(EllipseGeometryUpdater.perInstanceColorAppearanceType);
+ expect(primitive.appearance.closed).toBe(false);
+
+ objects.remove(dynamicObject);
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+
+ expect(scene.primitives.length).toBe(0);
+
+ visualizer.destroy();
+ });
+ });
+
+ it('Creates and removes static material open geometry', function() {
+ var objects = new DynamicObjectCollection();
+ var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, objects);
+
+ var ellipse = new DynamicEllipse();
+ ellipse.semiMajorAxis = new ConstantProperty(2);
+ ellipse.semiMinorAxis = new ConstantProperty(1);
+ ellipse.material = new GridMaterialProperty();
+
+ var dynamicObject = new DynamicObject();
+ dynamicObject.position = new ConstantPositionProperty(new Cartesian3(1234, 5678, 9101112));
+ dynamicObject.ellipse = ellipse;
+ objects.add(dynamicObject);
+
+ waitsFor(function() {
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+ return scene.primitives.get(0)._state === PrimitiveState.COMPLETE;
+ });
+
+ runs(function() {
+ var primitive = scene.primitives.get(0);
+ var attributes = primitive.getGeometryInstanceAttributes(dynamicObject);
+ expect(attributes).toBeDefined();
+ expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(true));
+ expect(attributes.color).toBeUndefined();
+ expect(primitive.appearance).toBeInstanceOf(EllipseGeometryUpdater.materialAppearanceType);
+ expect(primitive.appearance.closed).toBe(false);
+
+ objects.remove(dynamicObject);
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+
+ expect(scene.primitives.length).toBe(0);
+
+ visualizer.destroy();
+ });
+ });
+
+ it('Creates and removes static color closed geometry', function() {
+ var objects = new DynamicObjectCollection();
+ var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, objects);
+
+ var ellipse = new DynamicEllipse();
+ ellipse.semiMajorAxis = new ConstantProperty(2);
+ ellipse.semiMinorAxis = new ConstantProperty(1);
+ ellipse.material = new ColorMaterialProperty();
+ ellipse.extrudedHeight = new ConstantProperty(1000);
+
+ var dynamicObject = new DynamicObject();
+ dynamicObject.position = new ConstantPositionProperty(new Cartesian3(1234, 5678, 9101112));
+ dynamicObject.ellipse = ellipse;
+ objects.add(dynamicObject);
+
+ waitsFor(function() {
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+ return scene.primitives.get(0)._state === PrimitiveState.COMPLETE;
+ });
+
+ runs(function() {
+ var primitive = scene.primitives.get(0);
+ var attributes = primitive.getGeometryInstanceAttributes(dynamicObject);
+ expect(attributes).toBeDefined();
+ expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(true));
+ expect(attributes.color).toEqual(ColorGeometryInstanceAttribute.toValue(Color.WHITE));
+ expect(primitive.appearance).toBeInstanceOf(EllipseGeometryUpdater.perInstanceColorAppearanceType);
+ expect(primitive.appearance.closed).toBe(true);
+
+ objects.remove(dynamicObject);
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+
+ expect(scene.primitives.length).toBe(0);
+
+ visualizer.destroy();
+ });
+ });
+
+ it('Creates and removes static material closed geometry', function() {
+ var objects = new DynamicObjectCollection();
+ var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, objects);
+
+ var ellipse = new DynamicEllipse();
+ ellipse.semiMajorAxis = new ConstantProperty(2);
+ ellipse.semiMinorAxis = new ConstantProperty(1);
+ ellipse.material = new GridMaterialProperty();
+ ellipse.extrudedHeight = new ConstantProperty(1000);
+
+ var dynamicObject = new DynamicObject();
+ dynamicObject.position = new ConstantPositionProperty(new Cartesian3(1234, 5678, 9101112));
+ dynamicObject.ellipse = ellipse;
+ objects.add(dynamicObject);
+
+ waitsFor(function() {
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+ return scene.primitives.get(0)._state === PrimitiveState.COMPLETE;
+ });
+
+ runs(function() {
+ var primitive = scene.primitives.get(0);
+ var attributes = primitive.getGeometryInstanceAttributes(dynamicObject);
+ expect(attributes).toBeDefined();
+ expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(true));
+ expect(attributes.color).toBeUndefined();
+ expect(primitive.appearance).toBeInstanceOf(EllipseGeometryUpdater.materialAppearanceType);
+ expect(primitive.appearance.closed).toBe(true);
+
+ objects.remove(dynamicObject);
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+
+ expect(scene.primitives.length).toBe(0);
+
+ visualizer.destroy();
+ });
+ });
+
+ it('Creates and removes static outline geometry', function() {
+ var objects = new DynamicObjectCollection();
+ var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, objects);
+
+ var ellipse = new DynamicEllipse();
+ ellipse.semiMajorAxis = new ConstantProperty(2);
+ ellipse.semiMinorAxis = new ConstantProperty(1);
+ ellipse.outline = new ConstantProperty(true);
+ ellipse.outlineColor = new ConstantProperty(Color.BLUE);
+ ellipse.fill = new ConstantProperty(false);
+
+ var dynamicObject = new DynamicObject();
+ dynamicObject.position = new ConstantPositionProperty(new Cartesian3(1234, 5678, 9101112));
+ dynamicObject.ellipse = ellipse;
+ objects.add(dynamicObject);
+
+ waitsFor(function() {
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+ return scene.primitives.get(0)._state === PrimitiveState.COMPLETE;
+ });
+
+ runs(function() {
+ var primitive = scene.primitives.get(0);
+ var attributes = primitive.getGeometryInstanceAttributes(dynamicObject);
+ expect(attributes).toBeDefined();
+ expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(true));
+ expect(attributes.color).toEqual(ColorGeometryInstanceAttribute.toValue(Color.BLUE));
+ expect(primitive.appearance).toBeInstanceOf(EllipseGeometryUpdater.perInstanceColorAppearanceType);
+
+ objects.remove(dynamicObject);
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+
+ expect(scene.primitives.length).toBe(0);
+
+ visualizer.destroy();
+ });
+ });
+
+ it('Correctly handles geometry changing batches', function() {
+ var objects = new DynamicObjectCollection();
+ var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, objects);
+
+ var ellipse = new DynamicEllipse();
+ ellipse.semiMajorAxis = new ConstantProperty(2);
+ ellipse.semiMinorAxis = new ConstantProperty(1);
+ ellipse.material = new ColorMaterialProperty();
+
+ var dynamicObject = new DynamicObject();
+ dynamicObject.position = new ConstantPositionProperty(new Cartesian3(1234, 5678, 9101112));
+ dynamicObject.ellipse = ellipse;
+ objects.add(dynamicObject);
+
+ waitsFor(function() {
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+ return scene.primitives.get(0)._state === PrimitiveState.COMPLETE;
+ });
+
+ var primitive;
+ var attributes;
+
+ runs(function() {
+ primitive = scene.primitives.get(0);
+ attributes = primitive.getGeometryInstanceAttributes(dynamicObject);
+ expect(attributes).toBeDefined();
+ expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(true));
+ expect(attributes.color).toEqual(ColorGeometryInstanceAttribute.toValue(Color.WHITE));
+ expect(primitive.appearance).toBeInstanceOf(EllipseGeometryUpdater.perInstanceColorAppearanceType);
+
+ ellipse.material = new GridMaterialProperty();
+ });
+
+ waitsFor(function() {
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+ return scene.primitives.get(0)._state === PrimitiveState.COMPLETE;
+ });
+
+ runs(function() {
+ primitive = scene.primitives.get(0);
+ attributes = primitive.getGeometryInstanceAttributes(dynamicObject);
+ expect(attributes).toBeDefined();
+ expect(attributes.show).toEqual(ShowGeometryInstanceAttribute.toValue(true));
+ expect(attributes.color).toBeUndefined();
+ expect(primitive.appearance).toBeInstanceOf(EllipseGeometryUpdater.materialAppearanceType);
+
+ objects.remove(dynamicObject);
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+
+ expect(scene.primitives.length).toBe(0);
+
+ visualizer.destroy();
+ });
+
+ });
+
+ it('Creates and removes dynamic geometry', function() {
+ var objects = new DynamicObjectCollection();
+ var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, objects);
+
+ var ellipse = new DynamicEllipse();
+ ellipse.semiMajorAxis = new SampledProperty(Number);
+ ellipse.semiMajorAxis.addSample(time, 2);
+ ellipse.semiMinorAxis = new ConstantProperty(1);
+ ellipse.material = new ColorMaterialProperty();
+
+ var dynamicObject = new DynamicObject();
+ dynamicObject.position = new ConstantPositionProperty(new Cartesian3(1234, 5678, 9101112));
+ dynamicObject.ellipse = ellipse;
+ objects.add(dynamicObject);
+
+ waitsFor(function() {
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+ return scene.primitives.get(0)._state === PrimitiveState.COMPLETE;
+ });
+
+ runs(function() {
+ objects.remove(dynamicObject);
+ scene.initializeFrame();
+ visualizer.update(time);
+ scene.render(time);
+ expect(scene.primitives.length).toBe(0);
+ visualizer.destroy();
+ });
+ });
+
+ it('Constructor throws without type', function() {
+ var objects = new DynamicObjectCollection();
+ expect(function() {
+ return new GeometryVisualizer(undefined, scene, objects);
+ }).toThrowDeveloperError();
+ });
+
+ it('Constructor throws without scene', function() {
+ var objects = new DynamicObjectCollection();
+ expect(function() {
+ return new GeometryVisualizer(EllipseGeometryUpdater, undefined, objects);
+ }).toThrowDeveloperError();
+ });
+
+ it('Update throws without time parameter', function() {
+ var visualizer = new GeometryVisualizer(EllipseGeometryUpdater, scene, new DynamicObjectCollection());
+ expect(function() {
+ visualizer.update(undefined);
+ }).toThrowDeveloperError();
+ });
+}, 'WebGL');
\ No newline at end of file
diff --git a/Specs/DynamicScene/GridMaterialPropertySpec.js b/Specs/DynamicScene/GridMaterialPropertySpec.js
index 6b6da656468e..4411e42500f8 100644
--- a/Specs/DynamicScene/GridMaterialPropertySpec.js
+++ b/Specs/DynamicScene/GridMaterialPropertySpec.js
@@ -1,26 +1,25 @@
/*global defineSuite*/
-defineSuite([
- 'DynamicScene/GridMaterialProperty',
+defineSuite(['DynamicScene/GridMaterialProperty',
'DynamicScene/ConstantProperty',
+ 'DynamicScene/SampledProperty',
'DynamicScene/TimeIntervalCollectionProperty',
'Core/Cartesian2',
'Core/Color',
'Core/JulianDate',
- 'Core/TimeInterval',
- 'Specs/UndefinedProperty'
+ 'Core/TimeInterval'
], function(
GridMaterialProperty,
ConstantProperty,
+ SampledProperty,
TimeIntervalCollectionProperty,
Cartesian2,
Color,
JulianDate,
- TimeInterval,
- UndefinedProperty) {
+ TimeInterval) {
"use strict";
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
- it('works with basic types', function() {
+ it('constructor provides the expected defaults', function() {
var property = new GridMaterialProperty();
expect(property.color).toBeDefined();
expect(property.cellAlpha).toBeDefined();
@@ -52,10 +51,10 @@ defineSuite([
it('works with undefined values', function() {
var property = new GridMaterialProperty();
- property.color = new UndefinedProperty();
- property.cellAlpha = new UndefinedProperty();
- property.lineCount = new UndefinedProperty();
- property.lineThickness = new UndefinedProperty();
+ property.color.setValue(undefined);
+ property.cellAlpha.setValue(undefined);
+ property.lineCount.setValue(undefined);
+ property.lineThickness.setValue(undefined);
var result = property.getValue();
expect(result.hasOwnProperty('color')).toEqual(true);
@@ -138,4 +137,94 @@ defineSuite([
right.lineThickness = left.lineThickness;
expect(left.equals(right)).toEqual(true);
});
+
+ it('raises definitionChanged when a property is assigned or modified', function() {
+ var property = new GridMaterialProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
+ var oldValue = property.color;
+ property.color = new ConstantProperty(Color.WHITE);
+ expect(listener).toHaveBeenCalledWith(property, 'color', property.color, oldValue);
+ listener.reset();
+
+ property.color.setValue(Color.BLACK);
+ expect(listener).toHaveBeenCalledWith(property, 'color', property.color, property.color);
+ listener.reset();
+
+ property.color = property.color;
+ expect(listener.callCount).toEqual(0);
+ listener.reset();
+
+ oldValue = property.cellAlpha;
+ property.cellAlpha = new ConstantProperty(0.0);
+ expect(listener).toHaveBeenCalledWith(property, 'cellAlpha', property.cellAlpha, oldValue);
+ listener.reset();
+
+ property.cellAlpha.setValue(1.0);
+ expect(listener).toHaveBeenCalledWith(property, 'cellAlpha', property.cellAlpha, property.cellAlpha);
+ listener.reset();
+
+ property.cellAlpha = property.cellAlpha;
+ expect(listener.callCount).toEqual(0);
+ listener.reset();
+
+ oldValue = property.lineCount;
+ property.lineCount = new ConstantProperty(5.0);
+ expect(listener).toHaveBeenCalledWith(property, 'lineCount', property.lineCount, oldValue);
+ listener.reset();
+
+ property.lineCount.setValue(10.0);
+ expect(listener).toHaveBeenCalledWith(property, 'lineCount', property.lineCount, property.lineCount);
+ listener.reset();
+
+ property.lineCount = property.lineCount;
+ expect(listener.callCount).toEqual(0);
+ listener.reset();
+
+ oldValue = property.lineThickness;
+ property.lineThickness = new ConstantProperty(5.0);
+ expect(listener).toHaveBeenCalledWith(property, 'lineThickness', property.lineThickness, oldValue);
+ listener.reset();
+
+ property.lineThickness.setValue(10.0);
+ expect(listener).toHaveBeenCalledWith(property, 'lineThickness', property.lineThickness, property.lineThickness);
+ listener.reset();
+
+ property.lineThickness = property.lineThickness;
+ expect(listener.callCount).toEqual(0);
+ });
+
+ it('isConstant is only true when all properties are constant or undefined', function() {
+ var property = new GridMaterialProperty();
+ expect(property.isConstant).toBe(true);
+
+ property.color = undefined;
+ property.cellAlpha = undefined;
+ property.lineCount = undefined;
+ property.lineThickness = undefined;
+ expect(property.isConstant).toBe(true);
+
+ property.color = new SampledProperty(Color);
+ property.color.addSample(new JulianDate(), Color.WHITE);
+ expect(property.isConstant).toBe(false);
+
+ property.color = undefined;
+ expect(property.isConstant).toBe(true);
+ property.cellAlpha = new SampledProperty(Number);
+ property.cellAlpha.addSample(new JulianDate(), 0);
+ expect(property.isConstant).toBe(false);
+
+ property.cellAlpha = undefined;
+ expect(property.isConstant).toBe(true);
+ property.lineCount = new SampledProperty(Number);
+ property.lineCount.addSample(new JulianDate(), 1);
+ expect(property.isConstant).toBe(false);
+
+ property.lineCount = undefined;
+ expect(property.isConstant).toBe(true);
+ property.lineThickness= new SampledProperty(Number);
+ property.lineThickness.addSample(new JulianDate(), 1);
+ expect(property.isConstant).toBe(false);
+ });
});
\ No newline at end of file
diff --git a/Specs/DynamicScene/ImageMaterialPropertySpec.js b/Specs/DynamicScene/ImageMaterialPropertySpec.js
index 833583dd366f..c504b4be342d 100644
--- a/Specs/DynamicScene/ImageMaterialPropertySpec.js
+++ b/Specs/DynamicScene/ImageMaterialPropertySpec.js
@@ -5,24 +5,19 @@ defineSuite([
'DynamicScene/TimeIntervalCollectionProperty',
'Core/Cartesian2',
'Core/JulianDate',
- 'Core/TimeInterval',
- 'Specs/UndefinedProperty'
+ 'Core/TimeInterval'
], function(
ImageMaterialProperty,
ConstantProperty,
TimeIntervalCollectionProperty,
Cartesian2,
JulianDate,
- TimeInterval,
- UndefinedProperty) {
+ TimeInterval) {
"use strict";
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
- it('works with basic types', function() {
+ it('constructor provides the expected defaults', function() {
var property = new ImageMaterialProperty();
- expect(property.image).toBeUndefined();
- expect(property.repeat).toBeDefined();
-
expect(property.getType()).toEqual('Image');
var result = property.getValue();
@@ -42,8 +37,8 @@ defineSuite([
it('works with undefined values', function() {
var property = new ImageMaterialProperty();
- property.image = new UndefinedProperty();
- property.repeat = new UndefinedProperty();
+ property.image = new ConstantProperty();
+ property.repeat = new ConstantProperty();
var result = property.getValue();
expect(result.hasOwnProperty('image')).toEqual(true);
@@ -100,4 +95,56 @@ defineSuite([
right.repeat = left.repeat;
expect(left.equals(right)).toEqual(true);
});
+
+ it('raises definitionChanged when a property is assigned or modified', function() {
+ var property = new ImageMaterialProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
+ var oldValue = property.image;
+ property.image = new ConstantProperty('http://test.invalid/image.png');
+ expect(listener).toHaveBeenCalledWith(property, 'image', property.image, oldValue);
+ listener.reset();
+
+ property.image.setValue('http://test.invalid/image2.png');
+ expect(listener).toHaveBeenCalledWith(property, 'image', property.image, property.image);
+ listener.reset();
+
+ property.image = property.image;
+ expect(listener.callCount).toEqual(0);
+ listener.reset();
+
+ oldValue = property.repeat;
+ property.repeat = new ConstantProperty(new Cartesian2(1.5, 1.5));
+ expect(listener).toHaveBeenCalledWith(property, 'repeat', property.repeat, oldValue);
+ listener.reset();
+
+ property.repeat.setValue(new Cartesian2(1.0, 1.0));
+ expect(listener).toHaveBeenCalledWith(property, 'repeat', property.repeat, property.repeat);
+ listener.reset();
+
+ property.repeat = property.repeat;
+ expect(listener.callCount).toEqual(0);
+ });
+
+ it('isConstant is only true when all properties are constant or undefined', function() {
+ var property = new ImageMaterialProperty();
+ expect(property.isConstant).toBe(true);
+
+ property.image = undefined;
+ property.repeat = undefined;
+ expect(property.isConstant).toBe(true);
+
+ var start = new JulianDate(1, 0);
+ var stop = new JulianDate(2, 0);
+ property.image = new TimeIntervalCollectionProperty();
+ property.image.intervals.addInterval(new TimeInterval(start, stop, true, true, 'http://test.invalid/image.png'));
+ expect(property.isConstant).toBe(false);
+
+ property.image = undefined;
+ expect(property.isConstant).toBe(true);
+ property.repeat = new TimeIntervalCollectionProperty();
+ property.repeat.intervals.addInterval(new TimeInterval(start, stop, true, true, new Cartesian2(2, 3)));
+ expect(property.isConstant).toBe(false);
+ });
});
\ No newline at end of file
diff --git a/Specs/DynamicScene/PolygonGeometryUpdaterSpec.js b/Specs/DynamicScene/PolygonGeometryUpdaterSpec.js
new file mode 100644
index 000000000000..21912eaa2c08
--- /dev/null
+++ b/Specs/DynamicScene/PolygonGeometryUpdaterSpec.js
@@ -0,0 +1,437 @@
+/*global defineSuite*/
+defineSuite(['DynamicScene/PolygonGeometryUpdater',
+ 'DynamicScene/DynamicObject',
+ 'DynamicScene/DynamicPolygon',
+ 'Core/Cartesian3',
+ 'Core/Cartographic',
+ 'Core/Color',
+ 'Core/Ellipsoid',
+ 'Core/JulianDate',
+ 'Core/TimeInterval',
+ 'Core/TimeIntervalCollection',
+ 'Core/ColorGeometryInstanceAttribute',
+ 'Core/ShowGeometryInstanceAttribute',
+ 'DynamicScene/ColorMaterialProperty',
+ 'DynamicScene/ConstantProperty',
+ 'DynamicScene/ConstantPositionProperty',
+ 'DynamicScene/GridMaterialProperty',
+ 'DynamicScene/PropertyArray',
+ 'DynamicScene/SampledProperty',
+ 'DynamicScene/SampledPositionProperty',
+ 'DynamicScene/TimeIntervalCollectionProperty',
+ 'Scene/CompositePrimitive'
+ ], function(
+ PolygonGeometryUpdater,
+ DynamicObject,
+ DynamicPolygon,
+ Cartesian3,
+ Cartographic,
+ Color,
+ Ellipsoid,
+ JulianDate,
+ TimeInterval,
+ TimeIntervalCollection,
+ ColorGeometryInstanceAttribute,
+ ShowGeometryInstanceAttribute,
+ ColorMaterialProperty,
+ ConstantProperty,
+ ConstantPositionProperty,
+ GridMaterialProperty,
+ PropertyArray,
+ SampledProperty,
+ SampledPositionProperty,
+ TimeIntervalCollectionProperty,
+ CompositePrimitive) {
+ "use strict";
+ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
+
+ var time = new JulianDate();
+
+ function createBasicPolygon() {
+ var polygon = new DynamicPolygon();
+ var dynamicObject = new DynamicObject();
+ dynamicObject.vertexPositions = new ConstantProperty(Ellipsoid.WGS84.cartographicArrayToCartesianArray([new Cartographic(0, 0, 0), new Cartographic(1, 0, 0), new Cartographic(1, 1, 0), new Cartographic(0, 1, 0)]));
+ dynamicObject.polygon = polygon;
+ return dynamicObject;
+ }
+
+ it('Constructor sets expected defaults', function() {
+ var dynamicObject = new DynamicObject();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+
+ expect(updater.isDestroyed()).toBe(false);
+ expect(updater.dynamicObject).toBe(dynamicObject);
+ expect(updater.isClosed).toBe(false);
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.fillMaterialProperty).toBe(undefined);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.hasConstantFill).toBe(true);
+ expect(updater.hasConstantOutline).toBe(true);
+ expect(updater.outlineColorProperty).toBe(undefined);
+ expect(updater.isDynamic).toBe(false);
+ expect(updater.isOutlineVisible(time)).toBe(false);
+ expect(updater.isFilled(time)).toBe(false);
+ updater.destroy();
+ expect(updater.isDestroyed()).toBe(true);
+ });
+
+ it('No geometry available when polygon is undefined ', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ dynamicObject.polygon = undefined;
+
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('No geometry available when not filled or outline.', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ dynamicObject.polygon.fill = new ConstantProperty(false);
+ dynamicObject.polygon.outline = new ConstantProperty(false);
+
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('Values correct when using default graphics', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+
+ expect(updater.isClosed).toBe(false);
+ expect(updater.fillEnabled).toBe(true);
+ expect(updater.fillMaterialProperty).toEqual(ColorMaterialProperty.fromColor(Color.WHITE));
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.hasConstantFill).toBe(true);
+ expect(updater.hasConstantOutline).toBe(true);
+ expect(updater.outlineColorProperty).toBe(undefined);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('Polygon material is correctly exposed.', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ dynamicObject.polygon.material = new GridMaterialProperty(Color.BLUE);
+ expect(updater.fillMaterialProperty).toBe(dynamicObject.polygon.material);
+ });
+
+ it('Settings extrudedHeight causes geometry to be closed.', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ dynamicObject.polygon.extrudedHeight = new ConstantProperty(1000);
+ expect(updater.isClosed).toBe(true);
+ });
+
+ it('A time-varying vertexPositions causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ var point1 = new SampledPositionProperty();
+ point1.addSample(time, new Cartesian3());
+ var point2 = new SampledPositionProperty();
+ point2.addSample(time, new Cartesian3());
+ var point3 = new SampledPositionProperty();
+ point3.addSample(time, new Cartesian3());
+
+ dynamicObject.vertexPositions = new PropertyArray();
+ dynamicObject.vertexPositions.setValue([point1, point2, point3]);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying height causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ dynamicObject.polygon.height = new SampledProperty(Number);
+ dynamicObject.polygon.height.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying extrudedHeight causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ dynamicObject.polygon.extrudedHeight = new SampledProperty(Number);
+ dynamicObject.polygon.extrudedHeight.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying granularity causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ dynamicObject.polygon.granularity = new SampledProperty(Number);
+ dynamicObject.polygon.granularity.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying stRotation causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ dynamicObject.polygon.stRotation = new SampledProperty(Number);
+ dynamicObject.polygon.stRotation.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying perPositionHeight causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ dynamicObject.polygon.perPositionHeight = new SampledProperty(Number);
+ dynamicObject.polygon.perPositionHeight.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ function validateGeometryInstance(options) {
+ var dynamicObject = createBasicPolygon();
+
+ var polygon = dynamicObject.polygon;
+ polygon.show = new ConstantProperty(options.show);
+ polygon.fill = new ConstantProperty(options.fill);
+ polygon.material = options.material;
+ polygon.outline = new ConstantProperty(options.outline);
+ polygon.outlineColor = new ConstantProperty(options.outlineColor);
+ polygon.perPositionHeight = new ConstantProperty(options.perPositionHeight);
+
+ polygon.stRotation = new ConstantProperty(options.stRotation);
+ polygon.height = new ConstantProperty(options.height);
+ polygon.extrudedHeight = new ConstantProperty(options.extrudedHeight);
+ polygon.granularity = new ConstantProperty(options.granularity);
+
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+
+ var instance;
+ var geometry;
+ var attributes;
+ if (options.fill) {
+ instance = updater.createFillGeometryInstance(time);
+ geometry = instance.geometry;
+ expect(geometry._stRotation).toEqual(options.stRotation);
+ expect(geometry._height).toEqual(options.height);
+ expect(geometry._granularity).toEqual(options.granularity);
+ expect(geometry._extrudedHeight).toEqual(options.extrudedHeight);
+
+ attributes = instance.attributes;
+ if (options.material instanceof ColorMaterialProperty) {
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(options.material.color.getValue(time)));
+ } else {
+ expect(attributes.color).toBeUndefined();
+ }
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(options.fill));
+ }
+
+ if (options.outline) {
+ instance = updater.createOutlineGeometryInstance(time);
+ geometry = instance.geometry;
+ expect(geometry._height).toEqual(options.height);
+ expect(geometry._granularity).toEqual(options.granularity);
+ expect(geometry._extrudedHeight).toEqual(options.extrudedHeight);
+ expect(geometry._perPositionHeight).toEqual(options.perPositionHeight);
+
+ attributes = instance.attributes;
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(options.outlineColor));
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(options.fill));
+ }
+ }
+
+ it('Creates expected per-color geometry', function() {
+ validateGeometryInstance({
+ show : true,
+ material : ColorMaterialProperty.fromColor(Color.RED),
+ height : 431,
+ extrudedHeight : 123,
+ granularity : 0.97,
+ stRotation : 12,
+ fill : true,
+ outline : true,
+ outlineColor : Color.BLUE,
+ perPositionHeight : true
+ });
+ });
+
+ it('Creates expected per-material geometry', function() {
+ validateGeometryInstance({
+ show : true,
+ material : new GridMaterialProperty(),
+ height : 431,
+ extrudedHeight : 123,
+ granularity : 0.97,
+ stRotation : 12,
+ fill : true,
+ outline : true,
+ outlineColor : Color.BLUE,
+ perPositionHeight : false
+ });
+ });
+
+ it('Attributes have expected values at creation time', function() {
+ var time1 = new JulianDate(0, 0);
+ var time2 = new JulianDate(10, 0);
+ var time3 = new JulianDate(20, 0);
+
+ var fill = new TimeIntervalCollectionProperty();
+ fill.intervals.addInterval(new TimeInterval(time1, time2, true, true, false));
+ fill.intervals.addInterval(new TimeInterval(time2, time3, false, true, true));
+
+ var colorMaterial = new ColorMaterialProperty();
+ colorMaterial.color = new SampledProperty(Color);
+ colorMaterial.color.addSample(time, Color.YELLOW);
+ colorMaterial.color.addSample(time2, Color.BLUE);
+ colorMaterial.color.addSample(time3, Color.RED);
+
+ var outline = new TimeIntervalCollectionProperty();
+ outline.intervals.addInterval(new TimeInterval(time1, time2, true, true, false));
+ outline.intervals.addInterval(new TimeInterval(time2, time3, false, true, true));
+
+ var outlineColor = new SampledProperty(Color);
+ outlineColor.addSample(time, Color.BLUE);
+ outlineColor.addSample(time2, Color.RED);
+ outlineColor.addSample(time3, Color.YELLOW);
+
+ var dynamicObject = createBasicPolygon();
+ dynamicObject.polygon.fill = fill;
+ dynamicObject.polygon.material = colorMaterial;
+ dynamicObject.polygon.outline = outline;
+ dynamicObject.polygon.outlineColor = outlineColor;
+
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+
+ var instance = updater.createFillGeometryInstance(time2);
+ var attributes = instance.attributes;
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(colorMaterial.color.getValue(time2)));
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(fill.getValue(time2)));
+
+ instance = updater.createOutlineGeometryInstance(time2);
+ attributes = instance.attributes;
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(outlineColor.getValue(time2)));
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(outline.getValue(time2)));
+ });
+
+ it('dynamic updater sets properties', function() {
+ //This test is mostly a smoke screen for now.
+ var time1 = new JulianDate(0, 0);
+ var time2 = new JulianDate(1, 0);
+ var time3 = new JulianDate(2, 0);
+
+ function makeProperty(value1, value2) {
+ var property = new TimeIntervalCollectionProperty();
+ property.intervals.addInterval(new TimeInterval(time1, time2, true, false, value1));
+ property.intervals.addInterval(new TimeInterval(time2, time3, true, false, value2));
+ return property;
+ }
+
+ var dynamicObject = createBasicPolygon();
+
+ var polygon = dynamicObject.polygon;
+ polygon.height = makeProperty(2, 12);
+ polygon.extrudedHeight = makeProperty(1, 11);
+ polygon.outline = makeProperty(true, false);
+ polygon.fill = makeProperty(false, true);
+
+ dynamicObject.availability = new TimeIntervalCollection();
+ dynamicObject.availability.addInterval(new TimeInterval(time1, time3, true, false));
+
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ var primitives = new CompositePrimitive();
+ var dynamicUpdater = updater.createDynamicUpdater(primitives);
+ expect(dynamicUpdater.isDestroyed()).toBe(false);
+ expect(primitives.length).toBe(0);
+ dynamicUpdater.update(time1);
+ expect(primitives.length).toBe(1);
+ dynamicUpdater.destroy();
+ expect(primitives.length).toBe(0);
+ updater.destroy();
+ });
+
+ it('geometryChanged event is raised when expected', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ var listener = jasmine.createSpy('listener');
+ updater.geometryChanged.addEventListener(listener);
+
+ dynamicObject.vertexPositions = new ConstantProperty([]);
+ expect(listener.callCount).toEqual(1);
+
+ dynamicObject.polygon.height = new ConstantProperty(82);
+ expect(listener.callCount).toEqual(2);
+
+ dynamicObject.availability = new TimeIntervalCollection();
+ expect(listener.callCount).toEqual(3);
+
+ dynamicObject.vertexPositions = undefined;
+ expect(listener.callCount).toEqual(4);
+
+ //Since there's no valid geometry, changing another property should not raise the event.
+ dynamicObject.polygon.height = undefined;
+
+ //Modifying an unrelated property should not have any effect.
+ dynamicObject.viewFrom = new ConstantProperty(Cartesian3.UNIT_X);
+ expect(listener.callCount).toEqual(4);
+ });
+
+ it('createFillGeometryInstance throws if object is not filled', function() {
+ var dynamicObject = new DynamicObject();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createFillGeometryInstance(time);
+ }).toThrowDeveloperError();
+ });
+
+ it('createFillGeometryInstance throws if no time provided', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createFillGeometryInstance(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('createOutlineGeometryInstance throws if object is not outlined', function() {
+ var dynamicObject = new DynamicObject();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createOutlineGeometryInstance(time);
+ }).toThrowDeveloperError();
+ });
+
+ it('createOutlineGeometryInstance throws if no time provided', function() {
+ var dynamicObject = createBasicPolygon();
+ dynamicObject.polygon.outline = new ConstantProperty(true);
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createOutlineGeometryInstance(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('createDynamicUpdater throws if not dynamic', function() {
+ var dynamicObject = createBasicPolygon();
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createDynamicUpdater(new CompositePrimitive());
+ }).toThrowDeveloperError();
+ });
+
+ it('createDynamicUpdater throws if primitives undefined', function() {
+ var dynamicObject = createBasicPolygon();
+ dynamicObject.polygon.height = new SampledProperty(Number);
+ dynamicObject.polygon.height.addSample(time, 4);
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ expect(updater.isDynamic).toBe(true);
+ expect(function() {
+ return updater.createDynamicUpdater(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('dynamicUpdater.update throws if no time specified', function() {
+ var dynamicObject = createBasicPolygon();
+ dynamicObject.polygon.height = new SampledProperty(Number);
+ dynamicObject.polygon.height.addSample(time, 4);
+ var updater = new PolygonGeometryUpdater(dynamicObject);
+ var dynamicUpdater = updater.createDynamicUpdater(new CompositePrimitive());
+ expect(function() {
+ dynamicUpdater.update(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('Constructor throws if no DynamicObject supplied', function() {
+ expect(function() {
+ return new PolygonGeometryUpdater(undefined);
+ }).toThrowDeveloperError();
+ });
+});
\ No newline at end of file
diff --git a/Specs/DynamicScene/PolylineGeometryUpdaterSpec.js b/Specs/DynamicScene/PolylineGeometryUpdaterSpec.js
new file mode 100644
index 000000000000..9827cc64fb22
--- /dev/null
+++ b/Specs/DynamicScene/PolylineGeometryUpdaterSpec.js
@@ -0,0 +1,331 @@
+/*global defineSuite*/
+defineSuite(['DynamicScene/PolylineGeometryUpdater',
+ 'DynamicScene/DynamicObject',
+ 'DynamicScene/DynamicPolyline',
+ 'Core/Cartesian3',
+ 'Core/Cartographic',
+ 'Core/Color',
+ 'Core/Ellipsoid',
+ 'Core/JulianDate',
+ 'Core/TimeInterval',
+ 'Core/TimeIntervalCollection',
+ 'Core/ColorGeometryInstanceAttribute',
+ 'Core/ShowGeometryInstanceAttribute',
+ 'DynamicScene/ColorMaterialProperty',
+ 'DynamicScene/ConstantProperty',
+ 'DynamicScene/ConstantPositionProperty',
+ 'DynamicScene/GridMaterialProperty',
+ 'DynamicScene/PropertyArray',
+ 'DynamicScene/SampledProperty',
+ 'DynamicScene/SampledPositionProperty',
+ 'DynamicScene/TimeIntervalCollectionProperty',
+ 'Scene/CompositePrimitive'
+ ], function(
+ PolylineGeometryUpdater,
+ DynamicObject,
+ DynamicPolyline,
+ Cartesian3,
+ Cartographic,
+ Color,
+ Ellipsoid,
+ JulianDate,
+ TimeInterval,
+ TimeIntervalCollection,
+ ColorGeometryInstanceAttribute,
+ ShowGeometryInstanceAttribute,
+ ColorMaterialProperty,
+ ConstantProperty,
+ ConstantPositionProperty,
+ GridMaterialProperty,
+ PropertyArray,
+ SampledProperty,
+ SampledPositionProperty,
+ TimeIntervalCollectionProperty,
+ CompositePrimitive) {
+ "use strict";
+ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
+
+ var time = new JulianDate();
+
+ function createBasicPolyline() {
+ var polyline = new DynamicPolyline();
+ var dynamicObject = new DynamicObject();
+ dynamicObject.vertexPositions = new ConstantProperty(Ellipsoid.WGS84.cartographicArrayToCartesianArray([new Cartographic(0, 0, 0), new Cartographic(1, 0, 0), new Cartographic(1, 1, 0), new Cartographic(0, 1, 0)]));
+ dynamicObject.polyline = polyline;
+ return dynamicObject;
+ }
+
+ it('Constructor sets expected defaults', function() {
+ var dynamicObject = new DynamicObject();
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+
+ expect(updater.isDestroyed()).toBe(false);
+ expect(updater.dynamicObject).toBe(dynamicObject);
+ expect(updater.isClosed).toBe(false);
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.fillMaterialProperty).toBe(undefined);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.hasConstantFill).toBe(true);
+ expect(updater.hasConstantOutline).toBe(true);
+ expect(updater.outlineColorProperty).toBe(undefined);
+ expect(updater.isDynamic).toBe(false);
+ expect(updater.isOutlineVisible(time)).toBe(false);
+ expect(updater.isFilled(time)).toBe(false);
+ updater.destroy();
+ expect(updater.isDestroyed()).toBe(true);
+ });
+
+ it('No geometry available when polyline is undefined ', function() {
+ var dynamicObject = createBasicPolyline();
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ dynamicObject.polyline = undefined;
+
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('No geometry available when not shown.', function() {
+ var dynamicObject = createBasicPolyline();
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ dynamicObject.polyline.show = new ConstantProperty(false);
+
+ expect(updater.fillEnabled).toBe(false);
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('Values correct when using default graphics', function() {
+ var dynamicObject = createBasicPolyline();
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+
+ expect(updater.isClosed).toBe(false);
+ expect(updater.fillEnabled).toBe(true);
+ expect(updater.fillMaterialProperty).toEqual(ColorMaterialProperty.fromColor(Color.WHITE));
+ expect(updater.outlineEnabled).toBe(false);
+ expect(updater.hasConstantFill).toBe(true);
+ expect(updater.hasConstantOutline).toBe(true);
+ expect(updater.outlineColorProperty).toBe(undefined);
+ expect(updater.isDynamic).toBe(false);
+ });
+
+ it('Polyline material is correctly exposed.', function() {
+ var dynamicObject = createBasicPolyline();
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ dynamicObject.polyline.material = new ColorMaterialProperty();
+ expect(updater.fillMaterialProperty).toBe(dynamicObject.polyline.material);
+ });
+
+ it('A time-varying vertexPositions causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicPolyline();
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ var point1 = new SampledPositionProperty();
+ point1.addSample(time, new Cartesian3());
+ var point2 = new SampledPositionProperty();
+ point2.addSample(time, new Cartesian3());
+ var point3 = new SampledPositionProperty();
+ point3.addSample(time, new Cartesian3());
+
+ dynamicObject.vertexPositions = new PropertyArray();
+ dynamicObject.vertexPositions.setValue([point1, point2, point3]);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ it('A time-varying width causes geometry to be dynamic', function() {
+ var dynamicObject = createBasicPolyline();
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ dynamicObject.polyline.width = new SampledProperty(Number);
+ dynamicObject.polyline.width.addSample(time, 1);
+ expect(updater.isDynamic).toBe(true);
+ });
+
+ function validateGeometryInstance(options) {
+ var dynamicObject = createBasicPolyline();
+
+ var polyline = dynamicObject.polyline;
+ polyline.show = new ConstantProperty(options.show);
+ polyline.material = options.material;
+
+ polyline.width = new ConstantProperty(options.width);
+
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+
+ var instance;
+ var geometry;
+ var attributes;
+ instance = updater.createFillGeometryInstance(time);
+ geometry = instance.geometry;
+ expect(geometry._width).toEqual(options.width);
+
+ attributes = instance.attributes;
+ if (options.material instanceof ColorMaterialProperty) {
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(options.material.color.getValue(time)));
+ } else {
+ expect(attributes.color).toBeUndefined();
+ }
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(options.show));
+ }
+
+ it('Creates expected per-color geometry', function() {
+ validateGeometryInstance({
+ show : true,
+ material : ColorMaterialProperty.fromColor(Color.RED),
+ width : 3
+ });
+ });
+
+ it('Creates expected per-material geometry', function() {
+ validateGeometryInstance({
+ show : true,
+ material : new GridMaterialProperty(),
+ width : 4
+ });
+ });
+
+ it('Attributes have expected values at creation time', function() {
+ var time1 = new JulianDate(0, 0);
+ var time2 = new JulianDate(10, 0);
+ var time3 = new JulianDate(20, 0);
+
+ var show = new TimeIntervalCollectionProperty();
+ show.intervals.addInterval(new TimeInterval(time1, time2, true, true, false));
+ show.intervals.addInterval(new TimeInterval(time2, time3, false, true, true));
+
+ var colorMaterial = new ColorMaterialProperty();
+ colorMaterial.color = new SampledProperty(Color);
+ colorMaterial.color.addSample(time, Color.YELLOW);
+ colorMaterial.color.addSample(time2, Color.BLUE);
+ colorMaterial.color.addSample(time3, Color.RED);
+
+ var dynamicObject = createBasicPolyline();
+ dynamicObject.polyline.show = show;
+ dynamicObject.polyline.material = colorMaterial;
+
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+
+ var instance = updater.createFillGeometryInstance(time2);
+ var attributes = instance.attributes;
+ expect(attributes.color.value).toEqual(ColorGeometryInstanceAttribute.toValue(colorMaterial.color.getValue(time2)));
+ expect(attributes.show.value).toEqual(ShowGeometryInstanceAttribute.toValue(show.getValue(time2)));
+ });
+
+ it('dynamic updater sets properties', function() {
+ //This test is mostly a smoke screen for now.
+ var time1 = new JulianDate(0, 0);
+ var time2 = new JulianDate(1, 0);
+ var time3 = new JulianDate(2, 0);
+
+ function makeProperty(value1, value2) {
+ var property = new TimeIntervalCollectionProperty();
+ property.intervals.addInterval(new TimeInterval(time1, time2, true, false, value1));
+ property.intervals.addInterval(new TimeInterval(time2, time3, true, false, value2));
+ return property;
+ }
+
+ var dynamicObject = createBasicPolyline();
+
+ var polyline = dynamicObject.polyline;
+ polyline.width = makeProperty(2, 12);
+ polyline.show = makeProperty(true, false);
+
+ dynamicObject.availability = new TimeIntervalCollection();
+ dynamicObject.availability.addInterval(new TimeInterval(time1, time3, true, false));
+
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ var primitives = new CompositePrimitive();
+ var dynamicUpdater = updater.createDynamicUpdater(primitives);
+ expect(dynamicUpdater.isDestroyed()).toBe(false);
+ expect(primitives.length).toBe(0);
+ dynamicUpdater.update(time1);
+ expect(primitives.length).toBe(1);
+ dynamicUpdater.destroy();
+ expect(primitives.length).toBe(0);
+ updater.destroy();
+ });
+
+ it('geometryChanged event is raised when expected', function() {
+ var dynamicObject = createBasicPolyline();
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ var listener = jasmine.createSpy('listener');
+ updater.geometryChanged.addEventListener(listener);
+
+ dynamicObject.vertexPositions = new ConstantProperty(Ellipsoid.WGS84.cartographicArrayToCartesianArray([new Cartographic(0, 0, 0), new Cartographic(1, 0, 0)]));
+ expect(listener.callCount).toEqual(1);
+
+ dynamicObject.polyline.width = new ConstantProperty(82);
+ expect(listener.callCount).toEqual(2);
+
+ dynamicObject.availability = new TimeIntervalCollection();
+ expect(listener.callCount).toEqual(3);
+
+ dynamicObject.vertexPositions = undefined;
+ expect(listener.callCount).toEqual(4);
+
+ //Since there's no valid geometry, changing another property should not raise the event.
+ dynamicObject.polyline.width = undefined;
+
+ //Modifying an unrelated property should not have any effect.
+ dynamicObject.viewFrom = new ConstantProperty(Cartesian3.UNIT_X);
+ expect(listener.callCount).toEqual(4);
+ });
+
+ it('createFillGeometryInstance throws if object is not shown', function() {
+ var dynamicObject = new DynamicObject();
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createFillGeometryInstance(time);
+ }).toThrowDeveloperError();
+ });
+
+ it('createFillGeometryInstance throws if no time provided', function() {
+ var dynamicObject = createBasicPolyline();
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createFillGeometryInstance(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('createOutlineGeometryInstance throws', function() {
+ var dynamicObject = new DynamicObject();
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createOutlineGeometryInstance();
+ }).toThrowDeveloperError();
+ });
+
+ it('createDynamicUpdater throws if not dynamic', function() {
+ var dynamicObject = createBasicPolyline();
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ expect(function() {
+ return updater.createDynamicUpdater(new CompositePrimitive());
+ }).toThrowDeveloperError();
+ });
+
+ it('createDynamicUpdater throws if primitives undefined', function() {
+ var dynamicObject = createBasicPolyline();
+ dynamicObject.polyline.width = new SampledProperty(Number);
+ dynamicObject.polyline.width.addSample(time, 4);
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ expect(updater.isDynamic).toBe(true);
+ expect(function() {
+ return updater.createDynamicUpdater(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('dynamicUpdater.update throws if no time specified', function() {
+ var dynamicObject = createBasicPolyline();
+ dynamicObject.polyline.width = new SampledProperty(Number);
+ dynamicObject.polyline.width.addSample(time, 4);
+ var updater = new PolylineGeometryUpdater(dynamicObject);
+ var dynamicUpdater = updater.createDynamicUpdater(new CompositePrimitive());
+ expect(function() {
+ dynamicUpdater.update(undefined);
+ }).toThrowDeveloperError();
+ });
+
+ it('Constructor throws if no DynamicObject supplied', function() {
+ expect(function() {
+ return new PolylineGeometryUpdater(undefined);
+ }).toThrowDeveloperError();
+ });
+});
\ No newline at end of file
diff --git a/Specs/DynamicScene/PolylineOutlineMaterialPropertySpec.js b/Specs/DynamicScene/PolylineOutlineMaterialPropertySpec.js
index cdb025b14873..9619bd7777f8 100644
--- a/Specs/DynamicScene/PolylineOutlineMaterialPropertySpec.js
+++ b/Specs/DynamicScene/PolylineOutlineMaterialPropertySpec.js
@@ -1,32 +1,28 @@
/*global defineSuite*/
-defineSuite([
- 'DynamicScene/PolylineOutlineMaterialProperty',
+defineSuite(['DynamicScene/PolylineOutlineMaterialProperty',
'DynamicScene/ConstantProperty',
'DynamicScene/TimeIntervalCollectionProperty',
'Core/Color',
'Core/JulianDate',
- 'Core/TimeInterval',
- 'Specs/UndefinedProperty'
+ 'Core/TimeInterval'
], function(
PolylineOutlineMaterialProperty,
ConstantProperty,
TimeIntervalCollectionProperty,
Color,
JulianDate,
- TimeInterval,
- UndefinedProperty) {
+ TimeInterval) {
"use strict";
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
- it('works with basic types', function() {
+ it('constructor provides the expected defaults', function() {
var property = new PolylineOutlineMaterialProperty();
- expect(property.color).toBeDefined();
- expect(property.outlineColor).toBeDefined();
expect(property.getType()).toEqual('PolylineOutline');
var result = property.getValue();
expect(result.color).toEqual(Color.WHITE);
expect(result.outlineColor).toEqual(Color.BLACK);
+ expect(result.outlineWidth).toEqual(0.0);
});
it('works with constant values', function() {
@@ -41,8 +37,8 @@ defineSuite([
it('works with undefined values', function() {
var property = new PolylineOutlineMaterialProperty();
- property.color = new UndefinedProperty();
- property.outlineColor = new UndefinedProperty();
+ property.color.setValue(undefined);
+ property.outlineColor.setValue(undefined);
var result = property.getValue();
expect(result.hasOwnProperty('color')).toEqual(true);
@@ -104,4 +100,75 @@ defineSuite([
right.outlineWidth = new ConstantProperty(6);
expect(left.equals(right)).toEqual(false);
});
+
+ it('raises definitionChanged when a property is assigned or modified', function() {
+ var property = new PolylineOutlineMaterialProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
+ var oldValue = property.color;
+ property.color = new ConstantProperty(Color.RED);
+ expect(listener).toHaveBeenCalledWith(property, 'color', property.color, oldValue);
+ listener.reset();
+
+ property.color.setValue(Color.YELLOW);
+ expect(listener).toHaveBeenCalledWith(property, 'color', property.color, property.color);
+ listener.reset();
+
+ property.color = property.color;
+ expect(listener.callCount).toEqual(0);
+ listener.reset();
+
+ oldValue = property.outlineColor;
+ property.outlineColor = new ConstantProperty(Color.BLUE);
+ expect(listener).toHaveBeenCalledWith(property, 'outlineColor', property.outlineColor, oldValue);
+ listener.reset();
+
+ property.outlineColor.setValue(Color.GREEN);
+ expect(listener).toHaveBeenCalledWith(property, 'outlineColor', property.outlineColor, property.outlineColor);
+ listener.reset();
+
+ property.outlineColor = property.outlineColor;
+ expect(listener.callCount).toEqual(0);
+
+ oldValue = property.outlineWidth;
+ property.outlineWidth = new ConstantProperty(2.5);
+ expect(listener).toHaveBeenCalledWith(property, 'outlineWidth', property.outlineWidth, oldValue);
+ listener.reset();
+
+ property.outlineWidth.setValue(1.5);
+ expect(listener).toHaveBeenCalledWith(property, 'outlineWidth', property.outlineWidth, property.outlineWidth);
+ listener.reset();
+
+ property.outlineWidth = property.outlineWidth;
+ expect(listener.callCount).toEqual(0);
+ });
+
+ it('isConstant is only true when all properties are constant or undefined', function() {
+ var property = new PolylineOutlineMaterialProperty();
+ expect(property.isConstant).toBe(true);
+
+ property.color = undefined;
+ property.outlineColor = undefined;
+ property.outlineWidth = undefined;
+ expect(property.isConstant).toBe(true);
+
+ var start = new JulianDate(1, 0);
+ var stop = new JulianDate(2, 0);
+ property.color = new TimeIntervalCollectionProperty();
+ property.color.intervals.addInterval(new TimeInterval(start, stop, true, true, Color.RED));
+ expect(property.isConstant).toBe(false);
+
+ property.color = undefined;
+ expect(property.isConstant).toBe(true);
+ property.outlineColor = new TimeIntervalCollectionProperty();
+ property.outlineColor.intervals.addInterval(new TimeInterval(start, stop, true, true, Color.BLUE));
+ expect(property.isConstant).toBe(false);
+
+ property.outlineColor = undefined;
+ expect(property.isConstant).toBe(true);
+ property.outlineWidth = new TimeIntervalCollectionProperty();
+ property.outlineWidth.intervals.addInterval(new TimeInterval(start, stop, true, true, 2.0));
+ expect(property.isConstant).toBe(false);
+ });
});
\ No newline at end of file
diff --git a/Specs/DynamicScene/PositionPropertyArraySpec.js b/Specs/DynamicScene/PositionPropertyArraySpec.js
new file mode 100644
index 000000000000..add65f0fe671
--- /dev/null
+++ b/Specs/DynamicScene/PositionPropertyArraySpec.js
@@ -0,0 +1,113 @@
+/*global defineSuite*/
+defineSuite(['DynamicScene/PositionPropertyArray',
+ 'DynamicScene/ConstantPositionProperty',
+ 'DynamicScene/SampledPositionProperty',
+ 'Core/Cartesian3',
+ 'Core/JulianDate',
+ 'Core/ReferenceFrame'
+ ], function(
+ PositionPropertyArray,
+ ConstantPositionProperty,
+ SampledPositionProperty,
+ Cartesian3,
+ JulianDate,
+ ReferenceFrame) {
+ "use strict";
+ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
+
+ var time = new JulianDate();
+
+ it('default constructor sets expected values', function() {
+ var property = new PositionPropertyArray();
+ expect(property.isConstant).toBe(true);
+ expect(property.getValue(time)).toBeUndefined();
+ });
+
+ it('constructor sets expected values', function() {
+ var expected = [Cartesian3.UNIT_X, Cartesian3.UNIT_Z];
+ var value = [new ConstantPositionProperty(Cartesian3.UNIT_X), new ConstantPositionProperty(Cartesian3.UNIT_Z)];
+ var property = new PositionPropertyArray(value);
+ expect(property.getValue(time)).toEqual(expected);
+ });
+
+ it('setValue rasies definitionChanged event', function() {
+ var property = new PositionPropertyArray();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+ property.setValue([]);
+ expect(listener).toHaveBeenCalledWith(property);
+ });
+
+ it('changing array member raises definitionChanged event', function() {
+ var property = new PositionPropertyArray();
+ var item = new ConstantPositionProperty(Cartesian3.UNIT_X);
+ property.setValue([item]);
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+ item.setValue(Cartesian3.UNIT_Z);
+ expect(listener).toHaveBeenCalledWith(property);
+ });
+
+ it('works with result parameter', function() {
+ var expected = [Cartesian3.UNIT_X, Cartesian3.UNIT_Z];
+ var expectedResult = [];
+ var value = [new ConstantPositionProperty(Cartesian3.UNIT_X), new ConstantPositionProperty(Cartesian3.UNIT_Z)];
+ var property = new PositionPropertyArray(value);
+ var result = property.getValue(time, expectedResult);
+ expect(result).toEqual(expected);
+ expect(result).toBe(expectedResult);
+ });
+
+ it('works with reference frame parameter', function() {
+ var value = [new ConstantPositionProperty(Cartesian3.UNIT_X, ReferenceFrame.INERTIAL), new ConstantPositionProperty(Cartesian3.UNIT_Z, ReferenceFrame.FIXED)];
+ var expected = [value[0].getValueInReferenceFrame(time, ReferenceFrame.INERTIAL), value[1].getValueInReferenceFrame(time, ReferenceFrame.INERTIAL)];
+ var property = new PositionPropertyArray(value);
+ var result = property.getValueInReferenceFrame(time, ReferenceFrame.INERTIAL);
+ expect(result).toEqual(expected);
+ });
+
+ it('works with undefined value', function() {
+ var property = new PositionPropertyArray();
+ property.setValue(undefined);
+ expect(property.getValue(time)).toBeUndefined();
+ });
+
+ it('works with undefined propertyvalue', function() {
+ var property = new PositionPropertyArray();
+ property.setValue([new ConstantPositionProperty()]);
+ expect(property.getValue(time)).toEqual([]);
+ });
+
+ it('works with empty array', function() {
+ var property = new PositionPropertyArray();
+ property.setValue([]);
+ expect(property.getValue(time)).toEqual([]);
+ });
+
+ it('equals works', function() {
+ var left = new PositionPropertyArray([new ConstantPositionProperty(Cartesian3.UNIT_X)]);
+ var right = new PositionPropertyArray([new ConstantPositionProperty(Cartesian3.UNIT_X)]);
+
+ expect(left.equals(right)).toEqual(true);
+
+ right = new PositionPropertyArray([new ConstantPositionProperty(Cartesian3.UNIT_Z)]);
+ expect(left.equals(right)).toEqual(false);
+
+ left = new PositionPropertyArray();
+ right = new PositionPropertyArray();
+ expect(left.equals(right)).toEqual(true);
+ });
+
+ it('isConstant is true only if all members are constant', function() {
+ var property = new PositionPropertyArray();
+
+ property.setValue([new ConstantPositionProperty(Cartesian3.UNIT_X)]);
+ expect(property.isConstant).toBe(true);
+
+ var sampledProperty = new SampledPositionProperty();
+ sampledProperty.addSample(time, Cartesian3.UNIT_X);
+ property.setValue([new ConstantPositionProperty(Cartesian3.UNIT_Z), sampledProperty]);
+
+ expect(property.isConstant).toBe(false);
+ });
+});
\ No newline at end of file
diff --git a/Specs/DynamicScene/PropertyArraySpec.js b/Specs/DynamicScene/PropertyArraySpec.js
new file mode 100644
index 000000000000..230eeaae515d
--- /dev/null
+++ b/Specs/DynamicScene/PropertyArraySpec.js
@@ -0,0 +1,103 @@
+/*global defineSuite*/
+defineSuite(['DynamicScene/PropertyArray',
+ 'DynamicScene/ConstantProperty',
+ 'DynamicScene/SampledProperty',
+ 'Core/Cartesian3',
+ 'Core/JulianDate'
+ ], function(
+ PropertyArray,
+ ConstantProperty,
+ SampledProperty,
+ Cartesian3,
+ JulianDate) {
+ "use strict";
+ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
+
+ var time = new JulianDate();
+
+ it('default constructor sets expected values', function() {
+ var property = new PropertyArray();
+ expect(property.isConstant).toBe(true);
+ expect(property.getValue(time)).toBeUndefined();
+ });
+
+ it('constructor sets expected values', function() {
+ var expected = [1, 2];
+ var value = [new ConstantProperty(1), new ConstantProperty(2)];
+ var property = new PropertyArray(value);
+ expect(property.getValue(time)).toEqual(expected);
+ });
+
+ it('setValue rasies definitionChanged event', function() {
+ var property = new PropertyArray();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+ property.setValue([]);
+ expect(listener).toHaveBeenCalledWith(property);
+ });
+
+ it('changing array member raises definitionChanged event', function() {
+ var property = new PropertyArray();
+ var item = new ConstantProperty(1);
+ property.setValue([item]);
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+ item.setValue(2);
+ expect(listener).toHaveBeenCalledWith(property);
+ });
+
+ it('works with result parameter', function() {
+ var expected = [1, 2];
+ var expectedResult = [];
+ var value = [new ConstantProperty(1), new ConstantProperty(2)];
+ var property = new PropertyArray(value);
+ var result = property.getValue(time, expectedResult);
+ expect(result).toEqual(expected);
+ expect(result).toBe(expectedResult);
+ });
+
+ it('works with undefined value', function() {
+ var property = new PropertyArray();
+ property.setValue(undefined);
+ expect(property.getValue(time)).toBeUndefined();
+ });
+
+ it('ignores undefined property values', function() {
+ var property = new PropertyArray();
+ property.setValue([new ConstantProperty()]);
+ expect(property.getValue(time)).toEqual([]);
+ });
+
+ it('works with empty array', function() {
+ var property = new PropertyArray();
+ property.setValue([]);
+ expect(property.getValue(time)).toEqual([]);
+ });
+
+ it('equals works', function() {
+ var left = new PropertyArray([new ConstantProperty(1)]);
+ var right = new PropertyArray([new ConstantProperty(1)]);
+
+ expect(left.equals(right)).toEqual(true);
+
+ right = new PropertyArray([new ConstantProperty(2)]);
+ expect(left.equals(right)).toEqual(false);
+
+ left = new PropertyArray();
+ right = new PropertyArray();
+ expect(left.equals(right)).toEqual(true);
+ });
+
+ it('isConstant is true only if all members are constant', function() {
+ var property = new PropertyArray();
+
+ property.setValue([new ConstantProperty(2)]);
+ expect(property.isConstant).toBe(true);
+
+ var sampledProperty = new SampledProperty(Number);
+ sampledProperty.addSample(time, 1);
+ property.setValue([new ConstantProperty(2), sampledProperty]);
+
+ expect(property.isConstant).toBe(false);
+ });
+});
\ No newline at end of file
diff --git a/Specs/DynamicScene/SampledPositionPropertySpec.js b/Specs/DynamicScene/SampledPositionPropertySpec.js
index e4c2c745a930..5dc5f947fbac 100644
--- a/Specs/DynamicScene/SampledPositionPropertySpec.js
+++ b/Specs/DynamicScene/SampledPositionPropertySpec.js
@@ -1,6 +1,5 @@
/*global defineSuite*/
-defineSuite([
- 'DynamicScene/SampledPositionProperty',
+defineSuite(['DynamicScene/SampledPositionProperty',
'DynamicScene/PositionProperty',
'Core/Cartesian3',
'Core/defined',
@@ -172,8 +171,10 @@ defineSuite([
var property = new SampledPositionProperty();
property.addSamplesPackedArray(data, epoch);
- property.interpolationDegree = 2;
- property.interpolationAlgorithm = MockInterpolation;
+ property.setInterpolationOptions({
+ interpolationDegree : 2,
+ interpolationAlgorithm : MockInterpolation
+ });
expect(property.getValue(epoch)).toEqual(new Cartesian3(7, 8, 9));
expect(property.getValue(new JulianDate(0, 3))).toEqual(new Cartesian3(2, 3, 4));
@@ -208,27 +209,35 @@ defineSuite([
it('equals works when interpolators differ', function() {
var left = new SampledPositionProperty();
- left.interpolationAlgorithm = LinearApproximation;
-
var right = new SampledPositionProperty();
- right.interpolationAlgorithm = LinearApproximation;
expect(left.equals(right)).toEqual(true);
- right.interpolationAlgorithm = LagrangePolynomialApproximation;
+ right.setInterpolationOptions({
+ interpolationAlgorithm : LagrangePolynomialApproximation
+ });
expect(left.equals(right)).toEqual(false);
});
it('equals works when interpolator degree differ', function() {
var left = new SampledPositionProperty();
- left.interpolationAlgorithm = LagrangePolynomialApproximation;
- left.interpolationDegree = 2;
+
+ left.setInterpolationOptions({
+ interpolationDegree : 2,
+ interpolationAlgorithm : LagrangePolynomialApproximation
+ });
var right = new SampledPositionProperty();
- right.interpolationAlgorithm = LagrangePolynomialApproximation;
- right.interpolationDegree = 2;
+ right.setInterpolationOptions({
+ interpolationDegree : 2,
+ interpolationAlgorithm : LagrangePolynomialApproximation
+ });
expect(left.equals(right)).toEqual(true);
- right.interpolationDegree = 3;
+ right.setInterpolationOptions({
+ interpolationDegree : 3,
+ interpolationAlgorithm : LagrangePolynomialApproximation
+ });
+
expect(left.equals(right)).toEqual(false);
});
diff --git a/Specs/DynamicScene/SampledPropertySpec.js b/Specs/DynamicScene/SampledPropertySpec.js
index 5f8310631ff2..93363aa22981 100644
--- a/Specs/DynamicScene/SampledPropertySpec.js
+++ b/Specs/DynamicScene/SampledPropertySpec.js
@@ -1,6 +1,5 @@
/*global defineSuite*/
-defineSuite([
- 'DynamicScene/SampledProperty',
+defineSuite(['DynamicScene/SampledProperty',
'Core/defined',
'Core/JulianDate',
'Core/LinearApproximation',
@@ -18,6 +17,14 @@ defineSuite([
var property = new SampledProperty(Number);
expect(property.interpolationDegree).toEqual(1);
expect(property.interpolationAlgorithm).toEqual(LinearApproximation);
+ expect(property.isConstant).toEqual(true);
+ });
+
+ it('isConstant works', function() {
+ var property = new SampledProperty(Number);
+ expect(property.isConstant).toEqual(true);
+ property.addSample(new JulianDate(0, 0), 1);
+ expect(property.isConstant).toEqual(false);
});
it('addSamplesPackedArray works', function() {
@@ -25,7 +32,12 @@ defineSuite([
var epoch = new JulianDate(0, 0);
var property = new SampledProperty(Number);
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
property.addSamplesPackedArray(data, epoch);
+
+ expect(listener).toHaveBeenCalledWith(property);
expect(property.getValue(epoch)).toEqual(7);
expect(property.getValue(new JulianDate(0, 0.5))).toEqual(7.5);
});
@@ -35,9 +47,20 @@ defineSuite([
var times = [new JulianDate(0, 0), new JulianDate(1, 0), new JulianDate(2, 0)];
var property = new SampledProperty(Number);
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
property.addSample(times[0], values[0]);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
property.addSample(times[1], values[1]);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
property.addSample(times[2], values[2]);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
expect(property.getValue(times[0])).toEqual(values[0]);
expect(property.getValue(times[1])).toEqual(values[1]);
@@ -50,7 +73,11 @@ defineSuite([
var times = [new JulianDate(0, 0), new JulianDate(1, 0), new JulianDate(2, 0)];
var property = new SampledProperty(Number);
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
property.addSamples(times, values);
+
+ expect(listener).toHaveBeenCalledWith(property);
expect(property.getValue(times[0])).toEqual(values[0]);
expect(property.getValue(times[1])).toEqual(values[1]);
expect(property.getValue(times[2])).toEqual(values[2]);
@@ -136,12 +163,20 @@ defineSuite([
};
var property = new SampledProperty(Number);
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
property.addSamplesPackedArray(data, epoch);
+
expect(property.getValue(epoch)).toEqual(7);
expect(property.getValue(new JulianDate(0, 1))).toEqual(8);
- property.interpolationDegree = 2;
- property.interpolationAlgorithm = MockInterpolation;
+ property.setInterpolationOptions({
+ interpolationAlgorithm : MockInterpolation,
+ interpolationDegree : 2
+ });
+
+ expect(listener).toHaveBeenCalledWith(property);
expect(property.getValue(epoch)).toEqual(7);
expect(property.getValue(new JulianDate(0, 3))).toEqual(2);
@@ -293,27 +328,35 @@ defineSuite([
it('equals works when interpolators differ', function() {
var left = new SampledProperty(Number);
- left.interpolationAlgorithm = LinearApproximation;
-
var right = new SampledProperty(Number);
- right.interpolationAlgorithm = LinearApproximation;
expect(left.equals(right)).toEqual(true);
- right.interpolationAlgorithm = LagrangePolynomialApproximation;
+ right.setInterpolationOptions({
+ interpolationAlgorithm : LagrangePolynomialApproximation
+ });
expect(left.equals(right)).toEqual(false);
});
it('equals works when interpolator degree differ', function() {
var left = new SampledProperty(Number);
- left.interpolationAlgorithm = LagrangePolynomialApproximation;
- left.interpolationDegree = 2;
+
+ left.setInterpolationOptions({
+ interpolationDegree : 2,
+ interpolationAlgorithm : LagrangePolynomialApproximation
+ });
var right = new SampledProperty(Number);
- right.interpolationAlgorithm = LagrangePolynomialApproximation;
- right.interpolationDegree = 2;
+ right.setInterpolationOptions({
+ interpolationDegree : 2,
+ interpolationAlgorithm : LagrangePolynomialApproximation
+ });
expect(left.equals(right)).toEqual(true);
- right.interpolationDegree = 3;
+ right.setInterpolationOptions({
+ interpolationDegree : 3,
+ interpolationAlgorithm : LagrangePolynomialApproximation
+ });
+
expect(left.equals(right)).toEqual(false);
});
diff --git a/Specs/DynamicScene/TimeIntervalCollectionPositionPropertySpec.js b/Specs/DynamicScene/TimeIntervalCollectionPositionPropertySpec.js
index ff3a5a7b3588..9cc48d9e8677 100644
--- a/Specs/DynamicScene/TimeIntervalCollectionPositionPropertySpec.js
+++ b/Specs/DynamicScene/TimeIntervalCollectionPositionPropertySpec.js
@@ -1,6 +1,5 @@
/*global defineSuite*/
-defineSuite([
- 'DynamicScene/TimeIntervalCollectionPositionProperty',
+defineSuite(['DynamicScene/TimeIntervalCollectionPositionProperty',
'DynamicScene/PositionProperty',
'Core/Cartesian3',
'Core/JulianDate',
@@ -159,4 +158,24 @@ defineSuite([
right.intervals.addInterval(interval2);
expect(left.equals(right)).toEqual(true);
});
+
+ it('raises definitionChanged event', function() {
+ var interval = new TimeInterval(new JulianDate(10, 0), new JulianDate(12, 0), true, true, new Cartesian3(1, 2, 3));
+
+ var property = new TimeIntervalCollectionPositionProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
+ property.intervals.addInterval(interval);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ property.intervals.removeInterval(interval);
+ expect(listener).toHaveBeenCalledWith(property);
+
+ property.intervals.addInterval(interval);
+ listener.reset();
+ property.intervals.clear();
+ expect(listener).toHaveBeenCalledWith(property);
+ });
});
\ No newline at end of file
diff --git a/Specs/DynamicScene/TimeIntervalCollectionPropertySpec.js b/Specs/DynamicScene/TimeIntervalCollectionPropertySpec.js
index 29b0ced2f664..40a8dd7c0654 100644
--- a/Specs/DynamicScene/TimeIntervalCollectionPropertySpec.js
+++ b/Specs/DynamicScene/TimeIntervalCollectionPropertySpec.js
@@ -1,6 +1,5 @@
/*global defineSuite*/
-defineSuite([
- 'DynamicScene/TimeIntervalCollectionProperty',
+defineSuite(['DynamicScene/TimeIntervalCollectionProperty',
'Core/Cartesian3',
'Core/JulianDate',
'Core/TimeInterval',
@@ -18,6 +17,7 @@ defineSuite([
var property = new TimeIntervalCollectionProperty();
expect(property.intervals).toBeInstanceOf(TimeIntervalCollection);
expect(property.getValue(new JulianDate())).toBeUndefined();
+ expect(property.isConstant).toBe(true);
});
it('works with basic types', function() {
@@ -30,6 +30,7 @@ defineSuite([
expect(property.getValue(interval1.start)).toBe(interval1.data);
expect(property.getValue(interval2.stop)).toBe(interval2.data);
+ expect(property.isConstant).toBe(false);
});
it('works with clonable objects', function() {
@@ -105,4 +106,24 @@ defineSuite([
right.intervals.addInterval(interval2);
expect(left.equals(right)).toEqual(true);
});
+
+ it('raises definitionChanged event', function() {
+ var interval = new TimeInterval(new JulianDate(10, 0), new JulianDate(12, 0), true, true, new Cartesian3(1, 2, 3));
+
+ var property = new TimeIntervalCollectionProperty();
+ var listener = jasmine.createSpy('listener');
+ property.definitionChanged.addEventListener(listener);
+
+ property.intervals.addInterval(interval);
+ expect(listener).toHaveBeenCalledWith(property);
+ listener.reset();
+
+ property.intervals.removeInterval(interval);
+ expect(listener).toHaveBeenCalledWith(property);
+
+ property.intervals.addInterval(interval);
+ listener.reset();
+ property.intervals.clear();
+ expect(listener).toHaveBeenCalledWith(property);
+ });
});
\ No newline at end of file
diff --git a/Specs/DynamicScene/VisualizerCollectionSpec.js b/Specs/DynamicScene/VisualizerCollectionSpec.js
deleted file mode 100644
index 63ea3fb3ef42..000000000000
--- a/Specs/DynamicScene/VisualizerCollectionSpec.js
+++ /dev/null
@@ -1,139 +0,0 @@
-/*global defineSuite*/
-defineSuite([
- 'DynamicScene/VisualizerCollection',
- 'Core/JulianDate'
- ], function(
- VisualizerCollection,
- JulianDate) {
- "use strict";
- /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
-
- function MockVisualizer() {
- this.updateTime = undefined;
- this.isDestroyed = false;
- this.removeAllPrimitivesCalled = false;
- }
-
- MockVisualizer.prototype.setDynamicObjectCollection = function(dynamicObjectCollection) {
- this.mockCollection = dynamicObjectCollection;
- };
-
- MockVisualizer.prototype.update = function(time) {
- this.updateTime = time;
- };
-
- MockVisualizer.prototype.removeAllPrimitives = function() {
- this.removeAllPrimitivesCalled = true;
- };
-
- MockVisualizer.prototype.destroy = function() {
- this.isDestroyed = true;
- };
-
- function MockDynamicObjectCollection() {
- }
-
- it('Default constructor creates expected default properties', function() {
- var visualizers = new VisualizerCollection();
- expect(visualizers.getVisualizers().length).toEqual(0);
- expect(visualizers.getDynamicObjectCollection()).toBeUndefined();
- expect(visualizers.isDestroyed()).toEqual(false);
- });
-
- it('Constructor assigns expected paramters to properies', function() {
- var mockVisualizer = new MockVisualizer();
- var mockCollection = new MockDynamicObjectCollection();
-
- var visualizers = new VisualizerCollection([mockVisualizer], mockCollection);
- expect(visualizers.getVisualizers().length).toEqual(1);
- expect(visualizers.getDynamicObjectCollection()).toEqual(mockCollection);
- expect(mockVisualizer.mockCollection).toEqual(mockCollection);
- });
-
- it('Constructor assigns expected paramters to properies', function() {
- var mockVisualizer = new MockVisualizer();
- var mockCollection = new MockDynamicObjectCollection();
-
- var visualizers = new VisualizerCollection([mockVisualizer], mockCollection);
- expect(visualizers.getVisualizers().length).toEqual(1);
- expect(visualizers.getDynamicObjectCollection()).toEqual(mockCollection);
- expect(mockVisualizer.mockCollection).toEqual(mockCollection);
- });
-
- it('setVisualizers destroys old visualizers by default', function() {
- var mockVisualizer = new MockVisualizer();
- var mockCollection = new MockDynamicObjectCollection();
-
- var visualizers = new VisualizerCollection([mockVisualizer], mockCollection);
- visualizers.setVisualizers([]);
- expect(mockVisualizer.isDestroyed).toEqual(true);
- });
-
- it('setVisualizers does not destroys old visualizers if told', function() {
- var mockVisualizer = new MockVisualizer();
- var mockCollection = new MockDynamicObjectCollection();
-
- var visualizers = new VisualizerCollection([mockVisualizer], mockCollection);
- visualizers.setVisualizers([], false);
- expect(mockVisualizer.isDestroyed).toEqual(false);
- });
-
- it('setVisualizers does not destroys visualizers that is in new list', function() {
- var mockVisualizer = new MockVisualizer();
- var mockVisualizer2 = new MockVisualizer();
- var mockCollection = new MockDynamicObjectCollection();
-
- var visualizers = new VisualizerCollection([mockVisualizer, mockVisualizer2], mockCollection);
- visualizers.setVisualizers([mockVisualizer]);
- expect(mockVisualizer.isDestroyed).toEqual(false);
- expect(mockVisualizer2.isDestroyed).toEqual(true);
- });
-
- it('destroy destroys old visualizers by default', function() {
- var mockVisualizer = new MockVisualizer();
- var mockCollection = new MockDynamicObjectCollection();
-
- var visualizers = new VisualizerCollection([mockVisualizer], mockCollection);
- visualizers.destroy();
- expect(visualizers.isDestroyed()).toEqual(true);
- expect(mockVisualizer.isDestroyed).toEqual(true);
- });
-
- it('destroy does not destroy old visualizers if told', function() {
- var mockVisualizer = new MockVisualizer();
- var mockCollection = new MockDynamicObjectCollection();
-
- var visualizers = new VisualizerCollection([mockVisualizer], mockCollection);
- visualizers.destroy(false);
- expect(visualizers.isDestroyed()).toEqual(true);
- expect(mockVisualizer.isDestroyed).toEqual(false);
- });
-
- it('setDynamicObjectCollection calls setDynamicObjectCollection on underlying visualizers', function() {
- var mockVisualizer = new MockVisualizer();
- var mockCollection = new MockDynamicObjectCollection();
-
- var visualizers = new VisualizerCollection([mockVisualizer]);
- visualizers.setDynamicObjectCollection(mockCollection);
- expect(mockVisualizer.mockCollection).toEqual(mockCollection);
- });
-
- it('update calls update on underlying visualizers', function() {
- var mockVisualizer = new MockVisualizer();
- var mockCollection = new MockDynamicObjectCollection();
-
- var visualizers = new VisualizerCollection([mockVisualizer], mockCollection);
- var updateTime = new JulianDate();
- visualizers.update(updateTime);
- expect(mockVisualizer.updateTime).toEqual(updateTime);
- });
-
- it('removeAllPrimitives calls removeAllPrimitives on underlying visualizers', function() {
- var mockVisualizer = new MockVisualizer();
- var mockCollection = new MockDynamicObjectCollection();
-
- var visualizers = new VisualizerCollection([mockVisualizer], mockCollection);
- visualizers.removeAllPrimitives();
- expect(mockVisualizer.removeAllPrimitivesCalled).toEqual(true);
- });
-});
\ No newline at end of file
diff --git a/Specs/Renderer/FramebufferSpec.js b/Specs/Renderer/FramebufferSpec.js
index 575dc717c376..d8e5ccf96fd1 100644
--- a/Specs/Renderer/FramebufferSpec.js
+++ b/Specs/Renderer/FramebufferSpec.js
@@ -571,7 +571,7 @@ defineSuite([
pixelDatatype : PixelDatatype.UNSIGNED_SHORT
})]
});
- }).toThrow();
+ }).toThrowDeveloperError();
});
it('throws when created with a depth texture without a DEPTH_COMPONENT pixel format', function() {
diff --git a/Specs/Scene/BillboardCollectionSpec.js b/Specs/Scene/BillboardCollectionSpec.js
index 0616f70de84c..b9a6365361e5 100644
--- a/Specs/Scene/BillboardCollectionSpec.js
+++ b/Specs/Scene/BillboardCollectionSpec.js
@@ -992,23 +992,23 @@ defineSuite([
it('renders bounding volume with debugShowBoundingVolume', function() {
var scene = createScene();
- var b = scene.getPrimitives().add(new BillboardCollection({
+ var b = scene.primitives.add(new BillboardCollection({
debugShowBoundingVolume : true
}));
- b.setTextureAtlas(createTextureAtlas(scene.getContext(), [greenImage]));
+ b.setTextureAtlas(createTextureAtlas(scene.context, [greenImage]));
b.add({
position : Cartesian3.ZERO,
imageIndex : 0
});
- var camera = scene.getCamera();
+ var camera = scene.camera;
camera.position = new Cartesian3(1.02, 0.0, 0.0);
camera.direction = Cartesian3.negate(Cartesian3.UNIT_X);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Z);
scene.initializeFrame();
scene.render();
- var pixels = scene.getContext().readPixels();
+ var pixels = scene.context.readPixels();
expect(pixels[0]).not.toEqual(0);
expect(pixels[1]).toEqual(0);
expect(pixels[2]).toEqual(0);
@@ -1326,7 +1326,7 @@ defineSuite([
position : ellipsoid.cartographicToCartesian(Cartographic.fromDegrees(-50.0, 50.0, 0.0))
});
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
var orthoFrustum = new OrthographicFrustum();
orthoFrustum.right = maxRadii * Math.PI;
orthoFrustum.left = -orthoFrustum.right;
diff --git a/Specs/Scene/CameraControllerSpec.js b/Specs/Scene/CameraControllerSpec.js
index 8d17468f607e..04c061f9e966 100644
--- a/Specs/Scene/CameraControllerSpec.js
+++ b/Specs/Scene/CameraControllerSpec.js
@@ -816,7 +816,7 @@ defineSuite([
it('pick ellipsoid', function() {
var ellipsoid = Ellipsoid.WGS84;
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
camera.position = Cartesian3.multiplyByScalar(Cartesian3.UNIT_X, 2.0 * maxRadii);
camera.direction = Cartesian3.normalize(Cartesian3.negate(camera.position));
@@ -842,7 +842,7 @@ defineSuite([
it('pick map in 2D', function() {
var ellipsoid = Ellipsoid.WGS84;
var projection = new GeographicProjection(ellipsoid);
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
camera.position = new Cartesian3(0.0, 0.0, 2.0 * maxRadii);
camera.direction = Cartesian3.normalize(Cartesian3.negate(camera.position));
@@ -872,7 +872,7 @@ defineSuite([
it('pick rotated map in 2D', function() {
var ellipsoid = Ellipsoid.WGS84;
var projection = new GeographicProjection(ellipsoid);
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
camera.position = new Cartesian3(0.0, 0.0, 2.0 * maxRadii);
camera.direction = Cartesian3.normalize(Cartesian3.negate(camera.position));
@@ -908,7 +908,7 @@ defineSuite([
it('pick map in columbus view', function() {
var ellipsoid = Ellipsoid.WGS84;
var projection = new GeographicProjection(ellipsoid);
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
camera.position = Cartesian3.multiplyByScalar(Cartesian3.normalize(new Cartesian3(0.0, -1.0, 1.0)), 5.0 * maxRadii);
camera.direction = Cartesian3.normalize(Cartesian3.subtract(Cartesian3.ZERO, camera.position));
@@ -948,7 +948,7 @@ defineSuite([
it('set position cartographic in 2D', function() {
var ellipsoid = Ellipsoid.WGS84;
var projection = new GeographicProjection(ellipsoid);
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
controller._mode = SceneMode.SCENE2D;
controller._projection = projection;
@@ -1175,7 +1175,7 @@ defineSuite([
it('gets magnitude in 2D', function() {
var ellipsoid = Ellipsoid.WGS84;
var projection = new GeographicProjection(ellipsoid);
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
controller._mode = SceneMode.SCENE2D;
controller._projection = projection;
@@ -1297,7 +1297,7 @@ defineSuite([
});
it('animates position to visible map in Columbus view', function() {
- var maxRadii = Ellipsoid.WGS84.getMaximumRadius();
+ var maxRadii = Ellipsoid.WGS84.maximumRadius;
var frustum = new PerspectiveFrustum();
frustum.fovy = CesiumMath.toRadians(60.0);
frustum.aspectRatio = context.getDrawingBufferWidth() / context.getDrawingBufferHeight();
@@ -1347,7 +1347,7 @@ defineSuite([
});
it('animates position to visible map in Columbus view with web mercator projection', function() {
- var maxRadii = Ellipsoid.WGS84.getMaximumRadius();
+ var maxRadii = Ellipsoid.WGS84.maximumRadius;
var frustum = new PerspectiveFrustum();
frustum.fovy = CesiumMath.toRadians(60.0);
frustum.aspectRatio = context.getDrawingBufferWidth() / context.getDrawingBufferHeight();
diff --git a/Specs/Scene/CameraFlightPathSpec.js b/Specs/Scene/CameraFlightPathSpec.js
index 1e1666db38a5..f18ea3a5b97d 100644
--- a/Specs/Scene/CameraFlightPathSpec.js
+++ b/Specs/Scene/CameraFlightPathSpec.js
@@ -29,7 +29,7 @@ defineSuite([
beforeEach(function() {
scene = createScene();
- frameState = scene.getFrameState();
+ frameState = scene.frameState;
});
afterEach(function() {
diff --git a/Specs/Scene/CentralBodySpec.js b/Specs/Scene/CentralBodySpec.js
index e55c1b4c4b52..5eca061a7874 100644
--- a/Specs/Scene/CentralBodySpec.js
+++ b/Specs/Scene/CentralBodySpec.js
@@ -62,7 +62,7 @@ defineSuite([
it('renders with enableLighting', function() {
cb.enableLighting = true;
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
diff --git a/Specs/Scene/CentralBodySurfaceSpec.js b/Specs/Scene/CentralBodySurfaceSpec.js
index 517f05439d70..5cc54f03fe0c 100644
--- a/Specs/Scene/CentralBodySurfaceSpec.js
+++ b/Specs/Scene/CentralBodySurfaceSpec.js
@@ -82,7 +82,7 @@ defineSuite([
function switchTo2D() {
frameState.mode = SceneMode.SCENE2D;
var frustum = new OrthographicFrustum();
- frustum.right = Ellipsoid.WGS84.getMaximumRadius() * Math.PI;
+ frustum.right = Ellipsoid.WGS84.maximumRadius * Math.PI;
frustum.left = -frustum.right;
frustum.top = frustum.right;
frustum.bottom = -frustum.top;
@@ -137,7 +137,7 @@ defineSuite([
describe('layer updating', function() {
it('removing a layer removes it from all tiles', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
var layer = layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
@@ -163,7 +163,7 @@ defineSuite([
});
it('adding a layer adds it to all tiles after update', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
@@ -199,7 +199,7 @@ defineSuite([
});
it('moving a layer moves the corresponding TileImagery instances on every tile', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
var layer1 = layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
@@ -254,7 +254,7 @@ defineSuite([
}, 'WebGL');
it('renders in 2D geographic', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
@@ -269,7 +269,7 @@ defineSuite([
});
it('renders in 2D web mercator', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
@@ -284,7 +284,7 @@ defineSuite([
});
it('renders in Columbus View geographic', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
@@ -299,7 +299,7 @@ defineSuite([
});
it('renders in Columbus View web mercator', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
@@ -314,7 +314,7 @@ defineSuite([
});
it('renders in 3D', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
@@ -328,7 +328,7 @@ defineSuite([
});
it('renders in 3D and then Columbus View', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
@@ -351,7 +351,7 @@ defineSuite([
});
it('renders even if imagery root tiles fail to load', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
var providerWithInvalidRootTiles = new WebMapServiceImageryProvider({
@@ -371,7 +371,7 @@ defineSuite([
});
it('passes layer adjustment values as uniforms', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
var layer = layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
@@ -415,7 +415,7 @@ defineSuite([
});
it('passes functional layer adjustment values as uniforms', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
var layer = layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
@@ -470,7 +470,7 @@ defineSuite([
});
it('skips layer with uniform alpha value of zero', function() {
- var layerCollection = cb.getImageryLayers();
+ var layerCollection = cb.imageryLayerCollection;
layerCollection.removeAll();
var layer = layerCollection.addImageryProvider(new SingleTileImageryProvider({url : 'Data/Images/Red16x16.png'}));
diff --git a/Specs/Scene/CompositePrimitiveSpec.js b/Specs/Scene/CompositePrimitiveSpec.js
index 501ef2743009..3e5afbca3bbf 100644
--- a/Specs/Scene/CompositePrimitiveSpec.js
+++ b/Specs/Scene/CompositePrimitiveSpec.js
@@ -117,13 +117,13 @@ defineSuite([
});
it('has zero primitives when constructed', function() {
- expect(primitives.getLength()).toEqual(0);
+ expect(primitives.length).toEqual(0);
});
it('adds a primitive with add()', function() {
var p = createLabels();
expect(primitives.add(p)).toBe(p);
- expect(primitives.getLength()).toEqual(1);
+ expect(primitives.length).toEqual(1);
});
it('removes the first primitive', function() {
@@ -133,14 +133,14 @@ defineSuite([
primitives.add(p0);
primitives.add(p1);
- expect(primitives.getLength()).toEqual(2);
+ expect(primitives.length).toEqual(2);
expect(primitives.remove(p0)).toEqual(true);
- expect(primitives.getLength()).toEqual(1);
+ expect(primitives.length).toEqual(1);
expect(primitives.get(0)).toBe(p1);
expect(primitives.remove(p1)).toEqual(true);
- expect(primitives.getLength()).toEqual(0);
+ expect(primitives.length).toEqual(0);
});
it('removes the last primitive', function() {
@@ -150,14 +150,14 @@ defineSuite([
primitives.add(p0);
primitives.add(p1);
- expect(primitives.getLength()).toEqual(2);
+ expect(primitives.length).toEqual(2);
expect(primitives.remove(p1)).toEqual(true);
- expect(primitives.getLength()).toEqual(1);
+ expect(primitives.length).toEqual(1);
expect(primitives.get(0)).toBe(p0);
expect(primitives.remove(p0)).toEqual(true);
- expect(primitives.getLength()).toEqual(0);
+ expect(primitives.length).toEqual(0);
});
it('removes a primitive twice', function() {
@@ -177,10 +177,10 @@ defineSuite([
primitives.add(createLabels());
primitives.add(createLabels());
- expect(primitives.getLength()).toEqual(3);
+ expect(primitives.length).toEqual(3);
primitives.removeAll();
- expect(primitives.getLength()).toEqual(0);
+ expect(primitives.length).toEqual(0);
});
it('contains a primitive', function() {
@@ -249,9 +249,9 @@ defineSuite([
it('setting a central body', function() {
var ellipsoid = Ellipsoid.UNIT_SPHERE;
var cb = new CentralBody(ellipsoid);
- primitives.setCentralBody(cb);
+ primitives.centralBody = cb;
- expect(primitives.getCentralBody()).toBe(cb);
+ expect(primitives.centralBody).toBe(cb);
});
it('renders a primitive added with add()', function() {
@@ -467,7 +467,7 @@ defineSuite([
expect(context.readPixels()).toEqual([0, 0, 0, 0]);
var cb = new CentralBody(Ellipsoid.UNIT_SPHERE);
- primitives.setCentralBody(cb);
+ primitives.centralBody = cb;
savedCamera = frameState.camera;
frameState.camera = camera;
@@ -538,13 +538,13 @@ defineSuite([
expect(labels.isDestroyed()).toEqual(true);
});
- it('destroys primitive on setCentralBody', function() {
+ it('destroys primitive on set centralBody', function() {
var cb = new CentralBody(Ellipsoid.UNIT_SPHERE);
- primitives.setCentralBody(cb);
+ primitives.centralBody = cb;
expect(cb.isDestroyed()).toEqual(false);
- primitives.setCentralBody(null);
+ primitives.centralBody = null;
expect(cb.isDestroyed()).toEqual(true);
});
@@ -590,14 +590,14 @@ defineSuite([
expect(labels.isDestroyed()).toEqual(true);
});
- it('does not destroy primitive on setCentralBody', function() {
+ it('does not destroy primitive on set centralBody', function() {
var cb = new CentralBody(Ellipsoid.UNIT_SPHERE);
primitives.destroyPrimitives = false;
- primitives.setCentralBody(cb);
+ primitives.centralBody = cb;
expect(cb.isDestroyed()).toEqual(false);
- primitives.setCentralBody(null);
+ primitives.centralBody = null;
expect(cb.isDestroyed()).toEqual(false);
cb.destroy();
diff --git a/Specs/Scene/DebugModelMatrixPrimitiveSpec.js b/Specs/Scene/DebugModelMatrixPrimitiveSpec.js
index 716d73d82431..135acac30707 100644
--- a/Specs/Scene/DebugModelMatrixPrimitiveSpec.js
+++ b/Specs/Scene/DebugModelMatrixPrimitiveSpec.js
@@ -20,7 +20,7 @@ defineSuite([
beforeAll(function() {
scene = createScene();
- var camera = scene.getCamera();
+ var camera = scene.camera;
camera.position = new Cartesian3(1.02, 0.0, 0.0);
camera.direction = Cartesian3.negate(Cartesian3.UNIT_X);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Z);
@@ -35,7 +35,7 @@ defineSuite([
});
afterEach(function() {
- scene.getPrimitives().removeAll();
+ scene.primitives.removeAll();
});
it('gets the default properties', function() {
@@ -65,26 +65,26 @@ defineSuite([
});
it('renders', function() {
- var p = scene.getPrimitives().add(new DebugModelMatrixPrimitive());
+ var p = scene.primitives.add(new DebugModelMatrixPrimitive());
scene.render();
- expect(scene.getContext().readPixels()).not.toEqual([0, 0, 0, 255]);
+ expect(scene.context.readPixels()).not.toEqual([0, 0, 0, 255]);
// Update and render again
p.length = 100.0;
scene.render();
- expect(scene.getContext().readPixels()).not.toEqual([0, 0, 0, 255]);
+ expect(scene.context.readPixels()).not.toEqual([0, 0, 0, 255]);
});
it('does not render when show is false', function() {
- scene.getPrimitives().add(new DebugModelMatrixPrimitive({
+ scene.primitives.add(new DebugModelMatrixPrimitive({
show : false
}));
scene.render();
- expect(scene.getContext().readPixels()).toEqual([0, 0, 0, 255]);
+ expect(scene.context.readPixels()).toEqual([0, 0, 0, 255]);
});
it('is picked', function() {
- var p = scene.getPrimitives().add(new DebugModelMatrixPrimitive({
+ var p = scene.primitives.add(new DebugModelMatrixPrimitive({
id : 'id'
}));
diff --git a/Specs/Scene/EllipsoidPrimitiveSpec.js b/Specs/Scene/EllipsoidPrimitiveSpec.js
index c0041ebdb2c8..bb61c877c114 100644
--- a/Specs/Scene/EllipsoidPrimitiveSpec.js
+++ b/Specs/Scene/EllipsoidPrimitiveSpec.js
@@ -134,19 +134,19 @@ defineSuite([
it('renders bounding volume with debugShowBoundingVolume', function() {
var scene = createScene();
- scene.getPrimitives().add(new EllipsoidPrimitive({
+ scene.primitives.add(new EllipsoidPrimitive({
radii : new Cartesian3(1.0, 1.0, 1.0),
debugShowBoundingVolume : true
}));
- var camera = scene.getCamera();
+ var camera = scene.camera;
camera.position = new Cartesian3(1.02, 0.0, 0.0);
camera.direction = Cartesian3.negate(Cartesian3.UNIT_X);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Z);
scene.initializeFrame();
scene.render();
- var pixels = scene.getContext().readPixels();
+ var pixels = scene.context.readPixels();
expect(pixels[0]).not.toEqual(0);
expect(pixels[1]).toEqual(0);
expect(pixels[2]).toEqual(0);
diff --git a/Specs/Scene/ExtentPrimitiveSpec.js b/Specs/Scene/ExtentPrimitiveSpec.js
index c99dbd20be16..86c0c4bc6b01 100644
--- a/Specs/Scene/ExtentPrimitiveSpec.js
+++ b/Specs/Scene/ExtentPrimitiveSpec.js
@@ -137,18 +137,18 @@ defineSuite([
it('renders bounding volume with debugShowBoundingVolume', function() {
var scene = createScene();
- scene.getPrimitives().add(createExtent({
+ scene.primitives.add(createExtent({
debugShowBoundingVolume : true
}));
- var camera = scene.getCamera();
+ var camera = scene.camera;
camera.position = new Cartesian3(1.02, 0.0, 0.0);
camera.direction = Cartesian3.negate(Cartesian3.UNIT_X);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Z);
scene.initializeFrame();
scene.render();
- var pixels = scene.getContext().readPixels();
+ var pixels = scene.context.readPixels();
expect(pixels[0]).not.toEqual(0);
expect(pixels[1]).toEqual(0);
expect(pixels[2]).toEqual(0);
diff --git a/Specs/Scene/GeometryRenderingSpec.js b/Specs/Scene/GeometryRenderingSpec.js
index 3e90d7f2aa93..9229677e1c1c 100644
--- a/Specs/Scene/GeometryRenderingSpec.js
+++ b/Specs/Scene/GeometryRenderingSpec.js
@@ -259,7 +259,7 @@ defineSuite([
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0);
var frustum = new OrthographicFrustum();
- frustum.right = ellipsoid.getMaximumRadius() * Math.PI;
+ frustum.right = ellipsoid.maximumRadius * Math.PI;
frustum.left = -frustum.right;
frustum.top = frustum.right;
frustum.bottom = -frustum.top;
diff --git a/Specs/Scene/LabelCollectionSpec.js b/Specs/Scene/LabelCollectionSpec.js
index 0fce4a529c10..9857f2127f3d 100644
--- a/Specs/Scene/LabelCollectionSpec.js
+++ b/Specs/Scene/LabelCollectionSpec.js
@@ -1358,7 +1358,7 @@ defineSuite([
text : 'two'
});
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
var orthoFrustum = new OrthographicFrustum();
orthoFrustum.right = maxRadii * Math.PI;
orthoFrustum.left = -orthoFrustum.right;
diff --git a/Specs/Scene/MoonSpec.js b/Specs/Scene/MoonSpec.js
index 921afb5269fd..064abe0a95f5 100644
--- a/Specs/Scene/MoonSpec.js
+++ b/Specs/Scene/MoonSpec.js
@@ -64,26 +64,26 @@ defineSuite([
scene.initializeFrame();
scene.render();
- var date = scene.getFrameState().time;
- var camera = scene.getCamera();
+ var date = scene.frameState.time;
+ var camera = scene.camera;
lookAtMoon(camera, date);
scene.initializeFrame();
scene.render();
- expect(scene.getContext().readPixels()).toNotEqual([0, 0, 0, 0]);
+ expect(scene.context.readPixels()).toNotEqual([0, 0, 0, 0]);
});
it('does not render when show is false', function() {
var moon = new Moon();
moon.show = false;
- var context = scene.getContext();
+ var context = scene.context;
var frameState = createFrameState(createCamera(context, undefined, undefined, undefined, 1.0, 1.0e10));
var us = context.getUniformState();
us.update(context, frameState);
- lookAtMoon(scene.getCamera(), frameState.time);
+ lookAtMoon(scene.camera, frameState.time);
us.update(context, frameState);
diff --git a/Specs/Scene/MultifrustumSpec.js b/Specs/Scene/MultifrustumSpec.js
index e51c16973433..b7f8e4b9088f 100644
--- a/Specs/Scene/MultifrustumSpec.js
+++ b/Specs/Scene/MultifrustumSpec.js
@@ -57,10 +57,10 @@ defineSuite([
beforeEach(function() {
scene = createScene();
- context = scene.getContext();
- primitives = scene.getPrimitives();
+ context = scene.context;
+ primitives = scene.primitives;
- var camera = scene.getCamera();
+ var camera = scene.camera;
camera.position = new Cartesian3();
camera.direction = Cartesian3.negate(Cartesian3.UNIT_Z);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Y);
@@ -330,7 +330,7 @@ defineSuite([
});
it('does not crash when near plane is greater than or equal to the far plane', function() {
- var camera = scene.getCamera();
+ var camera = scene.camera;
camera.frustum.far = 1000.0;
camera.position = new Cartesian3(0.0, 0.0, 1e12);
diff --git a/Specs/Scene/PickSpec.js b/Specs/Scene/PickSpec.js
index b7ec0b18bd19..6de6f243fe40 100644
--- a/Specs/Scene/PickSpec.js
+++ b/Specs/Scene/PickSpec.js
@@ -38,8 +38,8 @@ defineSuite([
beforeAll(function() {
scene = createScene();
- primitives = scene.getPrimitives();
- camera = scene.getCamera();
+ primitives = scene.primitives;
+ camera = scene.camera;
});
afterAll(function() {
@@ -159,9 +159,9 @@ defineSuite([
});
it('pick in 2D', function() {
- var context = scene.getContext();
+ var context = scene.context;
var ellipsoid = scene.scene2D.projection.getEllipsoid();
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
camera.position = new Cartesian3(0.0, 0.0, 2.0 * maxRadii);
camera.direction = Cartesian3.normalize(Cartesian3.negate(camera.position));
@@ -190,9 +190,9 @@ defineSuite([
});
it('pick in 2D when rotated', function() {
- var context = scene.getContext();
+ var context = scene.context;
var ellipsoid = scene.scene2D.projection.getEllipsoid();
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
camera.position = new Cartesian3(0.0, 0.0, 2.0 * maxRadii);
camera.direction = Cartesian3.normalize(Cartesian3.negate(camera.position));
diff --git a/Specs/Scene/PolygonSpec.js b/Specs/Scene/PolygonSpec.js
index 831b08226845..b4e7da789025 100644
--- a/Specs/Scene/PolygonSpec.js
+++ b/Specs/Scene/PolygonSpec.js
@@ -308,18 +308,18 @@ defineSuite([
it('renders bounding volume with debugShowBoundingVolume', function() {
var scene = createScene();
- scene.getPrimitives().add(createPolygon({
+ scene.primitives.add(createPolygon({
debugShowBoundingVolume : true
}));
- var camera = scene.getCamera();
+ var camera = scene.camera;
camera.position = new Cartesian3(1.02, 0.0, 0.0);
camera.direction = Cartesian3.negate(Cartesian3.UNIT_X);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Z);
scene.initializeFrame();
scene.render();
- var pixels = scene.getContext().readPixels();
+ var pixels = scene.context.readPixels();
expect(pixels[0]).not.toEqual(0);
expect(pixels[1]).toEqual(0);
expect(pixels[2]).toEqual(0);
diff --git a/Specs/Scene/PolylineCollectionSpec.js b/Specs/Scene/PolylineCollectionSpec.js
index 5c8d41c2ba52..8e4bfeeda122 100644
--- a/Specs/Scene/PolylineCollectionSpec.js
+++ b/Specs/Scene/PolylineCollectionSpec.js
@@ -807,7 +807,7 @@ defineSuite([
it('renders bounding volume with debugShowBoundingVolume', function() {
var scene = createScene();
- var p = scene.getPrimitives().add(new PolylineCollection({
+ var p = scene.primitives.add(new PolylineCollection({
debugShowBoundingVolume : true
}));
var material = Material.fromType('Color');
@@ -817,14 +817,14 @@ defineSuite([
material : material
});
- var camera = scene.getCamera();
+ var camera = scene.camera;
camera.position = new Cartesian3(1.02, 0.0, 0.0);
camera.direction = Cartesian3.negate(Cartesian3.UNIT_X);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Z);
scene.initializeFrame();
scene.render();
- expect(scene.getContext().readPixels()).toNotEqual([0, 0, 0, 0]);
+ expect(scene.context.readPixels()).toNotEqual([0, 0, 0, 0]);
destroyScene(scene);
});
diff --git a/Specs/Scene/PrimitiveSpec.js b/Specs/Scene/PrimitiveSpec.js
index 8636bfc697eb..67e6b2cd868b 100644
--- a/Specs/Scene/PrimitiveSpec.js
+++ b/Specs/Scene/PrimitiveSpec.js
@@ -335,7 +335,7 @@ defineSuite([
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0);
var frustum = new OrthographicFrustum();
- frustum.right = Ellipsoid.WGS84.getMaximumRadius() * Math.PI;
+ frustum.right = Ellipsoid.WGS84.maximumRadius * Math.PI;
frustum.left = -frustum.right;
frustum.top = frustum.right;
frustum.bottom = -frustum.top;
@@ -366,16 +366,16 @@ defineSuite([
it('renders bounding volume with debugShowBoundingVolume', function() {
var scene = createScene();
- scene.getPrimitives().add(new Primitive({
+ scene.primitives.add(new Primitive({
geometryInstances : extentInstance1,
appearance : new PerInstanceColorAppearance(),
asynchronous : false,
debugShowBoundingVolume : true
}));
- scene.getCamera().controller.viewExtent(extent1);
+ scene.camera.controller.viewExtent(extent1);
scene.initializeFrame();
scene.render();
- var pixels = scene.getContext().readPixels();
+ var pixels = scene.context.readPixels();
expect(pixels[0]).not.toEqual(0);
expect(pixels[1]).toEqual(0);
expect(pixels[2]).toEqual(0);
diff --git a/Specs/Scene/SceneSpec.js b/Specs/Scene/SceneSpec.js
index 37d014e03ec9..639e5e34ec33 100644
--- a/Specs/Scene/SceneSpec.js
+++ b/Specs/Scene/SceneSpec.js
@@ -50,7 +50,7 @@ defineSuite([
afterEach(function() {
scene.debugCommandFilter = undefined;
- scene.getPrimitives().removeAll();
+ scene.primitives.removeAll();
});
afterAll(function() {
@@ -58,16 +58,15 @@ defineSuite([
});
it('constructor has expected defaults', function() {
- expect(scene.getCanvas()).toBeInstanceOf(HTMLCanvasElement);
- expect(scene.getContext()).toBeInstanceOf(Context);
- expect(scene.getPrimitives()).toBeInstanceOf(CompositePrimitive);
- expect(scene.getCamera()).toBeInstanceOf(Camera);
- expect(scene.getUniformState()).toBeInstanceOf(UniformState);
- expect(scene.getScreenSpaceCameraController()).toBeInstanceOf(ScreenSpaceCameraController);
- expect(scene.getFrameState()).toBeInstanceOf(FrameState);
- expect(scene.getAnimations()).toBeInstanceOf(AnimationCollection);
-
- var contextAttributes = scene.getContext()._gl.getContextAttributes();
+ expect(scene.canvas).toBeInstanceOf(HTMLCanvasElement);
+ expect(scene.context).toBeInstanceOf(Context);
+ expect(scene.primitives).toBeInstanceOf(CompositePrimitive);
+ expect(scene.camera).toBeInstanceOf(Camera);
+ expect(scene.screenSpaceCameraController).toBeInstanceOf(ScreenSpaceCameraController);
+ expect(scene.frameState).toBeInstanceOf(FrameState);
+ expect(scene.animations).toBeInstanceOf(AnimationCollection);
+
+ var contextAttributes = scene.context._gl.getContextAttributes();
// Do not check depth and antialias since they are requests not requirements
expect(contextAttributes.alpha).toEqual(false);
expect(contextAttributes.stencil).toEqual(false);
@@ -89,7 +88,7 @@ defineSuite([
webgl : webglOptions
});
- var contextAttributes = s.getContext()._gl.getContextAttributes();
+ var contextAttributes = s.context._gl.getContextAttributes();
expect(contextAttributes.alpha).toEqual(webglOptions.alpha);
expect(contextAttributes.depth).toEqual(webglOptions.depth);
expect(contextAttributes.stencil).toEqual(webglOptions.stencil);
@@ -103,12 +102,12 @@ defineSuite([
it('draws background color', function() {
scene.initializeFrame();
scene.render();
- expect(scene.getContext().readPixels()).toEqual([0, 0, 0, 255]);
+ expect(scene.context.readPixels()).toEqual([0, 0, 0, 255]);
scene.backgroundColor = Color.BLUE;
scene.initializeFrame();
scene.render();
- expect(scene.getContext().readPixels()).toEqual([0, 0, 255, 255]);
+ expect(scene.context.readPixels()).toEqual([0, 0, 255, 255]);
});
function getMockPrimitive(options) {
@@ -134,7 +133,7 @@ defineSuite([
var event = new Event();
event.addEventListener(spyListener);
- scene.getPrimitives().add(getMockPrimitive({
+ scene.primitives.add(getMockPrimitive({
event : event
}));
@@ -149,7 +148,7 @@ defineSuite([
c.pass = Pass.OPAQUE;
spyOn(c, 'execute');
- scene.getPrimitives().add(getMockPrimitive({
+ scene.primitives.add(getMockPrimitive({
command : c
}));
@@ -168,7 +167,7 @@ defineSuite([
c.pass = Pass.OPAQUE;
spyOn(c, 'execute');
- scene.getPrimitives().add(getMockPrimitive({
+ scene.primitives.add(getMockPrimitive({
command : c
}));
@@ -185,24 +184,24 @@ defineSuite([
c.debugShowBoundingVolume = true;
c.boundingVolume = new BoundingSphere(Cartesian3.ZERO, 7000000.0);
- scene.getPrimitives().add(getMockPrimitive({
+ scene.primitives.add(getMockPrimitive({
command : c
}));
scene.initializeFrame();
scene.render();
- expect(scene.getContext().readPixels()[0]).not.toEqual(0); // Red bounding sphere
+ expect(scene.context.readPixels()[0]).not.toEqual(0); // Red bounding sphere
});
it('debugShowCommands tints commands', function() {
var c = new DrawCommand();
c.execute = function() {};
c.pass = Pass.OPAQUE;
- c.shaderProgram = scene.getContext().getShaderCache().getShaderProgram(
+ c.shaderProgram = scene.context.getShaderCache().getShaderProgram(
'void main() { gl_Position = vec4(1.0); }',
'void main() { gl_FragColor = vec4(1.0); }');
- scene.getPrimitives().add(getMockPrimitive({
+ scene.primitives.add(getMockPrimitive({
command : c
}));
@@ -235,15 +234,15 @@ defineSuite([
});
extentPrimitive2.material.uniforms.color = new Color(0.0, 1.0, 0.0, 0.5);
- var primitives = scene.getPrimitives();
+ var primitives = scene.primitives;
primitives.add(extentPrimitive1);
primitives.add(extentPrimitive2);
- scene.getCamera().controller.viewExtent(extent);
+ scene.camera.controller.viewExtent(extent);
scene.initializeFrame();
scene.render();
- var pixels = scene.getContext().readPixels();
+ var pixels = scene.context.readPixels();
expect(pixels[0]).not.toEqual(0);
expect(pixels[1]).not.toEqual(0);
expect(pixels[2]).toEqual(0);
@@ -252,7 +251,7 @@ defineSuite([
scene.initializeFrame();
scene.render();
- pixels = scene.getContext().readPixels();
+ pixels = scene.context.readPixels();
expect(pixels[0]).not.toEqual(0);
expect(pixels[1]).not.toEqual(0);
expect(pixels[2]).toEqual(0);
@@ -274,15 +273,15 @@ defineSuite([
});
extentPrimitive2.material.uniforms.color = new Color(0.0, 1.0, 0.0, 0.5);
- var primitives = scene.getPrimitives();
+ var primitives = scene.primitives;
primitives.add(extentPrimitive1);
primitives.add(extentPrimitive2);
- scene.getCamera().controller.viewExtent(extent);
+ scene.camera.controller.viewExtent(extent);
scene.initializeFrame();
scene.render();
- var pixels = scene.getContext().readPixels();
+ var pixels = scene.context.readPixels();
expect(pixels[0]).not.toEqual(0);
expect(pixels[1]).toEqual(0);
expect(pixels[2]).toEqual(0);
@@ -291,7 +290,7 @@ defineSuite([
scene.initializeFrame();
scene.render();
- pixels = scene.getContext().readPixels();
+ pixels = scene.context.readPixels();
expect(pixels[0]).not.toEqual(0);
expect(pixels[1]).toEqual(0);
expect(pixels[2]).toEqual(0);
diff --git a/Specs/Scene/SceneTransformsSpec.js b/Specs/Scene/SceneTransformsSpec.js
index b85f20d39a7d..9746b9181782 100644
--- a/Specs/Scene/SceneTransformsSpec.js
+++ b/Specs/Scene/SceneTransformsSpec.js
@@ -42,7 +42,7 @@ defineSuite([
it('returns correct window position', function() {
var ellipsoid = Ellipsoid.WGS84;
- var positionCartographic = ellipsoid.cartesianToCartographic(scene.getCamera().position);
+ var positionCartographic = ellipsoid.cartesianToCartographic(scene.camera.position);
positionCartographic.height = 0.0;
var position = ellipsoid.cartographicToCartesian(positionCartographic);
@@ -56,7 +56,7 @@ defineSuite([
it('returns correct drawing buffer position', function() {
var ellipsoid = Ellipsoid.WGS84;
- var positionCartographic = ellipsoid.cartesianToCartographic(scene.getCamera().position);
+ var positionCartographic = ellipsoid.cartesianToCartographic(scene.camera.position);
positionCartographic.height = 0.0;
var position = ellipsoid.cartographicToCartesian(positionCartographic);
diff --git a/Specs/Scene/ScreenSpaceCameraControllerSpec.js b/Specs/Scene/ScreenSpaceCameraControllerSpec.js
index b0347c027412..715aba0cb06c 100644
--- a/Specs/Scene/ScreenSpaceCameraControllerSpec.js
+++ b/Specs/Scene/ScreenSpaceCameraControllerSpec.js
@@ -95,7 +95,7 @@ defineSuite([
projection : projection
}
};
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
var frustum = new OrthographicFrustum();
frustum.right = maxRadii * Math.PI;
frustum.left = -frustum.right;
@@ -407,7 +407,7 @@ defineSuite([
}
};
- var maxRadii = ellipsoid.getMaximumRadius();
+ var maxRadii = ellipsoid.maximumRadius;
camera.position = new Cartesian3(0.0, 0.0, maxRadii);
camera.direction = Cartesian3.negate(Cartesian3.UNIT_Z);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Y);
@@ -836,7 +836,7 @@ defineSuite([
it('pans with constrained axis other than z-axis', function() {
var frameState = setUp3D();
- camera.position = new Cartesian3(0.0, 2.0 * Ellipsoid.WGS84.getMaximumRadius(), 0.0);
+ camera.position = new Cartesian3(0.0, 2.0 * Ellipsoid.WGS84.maximumRadius, 0.0);
camera.direction = Cartesian3.normalize(Cartesian3.negate(camera.position));
camera.up = Cartesian3.clone(Cartesian3.UNIT_X);
camera.right = Cartesian3.cross(camera.direction, camera.up);
@@ -875,7 +875,7 @@ defineSuite([
it('pans with constrained axis and is tilted', function() {
var frameState = setUp3D();
- camera.position = new Cartesian3(0.0, 2.0 * Ellipsoid.WGS84.getMaximumRadius(), 0.0);
+ camera.position = new Cartesian3(0.0, 2.0 * Ellipsoid.WGS84.maximumRadius, 0.0);
camera.direction = Cartesian3.negate(Cartesian3.normalize(camera.position));
camera.up = Cartesian3.clone(Cartesian3.UNIT_X);
camera.right = Cartesian3.cross(camera.direction, camera.up);
@@ -897,7 +897,7 @@ defineSuite([
it('rotates with constrained axis and is tilted', function() {
var frameState = setUp3D();
- camera.position = new Cartesian3(0.0, 2.0 * Ellipsoid.WGS84.getMaximumRadius(), 0.0);
+ camera.position = new Cartesian3(0.0, 2.0 * Ellipsoid.WGS84.maximumRadius, 0.0);
camera.direction = Cartesian3.negate(Cartesian3.normalize(camera.position));
camera.up = Cartesian3.clone(Cartesian3.UNIT_X);
camera.right = Cartesian3.cross(camera.direction, camera.up);
diff --git a/Specs/Scene/SkyAtmosphereSpec.js b/Specs/Scene/SkyAtmosphereSpec.js
index 123d0549b34f..611e75c8734b 100644
--- a/Specs/Scene/SkyAtmosphereSpec.js
+++ b/Specs/Scene/SkyAtmosphereSpec.js
@@ -39,7 +39,7 @@ defineSuite([
expect(context.readPixels()).toEqual([0, 0, 0, 0]);
var us = context.getUniformState();
- var radii = Ellipsoid.WGS84.getRadii();
+ var radii = Ellipsoid.WGS84.radii;
var frameState = createFrameState(createCamera(
context, new Cartesian3(radii.x * 0.1, 0.0, radii.z * 1.005), new Cartesian3(0.0, 0.0, radii.z * 1.005), Cartesian3.UNIT_Z, 1.0, 20000000.0));
us.update(context, frameState);
@@ -58,7 +58,7 @@ defineSuite([
expect(context.readPixels()).toEqual([0, 0, 0, 0]);
var us = context.getUniformState();
- var radii = Ellipsoid.WGS84.getRadii();
+ var radii = Ellipsoid.WGS84.radii;
var frameState = createFrameState(createCamera(
context, new Cartesian3(radii.x * 0.5, 0.0, radii.z * 1.005), new Cartesian3(0.0, 0.0, radii.z * 1.005), Cartesian3.UNIT_Z, 1.0, 20000000.0));
us.update(context, frameState);
@@ -75,7 +75,7 @@ defineSuite([
s.show = false;
var us = context.getUniformState();
- var radii = Ellipsoid.WGS84.getRadii();
+ var radii = Ellipsoid.WGS84.radii;
var frameState = createFrameState(createCamera(
context, new Cartesian3(radii.x * 0.1, 0.0, radii.z * 1.005), new Cartesian3(0.0, 0.0, radii.z * 1.005), Cartesian3.UNIT_Z, 1.0, 20000000.0));
us.update(context, frameState);
@@ -88,7 +88,7 @@ defineSuite([
var s = new SkyAtmosphere();
var us = context.getUniformState();
- var radii = Ellipsoid.WGS84.getRadii();
+ var radii = Ellipsoid.WGS84.radii;
var frameState = createFrameState(createCamera(
context, new Cartesian3(radii.x * 0.1, 0.0, radii.z * 1.005), new Cartesian3(0.0, 0.0, radii.z * 1.005), Cartesian3.UNIT_Z, 1.0, 20000000.0));
frameState.mode = SceneMode.SCENE2D;
@@ -102,7 +102,7 @@ defineSuite([
var s = new SkyAtmosphere();
var us = context.getUniformState();
- var radii = Ellipsoid.WGS84.getRadii();
+ var radii = Ellipsoid.WGS84.radii;
var frameState = createFrameState(createCamera(
context, new Cartesian3(radii.x * 0.1, 0.0, radii.z * 1.005), new Cartesian3(0.0, 0.0, radii.z * 1.005), Cartesian3.UNIT_Z, 1.0, 20000000.0));
frameState.passes.render = false;
diff --git a/Specs/Scene/SunSpec.js b/Specs/Scene/SunSpec.js
index 055d43c492b7..05e156504905 100644
--- a/Specs/Scene/SunSpec.js
+++ b/Specs/Scene/SunSpec.js
@@ -33,8 +33,8 @@ defineSuite([
scene.initializeFrame();
scene.render();
- var us = scene.getContext().getUniformState();
- var camera = scene.getCamera();
+ var us = scene.context.getUniformState();
+ var camera = scene.camera;
var sunPosition = us.getSunPositionWC();
var cameraPosition = Cartesian3.multiplyByScalar(Cartesian3.normalize(sunPosition), 1e8);
@@ -42,7 +42,7 @@ defineSuite([
scene.initializeFrame();
scene.render();
- expect(scene.getContext().readPixels()).toNotEqual([0, 0, 0, 0]);
+ expect(scene.context.readPixels()).toNotEqual([0, 0, 0, 0]);
});
it('draws in Columbus view', function() {
@@ -52,8 +52,8 @@ defineSuite([
scene.initializeFrame();
scene.render();
- var us = scene.getContext().getUniformState();
- var camera = scene.getCamera();
+ var us = scene.context.getUniformState();
+ var camera = scene.camera;
var sunPosition = us.getSunPositionColumbusView();
var cameraPosition = Cartesian3.multiplyByScalar(Cartesian3.normalize(sunPosition), 1e8);
@@ -61,14 +61,14 @@ defineSuite([
scene.initializeFrame();
scene.render();
- expect(scene.getContext().readPixels()).toNotEqual([0, 0, 0, 0]);
+ expect(scene.context.readPixels()).toNotEqual([0, 0, 0, 0]);
});
it('does not render when show is false', function() {
var sun = new Sun();
sun.show = false;
- var context = scene.getContext();
+ var context = scene.context;
var frameState = createFrameState(createCamera(context, undefined, undefined, undefined, 1.0, 1.0e10));
var us = context.getUniformState();
@@ -89,7 +89,7 @@ defineSuite([
it('does not render in 2D', function() {
var sun = new Sun();
- var context = scene.getContext();
+ var context = scene.context;
var frameState = createFrameState(createCamera(context, undefined, undefined, undefined, 1.0, 1.0e10));
frameState.mode = SceneMode.SCENE2D;
@@ -111,7 +111,7 @@ defineSuite([
it('does not render without a render pass', function() {
var sun = new Sun();
- var context = scene.getContext();
+ var context = scene.context;
var frameState = createFrameState(createCamera(context, undefined, undefined, undefined, 1.0, 1.0e10));
frameState.passes.render = false;
@@ -144,8 +144,8 @@ defineSuite([
scene.initializeFrame();
scene.render();
- var us = scene.getContext().getUniformState();
- var camera = scene.getCamera();
+ var us = scene.context.getUniformState();
+ var camera = scene.camera;
var sunPosition = us.getSunPositionWC();
var cameraPosition = Cartesian3.multiplyByScalar(Cartesian3.normalize(sunPosition), 1e8);
@@ -153,7 +153,7 @@ defineSuite([
scene.initializeFrame();
scene.render();
- expect(scene.getContext().readPixels()).toNotEqual([0, 0, 0, 0]);
+ expect(scene.context.readPixels()).toNotEqual([0, 0, 0, 0]);
});
it('isDestroyed', function() {
diff --git a/Specs/UndefinedProperty.js b/Specs/UndefinedProperty.js
deleted file mode 100644
index 2a525029962d..000000000000
--- a/Specs/UndefinedProperty.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/*global define*/
-define(['../Core/defineProperties'], function(defineProperties) {
- "use strict";
-
- //A Property that always returns undefined.
-
- var UndefinedProperty = function() {
- };
-
- UndefinedProperty.prototype.getValue = function(time, result) {
- return undefined;
- };
-
- return UndefinedProperty;
-});
diff --git a/Specs/Widgets/CesiumInspector/CesiumInspectorSpec.js b/Specs/Widgets/CesiumInspector/CesiumInspectorSpec.js
new file mode 100644
index 000000000000..0891397a1608
--- /dev/null
+++ b/Specs/Widgets/CesiumInspector/CesiumInspectorSpec.js
@@ -0,0 +1,64 @@
+/*global defineSuite*/
+defineSuite([
+ 'Widgets/CesiumInspector/CesiumInspector',
+ 'Scene/CentralBody',
+ 'Core/Ellipsoid',
+ 'Specs/createScene',
+ 'Specs/destroyScene'
+ ], function(
+ CesiumInspector,
+ CentralBody,
+ Ellipsoid,
+ createScene,
+ destroyScene
+ ) {
+ "use strict";
+ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
+
+ var scene;
+ beforeAll(function() {
+ scene = createScene();
+ var ellipsoid = Ellipsoid.UNIT_SPHERE;
+ var cb = new CentralBody(ellipsoid);
+ var primitives = scene.primitives;
+ primitives.centralBody = cb;
+
+ });
+
+ afterAll(function() {
+ destroyScene(scene);
+ });
+
+ it('can create and destroy', function() {
+ var container = document.createElement('div');
+ container.id = 'testContainer';
+ document.body.appendChild(container);
+
+ var widget = new CesiumInspector('testContainer', scene);
+ expect(widget.container).toBe(container);
+ expect(widget.viewModel.scene).toBe(scene);
+ expect(widget.isDestroyed()).toEqual(false);
+ widget.destroy();
+ expect(widget.isDestroyed()).toEqual(true);
+
+ document.body.removeChild(container);
+ });
+
+ it('constructor throws with no element', function() {
+ expect(function() {
+ return new CesiumInspector();
+ }).toThrow();
+ });
+
+ it('constructor throws with string element that does not exist', function() {
+ expect(function() {
+ return new CesiumInspector('does not exist', scene);
+ }).toThrow();
+ });
+
+ it('constructor throws with no scene', function() {
+ expect(function() {
+ return new CesiumInspector(document.body);
+ }).toThrow();
+ });
+});
\ No newline at end of file
diff --git a/Specs/Widgets/CesiumInspector/CesiumInspectorViewModelSpec.js b/Specs/Widgets/CesiumInspector/CesiumInspectorViewModelSpec.js
new file mode 100644
index 000000000000..f0eac18cc4f4
--- /dev/null
+++ b/Specs/Widgets/CesiumInspector/CesiumInspectorViewModelSpec.js
@@ -0,0 +1,232 @@
+/*global defineSuite*/
+defineSuite([
+ 'Widgets/CesiumInspector/CesiumInspectorViewModel',
+ 'Specs/createScene',
+ 'Specs/destroyScene',
+ 'Core/Extent',
+ 'Core/defined',
+ 'Scene/ExtentPrimitive',
+ 'Scene/Tile',
+ 'Scene/WebMercatorTilingScheme',
+ 'Scene/Material',
+ 'Scene/CentralBody',
+ 'Core/Math'
+ ], function(
+ CesiumInspectorViewModel,
+ createScene,
+ destroyScene,
+ Extent,
+ defined,
+ ExtentPrimitive,
+ Tile,
+ WebMercatorTilingScheme,
+ Material,
+ CentralBody,
+ CesiumMath) {
+ "use strict";
+ /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/
+
+ var scene;
+ beforeAll(function() {
+ scene = createScene();
+ });
+
+ afterAll(function() {
+ destroyScene(scene);
+ });
+
+ beforeEach(function() {
+ scene.primitives.centralBody = new CentralBody();
+ scene.initializeFrame();
+ });
+
+ afterEach(function() {
+ scene.primitives.removeAll();
+ });
+
+ it('constructor sets values', function() {
+ var viewModel = new CesiumInspectorViewModel(scene);
+ expect(viewModel.scene).toBe(scene);
+ });
+
+ it('throws if scene is undefined', function() {
+ expect(function() {
+ return new CesiumInspectorViewModel();
+ }).toThrow();
+ });
+
+ it('show frustums', function() {
+ var viewModel = new CesiumInspectorViewModel(scene);
+ viewModel.frustums = true;
+ viewModel.showFrustums();
+ expect(viewModel.scene.debugShowFrustums).toBe(true);
+ setTimeout(function(){
+ viewModel.frustums = false;
+ viewModel.showFrustums();
+ expect(viewModel.scene.debugShowFrustums).toBe(false);
+ }, 250);
+ });
+
+ it('show performance', function() {
+ var viewModel = new CesiumInspectorViewModel(scene);
+ viewModel.performance = true;
+ viewModel.showPerformance();
+ scene.render();
+ var elements = document.getElementsByClassName('cesium-cesiumInspector-performanceDisplay');
+ expect(elements[0].innerHTML).not.toEqual('');
+
+ viewModel.performance = false;
+ viewModel.showPerformance();
+ scene.render();
+ expect(elements[0].innerHTML).toEqual('');
+ });
+
+ it ('primitive bounding sphere', function() {
+ var p = scene.primitives.add(new ExtentPrimitive({
+ extent : new Extent(
+ CesiumMath.toRadians(-110.0),
+ CesiumMath.toRadians(0.0),
+ CesiumMath.toRadians(-90.0),
+ CesiumMath.toRadians(20.0)),
+ rotation : CesiumMath.toRadians(45),
+ material : Material.fromType(Material.ColorType)
+ })
+ );
+ var viewModel = new CesiumInspectorViewModel(scene);
+ scene.render();
+ viewModel.primitive = p;
+ viewModel.primitiveBoundingSphere = true;
+ viewModel.showPrimitiveBoundingSphere();
+ expect(p.debugShowBoundingVolume).toEqual(true);
+
+ viewModel.primitiveBoundingSphere = false;
+ viewModel.showPrimitiveBoundingSphere();
+ scene.render();
+ expect(p.debugShowBoundingVolume).toEqual(false);
+ });
+
+ it ('primitive filter', function() {
+ var p = scene.primitives.add(new ExtentPrimitive({
+ extent : new Extent(
+ CesiumMath.toRadians(-110.0),
+ CesiumMath.toRadians(0.0),
+ CesiumMath.toRadians(-90.0),
+ CesiumMath.toRadians(20.0)),
+ rotation : CesiumMath.toRadians(45),
+ material : Material.fromType(Material.ColorType)
+ })
+ );
+
+ var q = scene.primitives.add(new ExtentPrimitive({
+ extent : new Extent(
+ CesiumMath.toRadians(-10.0),
+ CesiumMath.toRadians(0.0),
+ CesiumMath.toRadians(-9.0),
+ CesiumMath.toRadians(20.0)),
+ material : Material.fromType(Material.ColorType)
+ })
+ );
+
+ var viewModel = new CesiumInspectorViewModel(scene);
+ scene.render();
+ viewModel.primitive = p;
+ viewModel.filterPrimitive = true;
+ viewModel.doFilterPrimitive();
+ expect(defined(scene.debugCommandFilter)).toEqual(true);
+ expect(scene.debugCommandFilter({owner: p})).toEqual(true);
+ expect(scene.debugCommandFilter({owner: q})).toEqual(false);
+
+ viewModel.filterPrimitive = false;
+ viewModel.doFilterPrimitive();
+ expect(defined(scene.debugCommandFilter)).toEqual(false);
+ });
+
+ it ('primitive reference frame', function() {
+ var p = scene.primitives.add(new ExtentPrimitive({
+ extent : new Extent(
+ CesiumMath.toRadians(-110.0),
+ CesiumMath.toRadians(0.0),
+ CesiumMath.toRadians(-90.0),
+ CesiumMath.toRadians(20.0)),
+ rotation : CesiumMath.toRadians(45),
+ material : Material.fromType(Material.ColorType)
+ })
+ );
+ var viewModel = new CesiumInspectorViewModel(scene);
+ scene.render();
+ viewModel.primitive = p;
+ viewModel.primitiveReferenceFrame = true;
+ viewModel.showPrimitiveReferenceFrame();
+ expect(scene.primitives.length).toEqual(2);
+
+ viewModel.primitiveReferenceFrame = false;
+ viewModel.showPrimitiveReferenceFrame();
+ scene.render();
+ expect(scene.primitives.length).toEqual(1);
+ });
+
+ it('show wireframe', function() {
+ var viewModel = new CesiumInspectorViewModel(scene);
+ viewModel.wireframe = true;
+ viewModel.showWireframe();
+ expect(viewModel.scene.primitives.centralBody._surface._debug.wireframe).toBe(true);
+
+ viewModel.wireframe = false;
+ viewModel.showWireframe();
+ expect(viewModel.scene.primitives.centralBody._surface._debug.wireframe).toBe(false);
+ });
+
+ it('suspend updates', function() {
+ var viewModel = new CesiumInspectorViewModel(scene);
+ viewModel.suspendUpdates = true;
+ viewModel.doSuspendUpdates();
+ expect(viewModel.scene.primitives.centralBody._surface._debug.suspendLodUpdate).toBe(true);
+
+ viewModel.suspendUpdates = false;
+ viewModel.doSuspendUpdates();
+ expect(viewModel.scene.primitives.centralBody._surface._debug.suspendLodUpdate).toBe(false);
+ });
+
+ it('show tile coords', function() {
+ var viewModel = new CesiumInspectorViewModel(scene);
+ expect(viewModel.scene.primitives.centralBody.imageryLayerCollection.getLength()).toBe(0);
+
+ viewModel.tileCoordinates = true;
+ viewModel.showTileCoordinates();
+ expect(viewModel.scene.primitives.centralBody.imageryLayerCollection.getLength()).toBe(1);
+
+ viewModel.tileCoordinates = false;
+ viewModel.showTileCoordinates();
+ expect(viewModel.scene.primitives.centralBody.imageryLayerCollection.getLength()).toBe(0);
+ });
+
+ it('show tile bounding sphere', function() {
+ var viewModel = new CesiumInspectorViewModel(scene);
+ var tile = new Tile({tilingScheme : new WebMercatorTilingScheme(), x : 0, y : 0, level : 0});
+ viewModel.tile = tile;
+
+ viewModel.tileBoundingSphere = true;
+ viewModel.showTileBoundingSphere();
+ expect(viewModel.scene.primitives.centralBody._surface._debug.boundingSphereTile).toBe(tile);
+
+ viewModel.tileBoundingSphere = false;
+ viewModel.showTileBoundingSphere();
+ expect(viewModel.scene.primitives.centralBody._surface._debug.boundingSphereTile).toBe(undefined);
+ });
+
+ it('filter tile', function() {
+ var viewModel = new CesiumInspectorViewModel(scene);
+ var tile = new Tile({tilingScheme : new WebMercatorTilingScheme(), x : 0, y : 0, level : 0});
+ viewModel.tile = tile;
+
+ viewModel.filterTile = true;
+ viewModel.doFilterTile();
+ expect(viewModel.scene.primitives.centralBody._surface._tilesToRenderByTextureCount[0][0]).toBe(tile);
+ expect(viewModel.suspendUpdates).toBe(true);
+
+ viewModel.filterTile = false;
+ viewModel.doFilterTile();
+ expect(viewModel.suspendUpdates).toBe(false);
+ });
+
+}, 'WebGL');
\ No newline at end of file
diff --git a/Specs/Widgets/CesiumWidget/CesiumWidgetSpec.js b/Specs/Widgets/CesiumWidget/CesiumWidgetSpec.js
index 148ea6f5015b..6447e9a48d11 100644
--- a/Specs/Widgets/CesiumWidget/CesiumWidgetSpec.js
+++ b/Specs/Widgets/CesiumWidget/CesiumWidgetSpec.js
@@ -99,7 +99,7 @@ defineSuite([
imageryProvider : new TileCoordinatesImageryProvider()
};
widget = new CesiumWidget(container, options);
- var imageryLayers = widget.centralBody.getImageryLayers();
+ var imageryLayers = widget.centralBody.imageryLayerCollection;
expect(imageryLayers.getLength()).toEqual(1);
expect(imageryLayers.get(0).getImageryProvider()).toBe(options.imageryProvider);
});
@@ -108,7 +108,7 @@ defineSuite([
widget = new CesiumWidget(container, {
imageryProvider : false
});
- var imageryLayers = widget.centralBody.getImageryLayers();
+ var imageryLayers = widget.centralBody.imageryLayerCollection;
expect(imageryLayers.getLength()).toEqual(0);
});
@@ -155,7 +155,7 @@ defineSuite([
contextOptions : contextOptions
});
- var context = widget.scene.getContext();
+ var context = widget.scene.context;
var contextAttributes = context._gl.getContextAttributes();
expect(context.options.allowTextureFilterAnisotropic).toEqual(false);
diff --git a/Specs/Widgets/Geocoder/GeocoderViewModelSpec.js b/Specs/Widgets/Geocoder/GeocoderViewModelSpec.js
index a596f9f148aa..cd73c8c8ef09 100644
--- a/Specs/Widgets/Geocoder/GeocoderViewModelSpec.js
+++ b/Specs/Widgets/Geocoder/GeocoderViewModelSpec.js
@@ -68,14 +68,14 @@ defineSuite([
scene : scene
});
- var cameraPosition = scene.getCamera().position;
+ var cameraPosition = scene.camera.position;
viewModel.searchText = '220 Valley Creek Blvd, Exton, PA';
viewModel.search();
waitsFor(function() {
- scene.getAnimations().update();
- var newCameraPosition = scene.getCamera().position;
+ scene.animations.update();
+ var newCameraPosition = scene.camera.position;
return cameraPosition.x !== newCameraPosition.x || cameraPosition.y !== newCameraPosition.y || cameraPosition.z !== newCameraPosition.z;
});
});
diff --git a/Specs/Widgets/Viewer/ViewerSpec.js b/Specs/Widgets/Viewer/ViewerSpec.js
index 551e4b8a9f6e..f53532ee0cd2 100644
--- a/Specs/Widgets/Viewer/ViewerSpec.js
+++ b/Specs/Widgets/Viewer/ViewerSpec.js
@@ -298,7 +298,7 @@ defineSuite([
contextOptions : contextOptions
});
- var context = viewer.scene.getContext();
+ var context = viewer.scene.context;
var contextAttributes = context._gl.getContextAttributes();
expect(context.options.allowTextureFilterAnisotropic).toEqual(false);
@@ -321,8 +321,8 @@ defineSuite([
viewer = new Viewer(container, {
selectedImageryProviderViewModel : testProviderViewModel
});
- expect(viewer.centralBody.getImageryLayers().getLength()).toEqual(1);
- expect(viewer.centralBody.getImageryLayers().get(0).getImageryProvider()).toBe(testProvider);
+ expect(viewer.centralBody.imageryLayerCollection.getLength()).toEqual(1);
+ expect(viewer.centralBody.imageryLayerCollection.get(0).getImageryProvider()).toBe(testProvider);
expect(viewer.baseLayerPicker.viewModel.selectedItem).toBe(testProviderViewModel);
});
@@ -331,8 +331,8 @@ defineSuite([
baseLayerPicker : false,
imageryProvider : testProvider
});
- expect(viewer.centralBody.getImageryLayers().getLength()).toEqual(1);
- expect(viewer.centralBody.getImageryLayers().get(0).getImageryProvider()).toBe(testProvider);
+ expect(viewer.centralBody.imageryLayerCollection.getLength()).toEqual(1);
+ expect(viewer.centralBody.imageryLayerCollection.get(0).getImageryProvider()).toBe(testProvider);
});
it('can set imageryProviderViewModels', function() {
@@ -341,8 +341,8 @@ defineSuite([
viewer = new Viewer(container, {
imageryProviderViewModels : models
});
- expect(viewer.centralBody.getImageryLayers().getLength()).toEqual(1);
- expect(viewer.centralBody.getImageryLayers().get(0).getImageryProvider()).toBe(testProvider);
+ expect(viewer.centralBody.imageryLayerCollection.getLength()).toEqual(1);
+ expect(viewer.centralBody.imageryLayerCollection.get(0).getImageryProvider()).toBe(testProvider);
expect(viewer.baseLayerPicker.viewModel.selectedItem).toBe(testProviderViewModel);
expect(viewer.baseLayerPicker.viewModel.imageryProviderViewModels).toEqual(models);
});
@@ -477,6 +477,36 @@ defineSuite([
expect(viewer.clock.startTime).toEqual(dataSource2.clock.startTime);
});
+ it('updates the clock when the data source changes', function() {
+ var dataSource = new MockDataSource();
+ dataSource.clock = new DynamicClock();
+ dataSource.clock.startTime = JulianDate.fromIso8601('2013-08-01T18:00Z');
+ dataSource.clock.stopTime = JulianDate.fromIso8601('2013-08-21T02:00Z');
+ dataSource.clock.currentTime = JulianDate.fromIso8601('2013-08-02T00:00Z');
+ dataSource.clock.clockRange = ClockRange.CLAMPED;
+ dataSource.clock.clockStep = ClockStep.TICK_DEPENDENT;
+ dataSource.clock.multiplier = 20.0;
+
+ viewer = new Viewer(container);
+ viewer.dataSources.add(dataSource);
+
+ dataSource.clock.startTime = JulianDate.fromIso8601('2014-08-01T18:00Z');
+ dataSource.clock.stopTime = JulianDate.fromIso8601('2014-08-21T02:00Z');
+ dataSource.clock.currentTime = JulianDate.fromIso8601('2014-08-02T00:00Z');
+ dataSource.clock.clockRange = ClockRange.UNBOUNDED;
+ dataSource.clock.clockStep = ClockStep.SYSTEM_CLOCK;
+ dataSource.clock.multiplier = 20.0;
+
+ dataSource.changedEvent.raiseEvent(dataSource);
+
+ expect(viewer.clock.startTime).toEqual(dataSource.clock.startTime);
+ expect(viewer.clock.stopTime).toEqual(dataSource.clock.stopTime);
+ expect(viewer.clock.currentTime).toEqual(dataSource.clock.currentTime);
+ expect(viewer.clock.clockRange).toEqual(dataSource.clock.clockRange);
+ expect(viewer.clock.clockStep).toEqual(dataSource.clock.clockStep);
+ expect(viewer.clock.multiplier).toEqual(dataSource.clock.multiplier);
+ });
+
it('can manually control the clock tracking', function() {
var dataSource1 = new MockDataSource();
dataSource1.clock = new DynamicClock();
diff --git a/Specs/Widgets/Viewer/viewerDynamicObjectMixinSpec.js b/Specs/Widgets/Viewer/viewerDynamicObjectMixinSpec.js
index d049193c8269..4decf4785dd8 100644
--- a/Specs/Widgets/Viewer/viewerDynamicObjectMixinSpec.js
+++ b/Specs/Widgets/Viewer/viewerDynamicObjectMixinSpec.js
@@ -108,12 +108,11 @@ defineSuite([
});
it('throws if selectedObject property already added by another mixin.', function() {
- var viewer = new Viewer(container);
+ viewer = new Viewer(container);
viewer.selectedObject = true;
expect(function() {
viewer.extend(viewerDynamicObjectMixin);
- }).toThrow();
- viewer.destroy();
+ }).toThrowDeveloperError();
});
it('returns to home when a tracked object is removed', function() {
diff --git a/Specs/addDefaultMatchers.js b/Specs/addDefaultMatchers.js
index a54706086f67..b2282248f040 100644
--- a/Specs/addDefaultMatchers.js
+++ b/Specs/addDefaultMatchers.js
@@ -137,7 +137,7 @@ define([
}
return function() {
- return true;
+ return this.isNot ? false : true;
};
}())
};
diff --git a/Specs/destroyScene.js b/Specs/destroyScene.js
index 62fc750f29b7..10019e68a3b9 100644
--- a/Specs/destroyScene.js
+++ b/Specs/destroyScene.js
@@ -9,7 +9,7 @@ define([
function destroyScene(scene) {
if (defined(scene) && !scene.isDestroyed()) {
- var canvas = scene.getCanvas();
+ var canvas = scene.canvas;
scene.destroy();
destroyCanvas(canvas);
}
diff --git a/build.xml b/build.xml
index 1ae7bbbe0dfa..efdd379d7029 100644
--- a/build.xml
+++ b/build.xml
@@ -481,7 +481,7 @@
-
+