实体位置调整

三维标绘、量算、位置拾取、拖拽与模型位置调整。下面是该示例的核心 script 片段,供参考学习;完整可运行代码请进入在线 Demo 或查看仓库源码。

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

示例代码

import * as Cesium from 'cesium'
import { initCesium } from '@/utils/cesiumPluginsExtends/index'
export default {
  data () {
    return {
      activeId: 'light'
    }
  },
  mounted () {
    this.initMap()
  },
  methods: {
    initMap () {
      const tempData = [
        {
          type: 'UrlTemplateImageryProvider',
          option: {
            url: 'https://webst02.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}',
          }
        }]
      const {
        viewer,
        control,
        graphics
      } = new initCesium(
        {
          cesiumGlobal: Cesium,
          containerId: 'cesiumContainer',
          viewerConfig: {
            infoBox: false,
            shouldAnimate: true,
          },
          extraConfig: {},
          MapImageryList: tempData
        })


      this.c_viewer = viewer;
      this.graphics = graphics;
      this.control = control;
      this.initModel(viewer);

    },
    initModel (viewer) {
      let entity = this.graphics.createBoxGraphics({
        position: Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883, 0.0),
        name: "box",
        box: {
          dimensions: new Cesium.Cartesian3(500.0, 500.0, 500.0),//尺寸,长宽高
          material: new Cesium.ColorMaterialProperty((new Cesium.CallbackProperty(() => {
            return Cesium.Color.WHITE;
          }, false))),
        }
      })
      viewer.flyTo(entity);
      this.control.showEntityOrientationEditPanel({
        elementId: 'cust-gui-box', entity, cb: orientationRes => {
          console.log(orientationRes)
        }
      });
    },
  },
  beforeUnmount () {
    this.c_viewer = null;
    this.control = null;
    this.graphics = null;
  }
}

相关 API

安装:npm install cesium_dev_kit cesium