Skip to content

Commit 49b0e80

Browse files
author
Hannah
authored
Merge pull request #6110 from AnalyticalGraphicsInc/billboard-globe-undefined
Fix error with creating billboards without a globe
2 parents 3c9e832 + 3659996 commit 49b0e80

File tree

5 files changed

+77
-5
lines changed

5 files changed

+77
-5
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Change Log
2626
* Only one mesh per node is supported.
2727
* Only one primitive per mesh is supported.
2828
* Fixed a glTF animation bug that caused certain animations to jitter. [#5740](https://github.com/AnalyticalGraphicsInc/cesium/pull/5740)
29+
* Fixed a bug when creating billboard and model entities without a globe. [#6109](https://github.com/AnalyticalGraphicsInc/cesium/pull/6109)
2930
* Updated documentation links to reflect new locations on cesiumjs.org and cesium.com.
3031
* Added support for vertex shader uniforms when `tileset.colorBlendMode` is `MIX` or `REPLACE`. [#5874](https://github.com/AnalyticalGraphicsInc/cesium/pull/5874)
3132

Source/Scene/Billboard.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -950,10 +950,10 @@ define([
950950

951951
Billboard._updateClamping = function(collection, owner) {
952952
var scene = collection._scene;
953-
if (!defined(scene)) {
953+
if (!defined(scene) || !defined(scene.globe)) {
954954
//>>includeStart('debug', pragmas.debug);
955955
if (owner._heightReference !== HeightReference.NONE) {
956-
throw new DeveloperError('Height reference is not supported without a scene.');
956+
throw new DeveloperError('Height reference is not supported without a scene and globe.');
957957
}
958958
//>>includeEnd('debug');
959959
return;

Source/Scene/Model.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3924,10 +3924,10 @@ define([
39243924
}
39253925

39263926
var scene = model._scene;
3927-
if (!defined(scene) || (model.heightReference === HeightReference.NONE)) {
3927+
if (!defined(scene) || !defined(scene.globe) || (model.heightReference === HeightReference.NONE)) {
39283928
//>>includeStart('debug', pragmas.debug);
39293929
if (model.heightReference !== HeightReference.NONE) {
3930-
throw new DeveloperError('Height reference is not supported without a scene.');
3930+
throw new DeveloperError('Height reference is not supported without a scene and globe.');
39313931
}
39323932
//>>includeEnd('debug');
39333933
model._clampedModelMatrix = undefined;

Specs/Scene/BillboardCollectionSpec.js

+41
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,24 @@ defineSuite([
17901790
return deferred.promise;
17911791
});
17921792

1793+
it('can add a billboard without a globe', function() {
1794+
scene.globe = undefined;
1795+
1796+
var billboardsWithoutGlobe = new BillboardCollection({
1797+
scene : scene
1798+
});
1799+
1800+
var position = Cartesian3.fromDegrees(-73.0, 40.0);
1801+
var b = billboardsWithoutGlobe.add({
1802+
position : position
1803+
});
1804+
1805+
scene.renderForSpecs();
1806+
1807+
expect(b.position).toEqual(position);
1808+
expect(b._actualClampedPosition).toBeUndefined();
1809+
});
1810+
17931811
describe('height referenced billboards', function() {
17941812
var billboardsWithHeight;
17951813
beforeEach(function() {
@@ -1917,5 +1935,28 @@ defineSuite([
19171935
b.heightReference = HeightReference.CLAMP_TO_GROUND;
19181936
}).toThrowDeveloperError();
19191937
});
1938+
1939+
it('height reference without a globe rejects', function() {
1940+
scene.globe = undefined;
1941+
1942+
expect(function() {
1943+
return billboardsWithHeight.add({
1944+
heightReference : HeightReference.CLAMP_TO_GROUND,
1945+
position : Cartesian3.fromDegrees(-72.0, 40.0)
1946+
});
1947+
}).toThrowDeveloperError();
1948+
});
1949+
1950+
it('changing height reference without a globe throws DeveloperError', function() {
1951+
var b = billboardsWithHeight.add({
1952+
position : Cartesian3.fromDegrees(-72.0, 40.0)
1953+
});
1954+
1955+
scene.globe = undefined;
1956+
1957+
expect(function() {
1958+
b.heightReference = HeightReference.CLAMP_TO_GROUND;
1959+
}).toThrowDeveloperError();
1960+
});
19201961
});
19211962
}, 'WebGL');

Specs/Scene/ModelSpec.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -2947,7 +2947,7 @@ defineSuite([
29472947
position : Cartesian3.fromDegrees(-72.0, 40.0),
29482948
show : true
29492949
}).otherwise(function(error) {
2950-
expect(error.message).toEqual('Height reference is not supported without a scene.');
2950+
expect(error.message).toEqual('Height reference is not supported without a scene and globe.');
29512951
});
29522952
});
29532953

@@ -2962,6 +2962,36 @@ defineSuite([
29622962
expect(function () {
29632963
return scene.renderForSpecs();
29642964
}).toThrowDeveloperError();
2965+
2966+
primitives.remove(model);
2967+
});
2968+
});
2969+
2970+
it('height reference without a globe rejects', function() {
2971+
scene.globe = undefined;
2972+
return loadModelJson(texturedBoxModel.gltf, {
2973+
heightReference : HeightReference.CLAMP_TO_GROUND,
2974+
position : Cartesian3.fromDegrees(-72.0, 40.0),
2975+
scene : scene,
2976+
show : true
2977+
}).otherwise(function(error) {
2978+
expect(error.message).toEqual('Height reference is not supported without a scene and globe.');
2979+
});
2980+
});
2981+
2982+
it('changing height reference without a globe throws DeveloperError', function() {
2983+
scene.globe = undefined;
2984+
return loadModelJson(texturedBoxModel.gltf, {
2985+
position : Cartesian3.fromDegrees(-72.0, 40.0),
2986+
show : true
2987+
}).then(function(model) {
2988+
model.heightReference = HeightReference.CLAMP_TO_GROUND;
2989+
2990+
expect(function () {
2991+
return scene.renderForSpecs();
2992+
}).toThrowDeveloperError();
2993+
2994+
primitives.remove(model);
29652995
});
29662996
});
29672997
});

0 commit comments

Comments
 (0)