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

LabelCollection incorrectly caches clamped position when re-using #5338

Closed
mramato opened this issue May 18, 2017 · 1 comment
Closed

LabelCollection incorrectly caches clamped position when re-using #5338

mramato opened this issue May 18, 2017 · 1 comment

Comments

@mramato
Copy link
Contributor

mramato commented May 18, 2017

The below code:

  1. Creates a label, abc, with a position clamped to ground.
  2. When you press Step 1, it removes the label
  3. When you press Step 2, it adds a new label, abcd, without a position.

The bug is that the second label should not be displayed (because it has no position), but the first 3 letters shows up at the first removed label's position because the glyphs still have a value for _actualClampedPosition. I'm not sure if this is a bug in LabelCollection or a bug in BillboardCollection being exposed via label usage.

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

viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
    url : 'https://assets.agi.com/stk-terrain/world',
    requestWaterMask : true,
    requestVertexNormals : true
});
viewer.scene.globe.depthTestAgainstTerrain = true;

var labels = new Cesium.LabelCollection({scene:viewer.scene});
viewer.scene.primitives.add(labels);

var firstLabel = labels.add({
    position : Cesium.Cartesian3.fromDegrees(0,0),
    text : 'abc',
    font : '24px Helvetica',
    heightReference : Cesium.HeightReference.CLAMP_TO_GROUND
});

Sandcastle.addToolbarButton('Step1', function(){
    labels.remove(firstLabel);
});

Sandcastle.addToolbarButton('Step2', function(){
    var secondlabel = labels.add({
        text : 'defg',
        font : '24px Helvetica',
        heightReference : Cesium.HeightReference.CLAMP_TO_GROUND
    });
});
@mramato
Copy link
Contributor Author

mramato commented May 18, 2017

Definitely a billboard bug, here's a simpler reproduction:

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

var billboards = new Cesium.BillboardCollection({scene: viewer.scene});
viewer.scene.primitives.add(billboards);

var b = billboards.add({
    position : Cesium.Cartesian3.fromDegrees(-75, 45),
    image : '../images/facility.gif',
    heightReference : Cesium.HeightReference.CLAMP_TO_GROUND
});

Sandcastle.addToolbarButton('Set position', function(){
    b.position = Cesium.Cartesian3.ZERO;
});

mramato added a commit that referenced this issue May 18, 2017
Clear the current clamped position if the new position is not clampable.

Fixes #5338
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

1 participant