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 globe baselayer error #12274

Merged
merged 10 commits into from
Nov 15, 2024
7 changes: 6 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

- Fix label rendering bug in WebGL1 contexts. [#12301](https://github.com/CesiumGS/cesium/pull/12301)

#### @cesium/widgets

##### Fixes :wrench:

- Added a `DeveloperError` when `globe` is set to `false` and a `baseLayer` is provided in `Viewer` options. This prevents errors caused by attempting to use a `baseLayer` without a globe. [#12274](https://github.com/CesiumGS/cesium/pull/12274)

### 1.123.1 - 2024-11-07

#### @cesium/engine
Expand Down Expand Up @@ -54,7 +60,6 @@

- Fix flickering issue caused by bounding sphere retrieval being blocked by the bounding sphere of another entity. [#12230](https://github.com/CesiumGS/cesium/pull/12230)
- Fixed `ImageBasedLighting.imageBasedLightingFactor` not affecting lighting. [#12129](https://github.com/CesiumGS/cesium/pull/12129)

- Fix error with normalization of corner points for lines and corridors with collinear points. [#12255](https://github.com/CesiumGS/cesium/pull/12255)

### 1.122 - 2024-10-01
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Javier Sanchez](https://github.com/jvrjsanchez)
- [Jérôme Fayot](https://github.com/jfayot)
- [Kirn Kim](https://github.com/squrki)
- [Emanuele Mastaglia](https://github.com/Masty88)
12 changes: 11 additions & 1 deletion packages/widgets/Source/Viewer/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ function enableVRUI(viewer, enabled) {
* @property {ProviderViewModel[]} [imageryProviderViewModels=createDefaultImageryProviderViewModels()] The array of ProviderViewModels to be selectable from the BaseLayerPicker. This value is only valid if `baseLayerPicker` is set to true.
* @property {ProviderViewModel} [selectedTerrainProviderViewModel] The view model for the current base terrain layer, if not supplied the first available base layer is used. This value is only valid if `baseLayerPicker` is set to true.
* @property {ProviderViewModel[]} [terrainProviderViewModels=createDefaultTerrainProviderViewModels()] The array of ProviderViewModels to be selectable from the BaseLayerPicker. This value is only valid if `baseLayerPicker` is set to true.
* @property {ImageryLayer|false} [baseLayer=ImageryLayer.fromWorldImagery()] The bottommost imagery layer applied to the globe. If set to <code>false</code>, no imagery provider will be added. This value is only valid if `baseLayerPicker` is set to false.
* @property {ImageryLayer|false} [baseLayer=ImageryLayer.fromWorldImagery()] The bottommost imagery layer applied to the globe. If set to <code>false</code>, no imagery provider will be added. This value is only valid if `baseLayerPicker` is set to false. Cannot be used when `globe` is set to false.
* @property {Ellipsoid} [ellipsoid = Ellipsoid.default] The default ellipsoid.
* @property {TerrainProvider} [terrainProvider=new EllipsoidTerrainProvider()] The terrain provider to use
* @property {Terrain} [terrain] A terrain object which handles asynchronous terrain provider. Can only specify if options.terrainProvider is undefined.
Expand Down Expand Up @@ -402,6 +402,16 @@ function Viewer(container, options) {
container = getElement(container);
options = defaultValue(options, defaultValue.EMPTY_OBJECT);

//>>includeStart('debug', pragmas.debug);
Masty88 marked this conversation as resolved.
Show resolved Hide resolved
if (
options.globe === false &&
defined(options.baseLayer) &&
options.baseLayer !== false
) {
throw new DeveloperError("Cannot use baseLayer when globe is disabled.");
}
//>>includeEnd('debug')

const createBaseLayerPicker =
(!defined(options.globe) || options.globe !== false) &&
(!defined(options.baseLayerPicker) || options.baseLayerPicker !== false);
Expand Down
17 changes: 17 additions & 0 deletions packages/widgets/Specs/Viewer/ViewerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,23 @@ describe(
);
});

it("throws when baseLayer is provided with globe: false", function () {
expect(function () {
viewer = createViewer(container, {
globe: false,
baseLayer: new ImageryLayer(testProvider),
});
}).toThrowDeveloperError();
});

it("does not throw when globe is false and baseLayer is not provided", function () {
expect(function () {
viewer = createViewer(container, {
globe: false,
});
}).not.toThrowDeveloperError();
});

it("can set baseLayer to false when BaseLayerPicker is disabled", function () {
viewer = createViewer(container, {
baseLayerPicker: false,
Expand Down