| @@ -35,7 +35,7 @@ | |||
| "@babel/plugin-proposal-class-properties": "^7.18.6", | |||
| "@babel/plugin-transform-runtime": "^7.21.4", | |||
| "@babel/preset-env": "^7.21.5", | |||
| "@cesium/engine": "^3.0.0", | |||
| "@cesium/engine": "^3.0.1", | |||
| "@rollup/plugin-babel": "^6.0.3", | |||
| "@rollup/plugin-commonjs": "^24.1.0", | |||
| "@rollup/plugin-node-resolve": "^15.0.2", | |||
| @@ -25,10 +25,10 @@ class BaseLayerPicker { | |||
| let imageryLayers = this._globe.imageryLayers | |||
| if (!this._selectedImageryLayer) { | |||
| for (let i = imageryLayer.layers.length - 1; i >= 0; i--) { | |||
| imageryLayers.add( | |||
| new ImageryLayer(imageryLayer.layers[i], imageryLayer.options), | |||
| 0 | |||
| ) | |||
| let layer = imageryLayer.layers[i] | |||
| if (layer) { | |||
| imageryLayers.add(new ImageryLayer(layer, imageryLayer.options), 0) | |||
| } | |||
| } | |||
| } else if ( | |||
| this._selectedImageryLayer && | |||
| @@ -36,10 +36,10 @@ class BaseLayerPicker { | |||
| ) { | |||
| imageryLayers.removeAll() | |||
| for (let i = imageryLayer.layers.length - 1; i >= 0; i--) { | |||
| imageryLayers.add( | |||
| new ImageryLayer(imageryLayer.layers[i], imageryLayer.options), | |||
| 0 | |||
| ) | |||
| let layer = imageryLayer.layers[i] | |||
| if (layer) { | |||
| imageryLayers.add(new ImageryLayer(layer, imageryLayer.options), 0) | |||
| } | |||
| } | |||
| } | |||
| this._selectedImageryLayer = imageryLayer | |||
| @@ -91,6 +91,9 @@ class BaseLayerPicker { | |||
| * @returns {BaseLayerPicker} | |||
| */ | |||
| addTerrainProvider(provider) { | |||
| if (!provider) { | |||
| return this | |||
| } | |||
| this._terrainProviders.push(provider) | |||
| return this | |||
| } | |||
| @@ -755,10 +755,6 @@ Viewer.prototype.resize = function () { | |||
| if (width === this._lastWidth && height === this._lastHeight) { | |||
| return | |||
| } | |||
| let creditLeft = 0 | |||
| let creditBottom = 0 | |||
| this._bottomContainer.style.left = `${creditLeft}px` | |||
| this._bottomContainer.style.bottom = `${creditBottom}px` | |||
| this._lastWidth = width | |||
| this._lastHeight = height | |||
| } | |||
| @@ -181,66 +181,66 @@ class ImageryLayerFactory { | |||
| * @returns {any} | |||
| */ | |||
| static createImageryLayer(type, options) { | |||
| let imageryLayer = undefined | |||
| let promise = undefined | |||
| switch (type) { | |||
| case ImageryType.AMAP: | |||
| imageryLayer = this.createAmapImageryLayer(options) | |||
| promise = this.createAmapImageryLayer(options) | |||
| break | |||
| case ImageryType.BAIDU: | |||
| imageryLayer = this.createBaiduImageryLayer(options) | |||
| promise = this.createBaiduImageryLayer(options) | |||
| break | |||
| case ImageryType.GEO_VIS: | |||
| imageryLayer = this.createGeoVisImageryLayer(options) | |||
| promise = this.createGeoVisImageryLayer(options) | |||
| break | |||
| case ImageryType.GOOGLE: | |||
| imageryLayer = this.createGoogleImageryLayer(options) | |||
| promise = this.createGoogleImageryLayer(options) | |||
| break | |||
| case ImageryType.TDT: | |||
| imageryLayer = this.createTdtImageryLayer(options) | |||
| promise = this.createTdtImageryLayer(options) | |||
| break | |||
| case ImageryType.TENCENT: | |||
| imageryLayer = this.createTencentImageryLayer(options) | |||
| promise = this.createTencentImageryLayer(options) | |||
| break | |||
| case ImageryType.ARCGIS: | |||
| imageryLayer = this.createArcGisImageryLayer(options) | |||
| promise = this.createArcGisImageryLayer(options) | |||
| break | |||
| case ImageryType.BING: | |||
| imageryLayer = this.createBingImageryLayer(options) | |||
| promise = this.createBingImageryLayer(options) | |||
| break | |||
| case ImageryType.OSM: | |||
| imageryLayer = this.createOSMImageryLayer(options) | |||
| promise = this.createOSMImageryLayer(options) | |||
| break | |||
| case ImageryType.SINGLE_TILE: | |||
| imageryLayer = this.createSingleTileImageryLayer(options) | |||
| promise = this.createSingleTileImageryLayer(options) | |||
| break | |||
| case ImageryType.WMS: | |||
| imageryLayer = this.createWMSImageryLayer(options) | |||
| promise = this.createWMSImageryLayer(options) | |||
| break | |||
| case ImageryType.WMTS: | |||
| imageryLayer = this.createWMTSImageryLayer(options) | |||
| promise = this.createWMTSImageryLayer(options) | |||
| break | |||
| case ImageryType.XYZ: | |||
| imageryLayer = this.createXYZImageryLayer(options) | |||
| promise = this.createXYZImageryLayer(options) | |||
| break | |||
| case ImageryType.COORD: | |||
| imageryLayer = this.createCoordImageryLayer(options) | |||
| promise = this.createCoordImageryLayer(options) | |||
| break | |||
| case ImageryType.GRID: | |||
| imageryLayer = this.createGridImageryLayer(options) | |||
| promise = this.createGridImageryLayer(options) | |||
| break | |||
| case ImageryType.MAPBOX: | |||
| imageryLayer = this.createMapboxImageryLayer(options) | |||
| promise = this.createMapboxImageryLayer(options) | |||
| break | |||
| case ImageryType.MAPBOX_STYLE: | |||
| imageryLayer = this.createMapboxStyleImageryLayer(options) | |||
| promise = this.createMapboxStyleImageryLayer(options) | |||
| break | |||
| case ImageryType.TMS: | |||
| imageryLayer = this.createTMSImageryLayer(options) | |||
| promise = this.createTMSImageryLayer(options) | |||
| break | |||
| default: | |||
| break | |||
| } | |||
| return imageryLayer | |||
| return promise | |||
| } | |||
| } | |||
| @@ -9,46 +9,52 @@ class TerrainFactory { | |||
| /** | |||
| * | |||
| * @param options | |||
| * @returns {TerrainProvider} | |||
| * @returns {Promise<EllipsoidTerrainProvider>} | |||
| */ | |||
| static createEllipsoidTerrain(options) { | |||
| return new Cesium.EllipsoidTerrainProvider(options) | |||
| return Promise.resolve(new Cesium.EllipsoidTerrainProvider(options)) | |||
| } | |||
| /** | |||
| * Create url terrain | |||
| * @param options | |||
| * @returns {TerrainProvider} | |||
| * @returns {Promise<CesiumTerrainProvider>} | |||
| */ | |||
| static createUrlTerrain(options) { | |||
| return new Cesium.CesiumTerrainProvider(options) | |||
| return Cesium.CesiumTerrainProvider.fromUrl(options.url, options) | |||
| } | |||
| /** | |||
| * Create google terrain | |||
| * @param options | |||
| * @returns {TerrainProvider} | |||
| * @returns {Promise<GoogleEarthEnterpriseTerrainProvider>} | |||
| */ | |||
| static createGoogleTerrain(options) { | |||
| return new Cesium.GoogleEarthEnterpriseTerrainProvider(options) | |||
| return Cesium.GoogleEarthEnterpriseTerrainProvider.fromUrl( | |||
| options.url, | |||
| options | |||
| ) | |||
| } | |||
| /** | |||
| * Create arcgis terrain | |||
| * @param options | |||
| * @returns {TerrainProvider} | |||
| * @returns {Promise<ArcGISTiledElevationTerrainProvider>} | |||
| */ | |||
| static createArcgisTerrain(options) { | |||
| return new Cesium.ArcGISTiledElevationTerrainProvider(options) | |||
| return Cesium.ArcGISTiledElevationTerrainProvider.fromUrl( | |||
| options.url, | |||
| options | |||
| ) | |||
| } | |||
| /** | |||
| * Create vr terrain | |||
| * @param options | |||
| * @returns {TerrainProvider} | |||
| * @returns {Promise<VRTheWorldTerrainProvider>} | |||
| */ | |||
| static createVRTerrain(options) { | |||
| return new Cesium.VRTheWorldTerrainProvider(options) | |||
| return Cesium.VRTheWorldTerrainProvider.fromUrl(options.url, options) | |||
| } | |||
| /** | |||
| @@ -58,27 +64,27 @@ class TerrainFactory { | |||
| * @returns {any} | |||
| */ | |||
| static createTerrain(type, options) { | |||
| let terrain = undefined | |||
| let promise = undefined | |||
| switch (type) { | |||
| case TerrainType.NONE: | |||
| terrain = this.createEllipsoidTerrain(options) | |||
| promise = this.createEllipsoidTerrain(options) | |||
| break | |||
| case TerrainType.XYZ: | |||
| terrain = this.createUrlTerrain(options) | |||
| promise = this.createUrlTerrain(options) | |||
| break | |||
| case TerrainType.GOOGLE: | |||
| terrain = this.createGoogleTerrain(options) | |||
| promise = this.createGoogleTerrain(options) | |||
| break | |||
| case TerrainType.ARCGIS: | |||
| terrain = this.createArcgisTerrain(options) | |||
| promise = this.createArcgisTerrain(options) | |||
| break | |||
| case TerrainType.VR: | |||
| terrain = this.createVRTerrain(options) | |||
| promise = this.createVRTerrain(options) | |||
| break | |||
| default: | |||
| break | |||
| } | |||
| return terrain | |||
| return promise | |||
| } | |||
| } | |||
| @@ -371,10 +371,13 @@ class Viewer { | |||
| if (!terrain) { | |||
| return this | |||
| } | |||
| this._baseLayerPicker.addTerrainProvider(terrain) | |||
| if (!this._baseLayerPicker.selectedTerrain) { | |||
| this._baseLayerPicker.changeTerrain(0) | |||
| } | |||
| Promise.resolve(terrain).then((t) => { | |||
| this._baseLayerPicker.addTerrainProvider(t) | |||
| if (!this._baseLayerPicker.selectedTerrain) { | |||
| this._baseLayerPicker.changeTerrain(0) | |||
| } | |||
| }) | |||
| return this | |||
| } | |||