1.切换cesium底图为黑色
// 底图const baseLayer = viewer.imageryLayers.get(0);if (baseLayer.show) {baseLayer.show = false;viewer.scene.globe.baseColor = Cesium.Color.BLACK;} else {baseLayer.show = true;}
2.地下模式
async toggleUnderground(item: any) {item.active = !item.active;//前提先把场景上的图层全部移除或者隐藏const viewer = Mars.instance.workspace.viewer;// 底图const baseLayer = viewer.imageryLayers.get(0);if (baseLayer.show) {baseLayer.show = false;viewer.scene.globe.baseColor = Cesium.Color.BLACK;} else {baseLayer.show = true;}if (item.active) {//地下管线数组idlet undergroundpipelinsIds: any = [];let undexGroundFolderName = '/管线三维数据';const res = await axios.get('custom-resource/config.json');if (res?.data && res.data.underGroundLayerFolder) {undexGroundFolderName = res.data.underGroundLayerFolder;}const dataNodeS3MArrays = Mars.instance.workspace.dataNodeManager.findChildren(undexGroundFolderName);if (dataNodeS3MArrays.length > 0) {dataNodeS3MArrays.map((node: any) => {const datanode: any = Mars.instance.workspace.dataNodeManager.find(node.path);if (datanode?.imageryLayer?.id) {undergroundpipelinsIds.push(datanode?.imageryLayer?.id);}});}viewer.scene.layers.layerQueue.forEach((layer: any) => {if (undergroundpipelinsIds.length > 0) {const flag = undergroundpipelinsIds.includes(layer.id);if (!flag) {let style3D = new Cesium.Style3D();style3D.fillForeColor = new Cesium.Color(176 / 255, 216 / 255, 230 / 255, 0.7);layer.style3D = style3D;layer.refresh();}} else {let style3D = new Cesium.Style3D();style3D.fillForeColor = new Cesium.Color(176 / 255, 216 / 255, 230 / 255, 0.7);layer.style3D = style3D;layer.refresh();}return layer;});} else {viewer.scene.layers.layerQueue.forEach((layer: any) => {let style3D = new Cesium.Style3D();layer.style3D = style3D;layer.refresh();return layer;});}}