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

Billboards in custom data source are not initially clustered #4536

Closed
rutsky opened this issue Oct 27, 2016 · 5 comments
Closed

Billboards in custom data source are not initially clustered #4536

rutsky opened this issue Oct 27, 2016 · 5 comments

Comments

@rutsky
Copy link
Contributor

rutsky commented Oct 27, 2016

Custom data source with set of billboards and with enabled clustering is not clustered initially.

Take a look at the following example in Sandcastle:

var viewer = new Cesium.Viewer('cesiumContainer');

var image = new Image();
image.onload = function() {
    var dataSource = new Cesium.CustomDataSource('points');

    for (var i = 0; i !== 5000; i++) {
      dataSource.entities.add({
          position: Cesium.Cartesian3.fromDegrees(Math.random() * 360 - 180, Math.random() * 180 - 90, 0),
          billboard: {
            image: image
          }
        }
      );
    }

    dataSource.clustering.pixelRange = 20;
    dataSource.clustering.minimumClusterSize = 3;
    dataSource.clustering.enabled = true;

    viewer.dataSources.add(dataSource);
};
image.src = '../images/facility.gif';

Here is how it looks like after running:

2016-10-27_17 57 08_1

This stays for indefinite time, and only if I navigate (zoom or rotate) Earth for a few seconds billboards are being clustered:

2016-10-27_17 59 06_1

Datasource with only labels is being clustered initially normally.

@mramato
Copy link
Member

mramato commented Oct 27, 2016

Thanks for the bug report and isolated test case @rutsky. I can confirm this problem and it definitely only happens with billboards. Hopefully @bagnell will have time to look into it soon.

@billwritescode
Copy link

billwritescode commented Nov 16, 2016

Changing the pixel range in a timeout seems to help until a fix is in:

var viewer = new Cesium.Viewer('cesiumContainer');
var image = new Image();

var dataSource = new Cesium.CustomDataSource('points');

dataSource.clustering.pixelRange = 20;
dataSource.clustering.minimumClusterSize = 3;
dataSource.clustering.enabled = true;

viewer.dataSources.add(dataSource);

var forceCluster = function() {
dataSource.clustering.pixelRange = 0;
dataSource.clustering.pixelRange = 20;
};

image.onload = function() {

for (var i = 0; i !== 5000; i++) {
    dataSource.entities.add({
        position: Cesium.Cartesian3.fromDegrees(Math.random() * 360 - 180, Math.random() * 180 - 90, 0),
        billboard: {
            image: image
           }
     });

}

setTimeout(forceCluster, 200);

};
image.src = '../images/facility.gif';

http://cesiumjs.org/Cesium/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=6a09e40ba8f38fca1e29f97d07441679

@billwritescode
Copy link

billwritescode commented Mar 23, 2017

@bagnell and @mramato, thanks for looking into this.

I've seen similar issues where the _clusterDirty flag is not getting set appropriately, and this can lead to issues such as this. One hack is the above one with changing the pixelrange. But one thing that would be cleaner is exposing _cluster to the API, perhaps via a wrapper like this:

/**
 * Forces a recluster
 * @memberof EntityCluster.prototype
 * @type {Function}
 */
cluster : {
    get : function() {
        return this.enabled ? this._clusterDirty = true && this._cluster : function() {};
    }
}

Are there any plans to support this or a similar "force to cluster" function on the API?

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 18, 2017

Thanks again for the report and code example, @rutsky.

This was fixed in #5208.

@rutsky
Copy link
Contributor Author

rutsky commented Apr 18, 2017

@bagnell @pjcozzi Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants