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

Fix billboard entity show/hide #4460

Merged
merged 2 commits into from
Oct 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Change Log
* Added `Rectangle.simpleIntersection`.
* Added the ability to specify retina options, such as `@2x.png`, via the `MapboxImageryProvider` `format` option.
* Removed an unnecessary reprojection of Web Mercator imagery tiles to the Geographic projection on load. This should improve both visual quality and load performance slightly.
* Fix a issue where a billboard entity would not render after toggling the show propery. [#4408](https://github.com/AnalyticalGraphicsInc/cesium/issues/4408)

### 1.26 - 2016-10-03

Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/BillboardVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ define([
}

billboard.show = show;
if (item.textureValue !== textureValue) {
if (!defined(billboard.image) || item.textureValue !== textureValue) {
billboard.image = textureValue;
item.textureValue = textureValue;
}
Expand Down
77 changes: 77 additions & 0 deletions Specs/DataSources/BillboardVisualizerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,83 @@ defineSuite([
});
});

it('Display billboard after toggling show', function() {
var entityCollection = new EntityCollection();
visualizer = new BillboardVisualizer(entityCluster, entityCollection);

var testObject = entityCollection.getOrCreateEntity('test');

var time = JulianDate.now();
var billboard = testObject.billboard = new BillboardGraphics();
var bb;

testObject.position = new ConstantProperty(new Cartesian3(1234, 5678, 9101112));
billboard.show = new ConstantProperty(true);
billboard.color = new ConstantProperty(new Color(0.5, 0.5, 0.5, 0.5));
billboard.image = new ConstantProperty('Data/Images/Blue.png');
billboard.imageSubRegion = new ConstantProperty(new BoundingRectangle(0, 0, 1, 1));
billboard.eyeOffset = new ConstantProperty(new Cartesian3(1.0, 2.0, 3.0));
billboard.scale = new ConstantProperty(12.5);
billboard.rotation = new ConstantProperty(1.5);
billboard.alignedAxis = new ConstantProperty(Cartesian3.UNIT_Z);
billboard.heightReference = new ConstantProperty(HeightReference.CLAMP_TO_GROUND);
billboard.horizontalOrigin = new ConstantProperty(HorizontalOrigin.RIGHT);
billboard.verticalOrigin = new ConstantProperty(VerticalOrigin.TOP);
billboard.pixelOffset = new ConstantProperty(new Cartesian2(3, 2));
billboard.width = new ConstantProperty(15);
billboard.height = new ConstantProperty(5);
billboard.scaleByDistance = new ConstantProperty(new NearFarScalar());
billboard.translucencyByDistance = new ConstantProperty(new NearFarScalar());
billboard.pixelOffsetScaleByDistance = new ConstantProperty(new NearFarScalar(1.0, 0.0, 3.0e9, 0.0));
billboard.sizeInMeters = new ConstantProperty(true);
billboard.distanceDisplayCondition = new ConstantProperty(new DistanceDisplayCondition(10.0, 100.0));

visualizer.update(time);

var billboardCollection = entityCluster._billboardCollection;
expect(billboardCollection.length).toEqual(1);

bb = billboardCollection.get(0);

return pollToPromise(function() {
visualizer.update(time);
return bb.show; //true once the image is loaded.
}).then(function() {
billboard.show = new ConstantProperty(false);

return pollToPromise(function() {
visualizer.update(time);
return !bb.show;
}).then(function() {
billboard.show = new ConstantProperty(true);

return pollToPromise(function() {
visualizer.update(time);
return bb.show;
}).then(function() {
expect(bb.position).toEqual(testObject.position.getValue(time));
expect(bb.color).toEqual(testObject.billboard.color.getValue(time));
expect(bb.eyeOffset).toEqual(testObject.billboard.eyeOffset.getValue(time));
expect(bb.scale).toEqual(testObject.billboard.scale.getValue(time));
expect(bb.rotation).toEqual(testObject.billboard.rotation.getValue(time));
expect(bb.alignedAxis).toEqual(testObject.billboard.alignedAxis.getValue(time));
expect(bb.heightReference).toEqual(testObject.billboard.heightReference.getValue(time));
expect(bb.horizontalOrigin).toEqual(testObject.billboard.horizontalOrigin.getValue(time));
expect(bb.verticalOrigin).toEqual(testObject.billboard.verticalOrigin.getValue(time));
expect(bb.width).toEqual(testObject.billboard.width.getValue(time));
expect(bb.height).toEqual(testObject.billboard.height.getValue(time));
expect(bb.scaleByDistance).toEqual(testObject.billboard.scaleByDistance.getValue(time));
expect(bb.translucencyByDistance).toEqual(testObject.billboard.translucencyByDistance.getValue(time));
expect(bb.pixelOffsetScaleByDistance).toEqual(testObject.billboard.pixelOffsetScaleByDistance.getValue(time));
expect(bb.sizeInMeters).toEqual(testObject.billboard.sizeInMeters.getValue(time));
expect(bb.distanceDisplayCondition).toEqual(testObject.billboard.distanceDisplayCondition.getValue(time));
expect(bb.image).toBeDefined();
expect(bb._imageSubRegion).toEqual(testObject.billboard.imageSubRegion.getValue(time));
});
});
});
});

it('Reuses primitives when hiding one and showing another', function() {
var time = JulianDate.now();
var entityCollection = new EntityCollection();
Expand Down