| | |
| | | this.handlerRightEvents = { handler: null } |
| | | this.handlerMouseMoveEvents = { handler: null } |
| | | this.viewer = null |
| | | this.terrainProvider = null |
| | | this.terrainLoading = null |
| | | this.terrainEnabled = false |
| | | this.globalBaseMapLayers = [] |
| | | this.boundary = null |
| | | this.init(options) |
| | |
| | | |
| | | this.viewer?.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK) // 禁用双击 |
| | | |
| | | if (terrain) { |
| | | // 使用公司地形 |
| | | Cesium.CesiumTerrainProvider.fromUrl(`${import.meta.env.VITE_APP_TERRAIN_URL}ja_terrain`, { |
| | | requestVertexNormals: true, // 启用地形法线增强立体感 |
| | | requestWaterMask: true, // 启用水体遮罩效果 |
| | | }).then(terrainProvider => { |
| | | this.viewer.terrainProvider = terrainProvider |
| | | terrainLoadCallback?.() |
| | | }) |
| | | } |
| | | this.setTerrainVisible(terrain, terrainLoadCallback) |
| | | |
| | | this.viewer.scene.screenSpaceCameraController.maximumZoomDistance = 4500000 |
| | | this.switchLayers(layerMode) |
| | |
| | | |
| | | getViewer () { |
| | | return this.viewer |
| | | } |
| | | |
| | | async ensureTerrainProvider () { |
| | | if (this.terrainProvider) return this.terrainProvider |
| | | if (this.terrainLoading) return this.terrainLoading |
| | | this.terrainLoading = Cesium.CesiumTerrainProvider.fromUrl( |
| | | `${import.meta.env.VITE_APP_TERRAIN_URL}ja_terrain`, |
| | | { |
| | | requestVertexNormals: true, // 启用地形法线增强立体感 |
| | | requestWaterMask: true, // 启用水体遮罩效果 |
| | | } |
| | | ).then(provider => { |
| | | this.terrainProvider = provider |
| | | return provider |
| | | }) |
| | | return this.terrainLoading |
| | | } |
| | | |
| | | async setTerrainVisible (visible, terrainLoadCallback) { |
| | | if (!this.viewer) return |
| | | if (!visible) { |
| | | this.viewer.terrainProvider = new Cesium.EllipsoidTerrainProvider() |
| | | this.terrainEnabled = false |
| | | return |
| | | } |
| | | try { |
| | | const provider = await this.ensureTerrainProvider() |
| | | if (!this.viewer) return |
| | | this.viewer.terrainProvider = provider |
| | | this.terrainEnabled = true |
| | | terrainLoadCallback?.() |
| | | } catch (error) { |
| | | this.terrainEnabled = false |
| | | } |
| | | } |
| | | |
| | | // 销毁viewer |
| | |
| | | this.viewer?.imageryLayers.remove(imageryLayers) |
| | | } |
| | | } |
| | | } |
| | | } |