Cesium倾斜模型单体化

Cesium倾斜模型单体化

前言

目前Cesium三维项目很多是使用倾斜摄影模型,但是倾斜模型只是一张好看的皮,不能进行交互操作,所以需要后期实现单体化功能,单体化有很多种,比如楼栋单体化、分层单体化、更细的有分户单体化。

实现效果

在这里插入图片描述

实现思路

倾斜模型单体化需要数据结合代码来实现,数据生产需要采集每层的面坐标串等信息。有了数据后在Cesium中通过Entity的方式渲染出来。

关键代码

 //处理查询结果
    handleQueryResult(result) {
        //清除上一次结果
        this.clearQueryResult();
        //如果查询成功 那么返回的结果应该是一个geojson对象 类型为FeatureCollection
        let feature = result.features[0]; //取第一个要素
        if (!feature) return;
        let geometry = feature.geometry; //取要素的几何对象
        let properties = feature.properties; //取要素的属性信息
        let coordinates;
        let pointArr = [];
        if (geometry.type == "MultiPolygon") { //多面 房屋面一般不会出现空洞等现象 如果有需要另做处理
            coordinates = geometry.coordinates[0][0];
        } else if (geometry.type == "Polygon") {
            coordinates = geometry.coordinates[0];
        }

        for (let i = 0; i < coordinates.length; i++) {
            const element = coordinates[i];
            pointArr.push(element[0]);
            pointArr.push(element[1]);
            pointArr.push(0);
        }
        this.addClampFeature(pointArr);
        this.showBuildInfo(properties)
    },

    //添加贴地对象
    addClampFeature(pointArr) {
        this.clampFeature = this.viewer.entities.add({
            polygon: {
                hierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights(pointArr)),
                classificationType: Cesium.ClassificationType.CESIUM_3D_TILE,
                material: Cesium.Color.RED.withAlpha(0.5)
            }
        })
    },

详情参见 Cesium实战专栏

  • 1
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xt3d

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值