MCPcopy Create free account
hub / github.com/Tong89/smartNode / initCesium

Function initCesium

frontend/app.js:536–578  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

534 },
535
536 initCesium() {
537 if (!window.Cesium) {
538 this.cesiumReady = false;
539 return;
540 }
541
542 try {
543 const imageryProvider = new Cesium.TileMapServiceImageryProvider({
544 url: Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII'),
545 });
546
547 this.viewer = new Cesium.Viewer('cesiumContainer', {
548 imageryProvider,
549 animation: false,
550 timeline: false,
551 baseLayerPicker: false,
552 geocoder: false,
553 homeButton: false,
554 sceneModePicker: false,
555 navigationHelpButton: false,
556 fullscreenButton: false,
557 infoBox: false,
558 selectionIndicator: false,
559 requestRenderMode: true,
560 });
561
562 this.viewer.scene.globe.enableLighting = false;
563 this.viewer.scene.backgroundColor = Cesium.Color.fromCssColorString('#1f2b2d');
564 this.viewer.camera.setView({
565 destination: Cesium.Cartesian3.fromDegrees(110, 28, 22000000),
566 });
567
568 this.cesiumReady = true;
569
570 // 若上次选择了 2D 模式,初始化后立即切换
571 if (this.mapMode === '2D') {
572 this.viewer.scene.morphTo2D(0);
573 }
574 } catch (error) {
575 console.warn('Cesium 初始化失败:', error);
576 this.cesiumReady = false;
577 }
578 },
579
580 /**
581 * 在 2D 平面地图与 3D 地球模式之间切换。

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected