Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor DynamicScene to use Geometry & Appearances #1444

Merged
merged 100 commits into from
Feb 21, 2014
Merged
Show file tree
Hide file tree
Changes from 96 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
a16cf49
Start of DynamicScene refactor
mramato Jan 23, 2014
c5d0311
Merge branch 'master' into dynamicScene-refactor
mramato Jan 24, 2014
2cabf1b
Ongoing property work.
mramato Jan 27, 2014
82bb800
Ongoing property work.
mramato Jan 27, 2014
9e7a77f
Ongoing property work.
mramato Jan 27, 2014
45567c0
Merge remote-tracking branch 'origin/master' into dynamicScene-refactor
mramato Jan 27, 2014
b65c741
Minor doc update.
mramato Jan 28, 2014
fb5f562
Move properties back into DynamicScene for now.
mramato Jan 28, 2014
dba917e
Get rid of DynamicDirectionsProperty
mramato Jan 28, 2014
f7f2124
Ongoing property work
mramato Jan 28, 2014
f81a552
Ongoing DynamicScene refactor
mramato Jan 29, 2014
0aff771
Fix custom property used for CZML processing.
mramato Jan 29, 2014
14c53f8
Temporarily remove DynamicEllipse visualization.
mramato Jan 29, 2014
f1bf962
Merge remote-tracking branch 'origin/master' into dynamicScene-refactor
mramato Jan 29, 2014
56c6e5d
Everything old is new again
mramato Jan 30, 2014
3ff8489
Ellipse outline support
mramato Jan 30, 2014
cfc5f44
Ongoing geometry work
mramato Jan 31, 2014
8303835
Add support for geometry with materials
mramato Jan 31, 2014
a8a28d8
Add some really rough around the edges dynamic geometry support.
mramato Jan 31, 2014
a3275e4
Add iniitial support for dynamic outlines.
mramato Feb 3, 2014
df72363
Add availability checks.
mramato Feb 3, 2014
4c97425
Add support for DynamicEllipse.numberOfVerticalLines
mramato Feb 3, 2014
6ae8990
Ongoing geometry work
mramato Feb 3, 2014
db93931
Merge remote-tracking branch 'origin/master' into dynamicScene-refactor
mramato Feb 3, 2014
4bef033
Improve material batching to only evaluate time-dynamic attributes.
mramato Feb 3, 2014
6423452
Merge branch 'master' into dynamicScene-refactor
mramato Feb 4, 2014
30043ff
Merge branch 'master' into dynamicScene-refactor
mramato Feb 5, 2014
80179cf
Change property events to be more coarse grained
mramato Feb 5, 2014
9cb4482
Rename `propertyChanged` to `definitionChanged`
mramato Feb 5, 2014
dd396f4
Use `id` property for consistent picking.
mramato Feb 5, 2014
3ff6b18
Ongoing DynamicScene geometry work
mramato Feb 5, 2014
54f1105
Fix static outlines
mramato Feb 6, 2014
1e87c1e
Remove DynamicPolygonVisualizer, replace with PolygonGeometryUpdater
mramato Feb 6, 2014
7c31f79
Fix specs
mramato Feb 6, 2014
9cf4bf8
Replace DynamicEllipsoidVisualizer with EllipsoidGeometryUpdater
mramato Feb 6, 2014
b331eb5
Replace DynamicPolylineVisualizer with PolylineGeometryUpdater
mramato Feb 6, 2014
2cbc5e8
Merge branch 'master' into dynamicScene-refactor
mramato Feb 6, 2014
57634c5
Merge branch 'master' into dynamicScene-refactor
mramato Feb 7, 2014
a7ec717
Merge remote-tracking branch 'origin/master' into dynamicScene-refactor
mramato Feb 8, 2014
fe0efbe
Minor doc cleanup.
mramato Feb 8, 2014
164d7f5
Merge branch 'master' into dynamicScene-refactor
mramato Feb 9, 2014
af95f5f
EllipsoidGeometryUpdater should not use EllipsoidSurfaceAppearance
mramato Feb 10, 2014
4043a15
Fix translucency settings for outlines
mramato Feb 11, 2014
71b1354
Remove uneeded parameter.
mramato Feb 11, 2014
72f327e
Further batch geometry based on open/closed.
mramato Feb 11, 2014
e2fefba
Make static geometry asynchronous.
mramato Feb 11, 2014
30a354f
After discussion, it was decided to use `faceForward : true` everywhere
mramato Feb 11, 2014
2ac9c79
Replace truthy statement with defined.
mramato Feb 12, 2014
1742942
Merge remote-tracking branch 'origin/master' into dynamicScene-refactor
mramato Feb 12, 2014
aa928e0
Remove unecessary call to `defaultValue`
mramato Feb 12, 2014
89cbe0a
Rename Map to AssociativeArray to avoid confusion.
mramato Feb 12, 2014
881d294
Doc and specs for AssociativeArray
mramato Feb 12, 2014
d26103b
Cleanup and specs.
mramato Feb 12, 2014
e2a90bc
Simplify interval based Property objects
mramato Feb 13, 2014
01f0f43
Simplify createDynamicPropertyDescriptor usage
mramato Feb 14, 2014
4ecaf48
Merge remote-tracking branch 'origin/master' into dynamicScene-refactor
mramato Feb 14, 2014
0762685
Minor cleanup.
mramato Feb 14, 2014
4462534
Start defining the GeometryUpdater base interface.
mramato Feb 14, 2014
28f2bcf
Merge branch 'master' into dynamicScene-refactor
mramato Feb 15, 2014
1baddb3
Merge remote-tracking branch 'origin/master' into dynamicScene-refactor
mramato Feb 17, 2014
90ca6bf
Remove GeometryBatchType
mramato Feb 17, 2014
78740a3
Start adding updater specs
mramato Feb 17, 2014
147f5db
First pass at documenting GeometryUpdater & DynamicGeoemtryUpdater.
mramato Feb 17, 2014
78ef735
Merge branch 'master' into dynamicScene-refactor
mramato Feb 17, 2014
6863e5b
Documentation fixes.
mramato Feb 17, 2014
7fa37d4
Merge branch 'master' into dynamicScene-refactor
mramato Feb 17, 2014
4dcd525
Fix some specs I accidentally broke.
mramato Feb 17, 2014
4eeac68
Prefer jasmine.createSpy to spyOn
mramato Feb 18, 2014
46c9ecc
More doc updates
mramato Feb 18, 2014
c2ad052
Ongoing cleanup
mramato Feb 18, 2014
a32e690
Delete VisualizerCollection
mramato Feb 18, 2014
97aaa5c
Merge remote-tracking branch 'origin/master' into dynamicScene-refactor
mramato Feb 18, 2014
34b04d1
Cleanup more documentation.
mramato Feb 18, 2014
cead80d
Clean up material properties and specs.
mramato Feb 18, 2014
efb2f2d
Optimize EllipsoidGeometryUpder when dealing with dynamic radii
mramato Feb 18, 2014
437f6c8
Clean up exception handling
mramato Feb 18, 2014
448a0b1
Merge remote-tracking branch 'origin/master' into dynamicScene-refactor
mramato Feb 18, 2014
6bf3b99
Fix bug in StaticGeometryPerMaterialBatch
mramato Feb 18, 2014
529200f
Merge branch 'master' into dynamicScene-refactor
mramato Feb 19, 2014
355b7c4
Mostly finish up documentation.
mramato Feb 19, 2014
1d68c96
Update CHANGES
mramato Feb 19, 2014
bd1ceae
More specs for GeometryVisualizer.
mramato Feb 19, 2014
b45e794
Back out efb2f2d0af6566b1c4264d9dbe17ce3d034cba31
mramato Feb 19, 2014
1945e7a
Disable asynchronous primitives in DynamicScene
mramato Feb 19, 2014
6d890fa
Add a fast pass for dynamic ellipsoids in 3D mode.
mramato Feb 19, 2014
9f775a2
More specs
mramato Feb 19, 2014
6fbe899
Spec cleanup.
mramato Feb 19, 2014
ec520cd
Fix test
mramato Feb 19, 2014
f6cbd8a
Address review comments
mramato Feb 20, 2014
be622ae
Address additional review comments
mramato Feb 20, 2014
319cf6b
Add missing pragma
mramato Feb 20, 2014
0dd05c7
More updates after review.
mramato Feb 20, 2014
f5b01a9
Extract out Property.isConstant helper function.
mramato Feb 20, 2014
e05b0ec
Clean up PropertyArray & PositionPropertyArray.
mramato Feb 20, 2014
603484e
Fix bad logic due to copy/paste error.
mramato Feb 20, 2014
09eafb0
Fix filename typo. Remove dead code.
mramato Feb 20, 2014
d350459
Add isArray shim
mramato Feb 20, 2014
40c9f85
Minor tweak.
mramato Feb 20, 2014
1f64fde
Fix globals.
mramato Feb 20, 2014
f8e4f70
Add pragma, fix typos.
mramato Feb 21, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ Beta Releases
* `getEllipsoid` -> `ellipsoid`
* `getCameraPosition`, `setCameraPosition` -> `cameraPosition`
* Removed `Scene.getUniformState()`. Use `scene.context.getUniformState()`
* Visualizers no longer create a `dynamicObject` property on the primitives they create. Instead, they set the `id` property that is standard for all primitives.
* The `propertyChanged` on DynamicScene objects has been renamed to `definitionChanged`. Also, the event is now raised in the case of an existing property being modified as well as having a new property assigned (previously only property assignment would raise the event).
* The `visualizerTypes` parameter to the `DataSouceDisplay` has been changed to a callback function that creates an array of visualizer instances.
* `DynamicDirectionsProperty` and `DynamicVertexPositionsProperty` were both removed, they have been superseded by `PropertyArray` and `PropertyPositionArray`, which make it easy for DataSource implementations to create time-dynamic arrays.
* `VisualizerCollection` has been removed. It is superseded by `DataSourceDisplay`.
* `DynamicEllipsoidVisualizer`, `DynamicPolygonVisualizer`, and `DynamicPolylineVisualizer` have been removed. They are superseded by `GeometryVisualizer` and corresponding `GeometryUpdater` implementations; `EllipsoidGeometryUpdater`, `PolygonGeometryUpdater`, `PolylineGeometryUpdater`.
* DynamicScene now makes use of Geometry and Appearances, which provides a tremendous improvements to DataSource visualization (CZML, GeoJSON, etc..). Extruded geometries are now supported and in many use cases performance is now GPU bound.
* Added new `SelectionIndicator` and `InfoBox` widgets to `Viewer`, activated by `viewerDynamicObjectMixin`.
* Fix developer error when zooming in 2D. If the zoom would create an invalid frustum, nothing is done. [#1432](https://github.com/AnalyticalGraphicsInc/cesium/issues/1432)
* `OpenStreetMapImageryProvider` now supports imagery with a minimum level.
Expand All @@ -50,6 +57,12 @@ Beta Releases
* `RequestErrorEvent` now includes the headers that were returned with the error response.
* Added `CesiumInspector` widget for graphics debugging. In Cesium Viewer, it is enabled by using the query parameter `inspector=true`.
* Fixed `WallGeometry` bug that failed by removing positions that were less close together by less than 6 decimal places. [#1483](https://github.com/AnalyticalGraphicsInc/cesium/pull/1483)
* `DynamicEllipse`, `DynamicPolygon`, and `DynamicEllipsoid` now have properties matching their geometry counterpart, i.e. `EllipseGeometry`, `EllipseOutlineGeometry`, etc. These properties are also available in CZML.
* Added a `definitionChanged` event to the `Property` interface as well as most `DynamicScene` objects. This makes it easy for a client to observe when new data is loaded into a property or object.
* Added an `isConstant` property to the `Property` interface. Constant properties do not change in regards to simulation time, i.e. `Property.getValue` will always return the same result for all times.
* `ConstantProperty` is now mutable; it's value can be updated via `ConstantProperty.setValue`.
* Added AssociativeArray, which is a helper class for maintaining a hash of objects that also needs to be iterated often.
* Added `TimeIntervalCollection.getChangedEvent` which returns an event that will be raised whenever intervals are updated.

### b25 - 2014-02-03

Expand Down
80 changes: 72 additions & 8 deletions Source/DynamicScene/ColorMaterialProperty.js
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_colorSubscription is not used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same throughout.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createDynamicPropertyDescriptor actually uses all of the _xxxSubscription variables. I know this is confusing but I define them up-front so that the hidden class doesn't get changed. We can remove all of the _xxxSubscription variables and just let them be added at run-time to make the code cleaner but how much of a performance impact that would be, I don't know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

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.
Expand All @@ -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;
};

Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions Source/DynamicScene/CompositeDynamicObjectCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -116,7 +116,7 @@ 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;
Expand Down
51 changes: 42 additions & 9 deletions Source/DynamicScene/CompositeMaterialProperty.js
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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
Expand All @@ -32,7 +58,7 @@ define([
*/
intervals : {
get : function() {
return this._intervals;
return this._composite._intervals;
}
}
});
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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;
Expand Down
49 changes: 41 additions & 8 deletions Source/DynamicScene/CompositePositionProperty.js
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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
Expand All @@ -37,7 +63,7 @@ define([
*/
intervals : {
get : function() {
return this._intervals;
return this._composite.intervals;
}
},
/**
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down
Loading