Skip to content

地形开挖

框架支持自定义范围进行地形开挖

注意

WARNING

在创建多个地形开挖对象时,可能会出现创建结果无法正常显示的情况,只需要关闭场景深度检测即可

代码实例

vue3 + ts

ts
let map: any
LarkExplorer.ready({
    baseUrl: './dist/resources/',
  }).then(initMap)

function initMap() {
  // 默认谷歌影像地图
  const baseImagery = LarkExplorer.BaseLayer.DefaultTdtImg

  // 默认全球地形
  const baseTerrain = LarkExplorer.BaseLayer.DefaultTerrain

  map = new LarkExplorer.Map('map', baseImagery, baseTerrain)
  initView()
}
const initView = () => {
  map.Navigation.homeCamera = {
    position: {
      x: -2456634.8172948933,
      y: 4562075.945027415,
      z: 3711376.2026013467,
    },
    hpr: {
      heading: 0.10848129477705015,
      pitch: -0.30074066005546096,
      roll: 0.00014002081023090085,
    },
  }
  map.Navigation.homeView()
}


// 深度检测
const boolDepth = ref(true)
watch(boolDepth, (val) => {
  map.Terrain.depthTest = val
})

// 开挖深度
const height = ref(200)
let curItem: any = undefined // 当前开挖对象
const start = () => {
  map.Terrain.TerrainExcavation.startCreate(height.value, function (res: any) {
    curItem = res
    console.log('开挖结果:', res)
  })
}

// 更新
const update = () => {
  if (!curItem) return
  const id = curItem.id
  map.Terrain.TerrainExcavation.updateItem(id, {
    name: '更新对象',
    height: height.value,
  })
}
const removeAll = () => {
  map.Terrain.TerrainExcavation.removeAll()
}

运行效果 更多示例