klren0312 / daliy_knowledge

知识积累,正确使用方式是watch
21 stars 4 forks source link

cesium 加载本地地球贴图 #722

Open klren0312 opened 1 year ago

klren0312 commented 1 year ago

贴图下载地址: https://zouyaoji.top/vue-cesium/SampleData/images/worldimage.jpg

<!DOCTYPE html>
<html lang="en">

<head>
  <!-- Use correct character set. -->
  <meta charset="utf-8" />
  <!-- Tell IE to use the latest, best version. -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
  <meta name="viewport"
    content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
  <title>Hello World!</title>
  <script src="./Build/CesiumUnminified/Cesium.js"></script>
  <style>
    @import url(./Build/CesiumUnminified/Widgets/widgets.css);

    html,
    body,
    #cesiumContainer {
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
      overflow: hidden;
    }
    .cesium-widget-credits { display: none!important; visibility: hidden!important ; }
  </style>
</head>

<body>
  <div id="cesiumContainer"></div>
  <script>
    const viewer = new Cesium.Viewer('cesiumContainer', {
      shouldAnimate: true,            //展示动画
      baseLayerPicker: false,         //联网获取的贴图
      geocoder: false,                //是否显示地名查找控件
      sceneModePicker: false,         //是否显示投影方式控件
      navigationHelpButton: false,    //是否显示帮助信息控件
      baseLayerPicker: false,         //是否显示图层选择控件
      homeButton: false,              //是否显示Home按钮
      fullscreenButton: false,        //是否显示全屏按钮
    })
    viewer.scene.globe.enableLighting = false
    const layers = viewer.scene.imageryLayers

    const singleTileLayer = Cesium.ImageryLayer.fromProviderAsync(
      Cesium.SingleTileImageryProvider.fromUrl(
        './worldimage.jpg',
      )
    )
    singleTileLayer.brightness = 1.0
    singleTileLayer.contrast = 1.72
    layers.add(singleTileLayer)
  </script>
</body>

</html>