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

DynamicScene ES5 properties #1132

Merged
merged 47 commits into from
Sep 20, 2013
Merged

DynamicScene ES5 properties #1132

merged 47 commits into from
Sep 20, 2013

Conversation

mramato
Copy link
Contributor

@mramato mramato commented Sep 10, 2013

This change updates all of the DynamicScene graphics objects (DynamicBillboard et al.) to use ES5 properties. It adds the ability to observe each of these objects via the propertyChanged event. CompositeDynamicObjectCollection has been rewritten to actually work in all cases and uses the new features to make that happen. DynamicObjectCollection has also had some API changes to improve usability. Both collections now offer additional notification information for when objects change. I'm not 100% happy with the CompositeDynamicObjectCollection API, so I'm open for suggestions for additional tweaks.

This change also adds the ability to easily specify custom properties on DynamicObject via the addProperty method. This allows for any data source to add custom properties which will then play nice with the compositing and notifications system. This is a precursor to automagically handling custom properties in CZML in a future pull request.

Since ES5 properties are slow, the visualizers currently index into the "private" variables that back the properties. Future pull requests will re-write each of the visualizers in order to take advantage of the new functionality and improve overall performance.

mramato added 30 commits August 28, 2013 16:50
1. Refactor DynamicBillboard to use ES5 properties and raise property changed events.
2. Refactor DynamicObjectCollection to improve the API and event notification.

CompositeDynamicObjectCollection is busted until it is also refactored.
This also involves refactoring DynamicObject to generate proeprty notifications.
This is a huge performance regression until visualizers are optimized.
…hey are refactored. This fixes the performance regression created with last submit.
Remove DynamicObject.subPropertyChanged since it's only used by CompositeDynamicObjectCollection, which will get it's own version.
Some specs failing because of the way we are exposing collections.
Rather than expose a collection property, wrap it so that we can always know when something has changed.
1. Added clone to all DynamicXXX objects because the composite needed it.
2. Add tests for both coarse and fine property compositing.
3. Rename collection methods to remove ambiguity.

Everything should work but we still need tests for the collection level stuff.
Fix DynamicEllipsoid.clone which the test showed did not work.
Also take a first change at updating CHANGES.
var id = dynamicObject.id;
var hash = this._hash;
if (defined(hash[id])) {
throw new DeveloperError('An object with id ' + id + ' already exists in this collection.');
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a RuntimeError, not a DeveloperError.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess I see your point. At some point we need to do a thorough review of all of our exceptions and come up with some rules for when to throw them.

Copy link
Contributor

Choose a reason for hiding this comment

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

My rough rule of thumb: DeveloperError means you coded it wrong, RuntimeError means the data is wrong, and also sort of indicates that you as the developer should be validating the data somehow.

…tCollection instances

Rather than storing a property on the objects themselves, generate a unique key based on the object id, the id of the collection it is in, and the property name.0

Add an `id` property to both DynamicObjectCollection and CompositeDynamicObjectCollection; which is a readonly GUID generated at construction time.
@mramato
Copy link
Contributor Author

mramato commented Sep 19, 2013

@shunter This is ready for another look.

@mramato
Copy link
Contributor Author

mramato commented Sep 19, 2013

@shunter I wasn't sure if there was anything else you needed from me. I'm pretty sure all of your comments have been addressed.

@shunter
Copy link
Contributor

shunter commented Sep 20, 2013

I pushed the spec I showed you that fails because property change listeners clobber object change listeners in certain cases. I suggest changing your keys to something like JSON.stringify([collectionId, dynamicObject.id, propertyName]) which should avoid collisions caused by the input strings.

@mramato
Copy link
Contributor Author

mramato commented Sep 20, 2013

Thanks @shunter good catch. This is now fixed and ready to go.

@mramato
Copy link
Contributor Author

mramato commented Sep 20, 2013

Good to go.

shunter added a commit that referenced this pull request Sep 20, 2013
@shunter shunter merged commit 119b26c into master Sep 20, 2013
@shunter shunter deleted the dynamicScene-es5-properties branch September 20, 2013 19:15
@mramato mramato mentioned this pull request Sep 22, 2013
70 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants