| | |
| | | terrain = false, |
| | | layerMode = 0, |
| | | contour = true, |
| | | // flyToContour = false, |
| | | flyToContour = false, |
| | | multiple = 1.4, |
| | | |
| | | dockOptions = {}, |
| | | |
| | | |
| | | |
| | | boundaryColor = '#7FFFD4', |
| | | boundaryChange, |
| | | dockRangeType = 1, |
| | | useDockHeight = false |
| | | } = options |
| | |
| | | this.viewer.clockViewModel.currentTime = Cesium.JulianDate.addHours(utc, 0, new Cesium.JulianDate()) |
| | | |
| | | // 边界,机巢 |
| | | |
| | | this.boundary = useBoundary(this.viewer, { multiple, dockOptions, boundaryChange, boundaryColor, dockRangeType, useDockHeight }) |
| | | this.viewer?.imageryLayers.removeAll() |
| | | this.viewer._cesiumWidget._creditContainer.style.display = 'none' |
| | | handler = new Cesium.ScreenSpaceEventHandler(this.viewer?.scene.canvas) |
| | |
| | | requestWaterMask: true, // 启用水体遮罩效果 |
| | | }).then(terrainProvider => { |
| | | this.viewer.terrainProvider = terrainProvider |
| | | |
| | | options?.terrainInit?.() |
| | | }) |
| | | } catch (error) { |
| | | console.error('地形加载失败:', error) |
| | |
| | | this.viewer.scene.screenSpaceCameraController.maximumZoomDistance = 4500000 |
| | | this.switchLayers(layerMode) |
| | | this.switchFlatMode(flatMode) |
| | | // this.switchContour(contour) |
| | | // flyToContour && this.flyToContour(contour) |
| | | this.switchContour(contour) |
| | | flyToContour && this.flyToContour(contour) |
| | | } |
| | | |
| | | getViewer () { |
| | |
| | | gl = null |
| | | this.viewer?.destroy() // 销毁Viewer实例 |
| | | this.viewer = null |
| | | var cesiumContainer = document.getElementById(this.viewerDom) |
| | | if (cesiumContainer && removeDom) { |
| | | cesiumContainer.remove() // 移除与地图相关的DOM元素 |
| | | this.viewerDom = null |
| | | } |
| | | // var cesiumContainer = document.getElementById(this.viewerDom) |
| | | // if (cesiumContainer && removeDom) { |
| | | // cesiumContainer.remove() // 移除与地图相关的DOM元素 |
| | | // this.viewerDom = null |
| | | // } |
| | | this.viewerDom = null |
| | | } |
| | | } |
| | | |
| | | setShowDock (sns) { |
| | | // this.boundary?.setShowDock(sns) |
| | | this.boundary?.setShowDock(sns) |
| | | } |
| | | |
| | | // 切换轮廓显示 |
| | | // async switchContour (open) { |
| | | // if (open) { |
| | | // await this.boundary?.openContour() |
| | | // } else { |
| | | // this.boundary?.closeContour() |
| | | // } |
| | | // } |
| | | async switchContour (open) { |
| | | if (open) { |
| | | await this.boundary?.openContour() |
| | | |
| | | } else { |
| | | this.boundary?.closeContour() |
| | | } |
| | | } |
| | | // // 飞向轮廓居中 |
| | | // flyToContour () { |
| | | // this.boundary?.flyToBoundary() |
| | | // } |
| | | flyToContour () { |
| | | this.boundary?.flyToBoundary() |
| | | } |
| | | |
| | | // 飞行 flyto |
| | | flyTo (pointOption, time = 4, height = 3000, orientation = {}, complete = () => { }) { |
| | | console.log(pointOption, ) |
| | | if (!pointOption.longitude && !pointOption.latitude) return |
| | | const destination = Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude, height) |
| | | const duration = time |
| | |
| | | Cesium.Cartesian3.subtract(a, this.viewer?.camera.position, a), |
| | | Cesium.Cartesian3.normalize(r, r), |
| | | Cesium.Cartesian3.normalize(a, a)) : (r = c.direction, |
| | | a = h.direction) |
| | | a = h.direction) |
| | | let d = Cesium.Cartesian3.dot(r, a) |
| | | , p = 0 |
| | | return d < 1 && (p = Math.acos(d)), |
| | |
| | | , r = Cesium.Math.acosClamped(-e) |
| | | a > 0 && a > r && (a = r - Cesium.Math.EPSILON4), |
| | | r = Cesium.Math.acosClamped(e), |
| | | a < 0 && -a > r && (a = -r + Cesium.Math.EPSILON4) |
| | | a < 0 && -a > r && (a = -r + Cesium.Math.EPSILON4) |
| | | } |
| | | return a |
| | | } |