import * as Cesium from ‘cesium’;
import ‘cesium/Widgets/widgets.css’;
import {message} from “ant-design-vue”;
let viewer = null
Cesium.Ion.defaultAccessToken = ‘eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI1ZDk0ZWM3Mi0wNjliLTRkNjAtYjBkMS0zZWY0OGIxNDIxYzkiLCJpZCI6MjQ0OTEsInNjb3BlcyI6WyJhc3IiLCJnYyJdLCJpYXQiOjE1ODUyOTEwOTd9.11P_WP5Lv-fcvJ4KZFp2onou7_-5fTUAaGavg-T_Aho’
const mapOptions = {
skyAtmosphere: new Cesium.SkyAtmosphere(),
sceneModePicker: false,
baseLayerPicker: false,
homeButton: false, //是否显示home键
animation: false, //是否显示动画控件
geocoder: false, //是否显示地名查找控件 如果设置为true,则无法查询
timeline: false, //是否显示时间线控件
fullscreenButton: false, //是否全屏显示
scene3DOnly: false, //如果设置为true,则所有几何图形以3D模式绘制以节约GPU资源
infoBox: false, //是否显示点击要素之后显示的信息
navigationInstructionsInitiallyVisible: false,
navigationHelpButton: false, //是否显示帮助信息控件
selectionIndicator: false, //是否显示指示器组件
}
class CesiumBase {
constructor(selectorCesium) {
this.containerCesium = document.querySelector(selectorCesium)
}
async initCesium() {
try {
viewer = new Cesium.Viewer(this.containerCesium, mapOptions);
viewer.imageryLayers.get(0).show = false;
const tileSet = await Cesium.Cesium3DTileset.fromIonAssetId(2275207)
viewer.scene.primitives.add(tileSet);
viewer.scene.globe.enableLighting = true;
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(122.461792, 30.423389, 3500.0),
});
} catch (e) {
message.error(e)
}
}
}
export default CesiumBase