<script setup>
// import { useBase } from '../BaseMB/hooks/base'

// const { addBaseFacilities } = useBase()

onMounted(() => {
  window.viewer = new Cesium.Viewer('earth-container', {
    selectionIndicator: false,
    animation: false,
    baseLayerPicker: false,
    geocoder: false,
    timeline: false,
    sceneModePicker: false,
    navigationHelpButton: false,
    infoBox: false,
    fullscreenButton: false,
    homeButton: false,
    imageryProvider: new Cesium.UrlTemplateImageryProvider({
      url: 'http://192.168.10.201:2022/api/maptilecache/service/tms/1.0.0/img_globle1to9-PNG-4326@EPSG:4326@png/{z}/{x}/{reverseY}.png',
      // url: 'js/Cesium/Assets/Textures/NaturalEarthII/{z}/{x}/{reverseY}.jpg',
      // url: 'GV/resources/theme/earthTheme/{z}/{x}/{y}.jpg',
      tilingScheme: new Cesium.GeographicTilingScheme(),
    }),

    // imageryProvider: false,
  })
  viewer.camera.setView({
    destination: Cesium.Cartesian3.fromDegrees(117.48, 30.67, 15500000.0),
  })

  viewer.clock.shouldAnimate = true
  viewer.scene.globe.enableLighting = true

  if (Cesium.FeatureDetection.supportsImageRenderingPixelated()) {
    console.log('window.devicePixelRatio', window.devicePixelRatio)
    viewer.resolutionScale = window.devicePixelRatio
  }

  // 开启抗锯齿
  viewer.scene.postProcessStages.fxaa.enabled = true
  viewer.scene.skyBox = new Cesium.SkyBox({
    sources: {
      positiveX: 'GV/resources/theme/skyBox/PositiveX.jpg',
      negativeX: 'GV/resources/theme/skyBox/NegativeX.jpg',
      positiveY: 'GV/resources/theme/skyBox/PositiveY.jpg',
      negativeY: 'GV/resources/theme/skyBox/NegativeY.jpg',
      positiveZ: 'GV/resources/theme/skyBox/PositiveZ.jpg',
      negativeZ: 'GV/resources/theme/skyBox/NegativeZ.jpg',
    },
  })
  // viewer.scene.globe.depthTestAgainstTerrain = true

  // addBaseFacilities()
})
</script>

<template>
  <div
    id="earth-container"
    class="absolute top-0 left-0 bottom-0 right-0"
  ></div>
</template>

<style lang="scss">
.cesium-widget-credits {
  display: none !important;
}
</style>