动态渐变墙

点、线、面、模型、圆、墙、视频面、GIF 标牌等 Cesium 实体图形。下面是该示例的核心 script 片段,供参考学习;完整可运行代码请进入在线 Demo 或查看仓库源码。

在线运行 Demo 全部示例 查看完整源码

示例代码

import * as Cesium from 'cesium'
import { Graphics } from '@/utils/cesiumPluginsExtends/singleImport/Graphics'


export default {
  mounted () {
    this.initMap()
  },
  methods: {
    async initMap () {
      const graphicsObj = new Graphics({
        cesiumGlobal: Cesium,
        containerId: 'cesiumContainer',
        viewerConfig: {
          infoBox: false,
          shouldAnimate: true,
        },
        MapImageryList: []
      })
      this.c_viewer = graphicsObj.viewer;

      this.graphics = graphicsObj.graphics;

      this.graphics.setDefSceneConfig()
      this.graphics.setBloomLightScene()
      let tiles = await Cesium.Cesium3DTileset.fromUrl('static/data/3DTiles/building/tileset.json');
      let tileset = this.c_viewer.scene.primitives.add(tiles)
      tileset.style = new Cesium.Cesium3DTileStyle({
        color: {
          conditions: [
            ["${height} >= 300", "rgba(0, 149, 251, 0.3)"],
            ["${height} >= 200", "rgb(0, 149, 251, 0.3)"],
            ["${height} >= 100", "rgb(0, 149, 251, 0.3)"],
            ["${height} >= 50", "rgb(0, 149, 251, 0.3)"],
            ["${height} >= 25", "rgb(0, 149, 251, 0.3)"],
            ["${height} >= 10", "rgb(0, 149, 251, 0.3)"],
            ["${height} >= 5", "rgb(0, 149, 251, 0.3)"],
            ["true", "rgb(0, 149, 251, 0.3)"]
          ]
        }
      })

      this.flyto();

      this.createModel();
    },
    flyto () {
      this.graphics.flyTo({
        position: { x: -1337132.0092982147, y: 5330611.474631115, z: 3228680.029449292 },
        orientation: {
          heading: Cesium.Math.toRadians(1.0114629015290062),
          pitch: Cesium.Math.toRadians(-23.53661660731824),
          roll: Cesium.Math.toRadians(0.00324596311071617)
        }
      })
    },
    createModel () {
      this.graphics.craeteDynamicShadeWallGraphics({
        positions: Cesium.Cartesian3.fromDegreesArrayHeights([
          104.07263175401185, 30.647622150198725, 500.0,
          104.06369117158526, 30.648834374000277, 500.0,
          104.06437182811021, 30.62274533905387, 500.0,
          104.07463538167119, 30.62285687644371, 500.0,
          104.07263175401185, 30.647622150198725, 500.0
        ]),
      })

    }
  },
  beforeUnmount () {
    this.c_viewer = null;
    this.graphics = null;
  }
}

相关 API

安装:npm install cesium_dev_kit cesium