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 error with creating billboards without a globe #6110

Merged
merged 5 commits into from
Jan 11, 2018
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 @@ -26,6 +26,7 @@ Change Log
* Only one mesh per node is supported.
* Only one primitive per mesh is supported.
* Fixed a glTF animation bug that caused certain animations to jitter. [#5740](https://github.com/AnalyticalGraphicsInc/cesium/pull/5740)
* Fixed a bug when creating billboard and model entities without a globe. [#6109](https://github.com/AnalyticalGraphicsInc/cesium/pull/6109)
* Updated documentation links to reflect new locations on cesiumjs.org and cesium.com.
* Added support for vertex shader uniforms when `tileset.colorBlendMode` is `MIX` or `REPLACE`. [#5874](https://github.com/AnalyticalGraphicsInc/cesium/pull/5874)

Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/Billboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -950,10 +950,10 @@ define([

Billboard._updateClamping = function(collection, owner) {
var scene = collection._scene;
if (!defined(scene)) {
if (!defined(scene) || !defined(scene.globe)) {
//>>includeStart('debug', pragmas.debug);
if (owner._heightReference !== HeightReference.NONE) {
throw new DeveloperError('Height reference is not supported without a scene.');
throw new DeveloperError('Height reference is not supported without a scene and globe.');
}
//>>includeEnd('debug');
return;
Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3924,10 +3924,10 @@ define([
}

var scene = model._scene;
if (!defined(scene) || (model.heightReference === HeightReference.NONE)) {
if (!defined(scene) || !defined(scene.globe) || (model.heightReference === HeightReference.NONE)) {
//>>includeStart('debug', pragmas.debug);
if (model.heightReference !== HeightReference.NONE) {
throw new DeveloperError('Height reference is not supported without a scene.');
throw new DeveloperError('Height reference is not supported without a scene and globe.');
}
//>>includeEnd('debug');
model._clampedModelMatrix = undefined;
Expand Down
41 changes: 41 additions & 0 deletions Specs/Scene/BillboardCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,24 @@ defineSuite([
return deferred.promise;
});

it('can add a billboard without a globe', function() {
scene.globe = undefined;

var billboardsWithoutGlobe = new BillboardCollection({
scene : scene
});

var position = Cartesian3.fromDegrees(-73.0, 40.0);
var b = billboardsWithoutGlobe.add({
position : position
});

scene.renderForSpecs();

expect(b.position).toEqual(position);
expect(b._actualClampedPosition).toBeUndefined();
});

describe('height referenced billboards', function() {
var billboardsWithHeight;
beforeEach(function() {
Expand Down Expand Up @@ -1917,5 +1935,28 @@ defineSuite([
b.heightReference = HeightReference.CLAMP_TO_GROUND;
}).toThrowDeveloperError();
});

it('height reference without a globe rejects', function() {
scene.globe = undefined;

expect(function() {
return billboardsWithHeight.add({
heightReference : HeightReference.CLAMP_TO_GROUND,
position : Cartesian3.fromDegrees(-72.0, 40.0)
});
}).toThrowDeveloperError();
});

it('changing height reference without a globe throws DeveloperError', function() {
var b = billboardsWithHeight.add({
position : Cartesian3.fromDegrees(-72.0, 40.0)
});

scene.globe = undefined;

expect(function() {
b.heightReference = HeightReference.CLAMP_TO_GROUND;
}).toThrowDeveloperError();
});
});
}, 'WebGL');
32 changes: 31 additions & 1 deletion Specs/Scene/ModelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2947,7 +2947,7 @@ defineSuite([
position : Cartesian3.fromDegrees(-72.0, 40.0),
show : true
}).otherwise(function(error) {
expect(error.message).toEqual('Height reference is not supported without a scene.');
expect(error.message).toEqual('Height reference is not supported without a scene and globe.');
});
});

Expand All @@ -2962,6 +2962,36 @@ defineSuite([
expect(function () {
return scene.renderForSpecs();
}).toThrowDeveloperError();

primitives.remove(model);
});
});

it('height reference without a globe rejects', function() {
scene.globe = undefined;
return loadModelJson(texturedBoxModel.gltf, {
heightReference : HeightReference.CLAMP_TO_GROUND,
position : Cartesian3.fromDegrees(-72.0, 40.0),
scene : scene,
show : true
}).otherwise(function(error) {
expect(error.message).toEqual('Height reference is not supported without a scene and globe.');
});
});

it('changing height reference without a globe throws DeveloperError', function() {
scene.globe = undefined;
return loadModelJson(texturedBoxModel.gltf, {
position : Cartesian3.fromDegrees(-72.0, 40.0),
show : true
}).then(function(model) {
model.heightReference = HeightReference.CLAMP_TO_GROUND;

expect(function () {
return scene.renderForSpecs();
}).toThrowDeveloperError();

primitives.remove(model);
});
});
});
Expand Down