cesium模型定位到tile

15 篇文章 0 订阅

 

 定位到符合条件的tile

模型数据自行处理

  Cesium.Resource.fetchJson({
    url: '../../public/模型/scenetree.json'
  }).then(res => {
    let data = res.scenes[0].children.length
    for (let i = 0; i < data; i++) {
      if (i == 0) {
        res.scenes[0].children[i].children[0].children.forEach(item => {
          dataList.data.push({
            id: item.id,
            name: item.name,
            sphere: item.sphere,
          })
        })
      } else if (i == 1) {
        res.scenes[0].children[i].children.forEach(item => {
          dataList.data.push({
            id: item.id,
            name: item.name,
            sphere: item.sphere,
          })
        })
      }
    }
  })

然后根据名称或者id 遍历数据,操作相机

   dataList.data.forEach(item => {
    if (item.id == val.id) {
      let sphere = item.sphere
      let center = new Cesium.Cartesian3(sphere[0], sphere[1], sphere[2])
      const boundingSphere = new Cesium.BoundingSphere(center, sphere[3])
      viewer.camera.flyToBoundingSphere(boundingSphere, {
        offset: new Cesium.HeadingPitchRange(3.5, -0.5, 200),
        duration: 2,
      })
    }
  })

修改制定tile的颜色

 con = [
            ['${name} ==="227" ', 'color("blue", 0.5)'], //符合条件项
            ['true', 'rgba(255,255,255,0.3)'] //其他项
        ]
        tileset.style = new Cesium.Cesium3DTileStyle({
            color:{
                conditions:con
            }
        })

  • 7
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值