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

Add ordering at the DataSource level #6316

Merged
merged 10 commits into from
Mar 20, 2018
Merged

Add ordering at the DataSource level #6316

merged 10 commits into from
Mar 20, 2018

Conversation

hpinkos
Copy link
Contributor

@hpinkos hpinkos commented Mar 9, 2018

This change makes order matter in DataSourceCollection. It only has an effect on ground primitives. All ground primitives from one DataSource render above all ground primitives in a lower DataSource in the same DataSourceCollection

  • Added raise, lower, raiseToTop, lowerToButtom methods in DataSourceCollection
  • Instead of adding everything directly to scene.primitives/scene.groundPrimitives, DataSourceDisplay creates it's own PrimitiveCollections. This is so the order of data sources in the data source collection has a one-to-one mapping with the order of primitives in the primitive collection.
  • When a new data source is added to the data source collection, DataSourceDisplay creates a PrimitiveCollection for all the entities in that data source to use.
  • When the ordering of data sources changes, DataSourceDisplay re-orders the corresponding PrimitiveCollection so the ground primitives layer accordingly
  • Added a Sandcastle example to demonstrate this with CZML

@cesium-concierge
Copy link

Signed CLA is on file.

@hpinkos, thanks for the pull request! Maintainers, we have a signed CLA from @hpinkos, so you can review this at any time.

⚠️ I noticed that CHANGES.md has not been updated. If this change updates the public API in any way, fixes a bug, or makes any non-trivial update, please add a bullet point to CHANGES.md and comment on this pull request so we know it was updated. For more info, see the Pull Request Guidelines.


I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome.

🌍 🌎 🌏


this._dataSourceCollection = dataSourceCollection;
this._scene = scene;
this._primitives = scene.primitives.add(new PrimitiveCollection());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid adding these primitives until at least one data source is added? Otherwise users will always have these two primitives in there app, which is something we try and avoid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, this doesn't get us anything because we add the defaultDataSource in the constructor

Copy link
Contributor

Choose a reason for hiding this comment

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

That's unfortunate. Are you sure there's no way for us to create the primitives but not add them until something is actually added to the scene?

@@ -90,7 +95,7 @@ define([
DataSourceDisplay.defaultVisualizersCallback = function(scene, entityCluster, dataSource) {
var entities = dataSource.entities;
return [new BillboardVisualizer(entityCluster, entities),
new GeometryVisualizer(scene, entities),
new GeometryVisualizer(scene, dataSource),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is another breaking change, correct? (I'm okay with it, just making sure we document it).

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually,why not just pass the primitives and ground primitive collections instead of the dataSource? This keeps it loosely coupled.

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 was trying to cut down on the number of params, but I'm okay passing entites, primitives, groundPrimitives

@mramato
Copy link
Contributor

mramato commented Mar 13, 2018

Works as advertised, those two comments were all I had as far as feedback on the approach. When this is ready for merge I'll do a more thorough review. Thanks @hpinkos!

@hpinkos
Copy link
Contributor Author

hpinkos commented Mar 14, 2018

Ready for a full review

@hpinkos
Copy link
Contributor Author

hpinkos commented Mar 15, 2018

I'll have to figure out why all these tests are failing on travis, they pass locally

@mramato
Copy link
Contributor

mramato commented Mar 15, 2018

No worries, just bump when it's ready and I'll do a full review.

collection.raise(source);
collection.lower(source);
collection.raiseToTop(source);
collection.lowerToBottom(source);
Copy link
Contributor

Choose a reason for hiding this comment

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

We try to avoid uber tests like this that call a whole bunch of functions at once because they are hard to debug when something brakes. If you think this is the best way to test the ordering functionality, we can keep this. But please add comments to each function call indicating what exactly is being tested.

@mramato
Copy link
Contributor

mramato commented Mar 17, 2018

Just those two comments.

@hpinkos
Copy link
Contributor Author

hpinkos commented Mar 19, 2018

@mramato ready

  • Don't add primitives to scene.primitives until either an entity is added to the defaultDataSource or the dataSourceCollection has at least one dataSource
  • Split up specs

@mramato
Copy link
Contributor

mramato commented Mar 20, 2018

Thanks @hpinkos!

@mramato mramato merged commit c268786 into master Mar 20, 2018
@mramato mramato deleted the data-sources-order branch March 20, 2018 00:39
@hpinkos hpinkos restored the data-sources-order branch March 23, 2018 20:26
@hpinkos hpinkos deleted the data-sources-order branch March 23, 2018 20:30
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.

3 participants