Cesium 案例分析 --单体化分析(分栋、分层)

Cesium的单体化就我接触过的来说分两种:

1、通过数据内部属性进行单体化:

例如:官网案例(https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=3D%20Tiles%20Feature%20Styling.html&label=All) 

 通过对3dtiles的某个属性进行分段达到分类的目的;

2、矢量面叠加单体化:通过classificationType属性来进行单体化;

步骤:

a:首先添加3dtiles模型

b:绘制矢量面,其中矢量面的坐标可手动绘制,保存;

c:矢量面叠加到3dtiles模型上

d:添加一个移动的面及样式,绑定移动事件,移动时获取当前选中的面的坐标,设定移动面的坐标为当前选中的面;

 

3、promitive添加模型,通过classificationType属性来进行单体化

   参考案例(https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=Classification.html&label=All

步骤:

a:先添加primitve模型

var treeHighlight3 = scene.primitives.add(new Cesium.ClassificationPrimitive({
    geometryInstances : new Cesium.GeometryInstance({
        geometry : new Cesium.EllipsoidGeometry({
            radii : new Cesium.Cartesian3(2.45, 2.45, 3.0)
        }),
        modelMatrix : modelMatrix,
        attributes : {
            color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromCssColorString('#004FFF').withAlpha(0.5)),
            show : new Cesium.ShowGeometryInstanceAttribute(true)
        },
        id : 'volume 3'
    }),
    classificationType : Cesium.ClassificationType.CESIUM_3D_TILE
}));

b:加入鼠标移入事件设定样式

var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
    var pickedObject = scene.pick(movement.endPosition);
    if (Cesium.defined(pickedObject) && Cesium.defined(pickedObject.id)) {
        if (pickedObject.id === currentObjectId) {
            return;
        }

        if (Cesium.defined(currentObjectId)) {
            attributes = currentPrimitive.getGeometryInstanceAttributes(currentObjectId);
            attributes.color = currentColor;
            attributes.show = currentShow;
            currentObjectId = undefined;
            currentPrimitive = undefined;
            currentColor = undefined;
            currentShow = undefined;
        }
    }

    if (Cesium.defined(pickedObject) && Cesium.defined(pickedObject.primitive) && Cesium.defined(pickedObject.id) && Cesium.defined(pickedObject.primitive.getGeometryInstanceAttributes)) {
        currentObjectId = pickedObject.id;
        currentPrimitive = pickedObject.primitive;
        attributes = currentPrimitive.getGeometryInstanceAttributes(currentObjectId);
        currentColor = attributes.color;
        currentShow = attributes.show;
        if (!scene.invertClassification) {
            attributes.color = [255, 0, 255, 128];
        }
        attributes.show = [1];
    } else if (Cesium.defined(currentObjectId)) {
        attributes = currentPrimitive.getGeometryInstanceAttributes(currentObjectId);
        attributes.color = currentColor;
        attributes.show = currentShow;
        currentObjectId = undefined;
        currentPrimitive = undefined;
        currentColor = undefined;
    }
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

目前分层和分栋包括分户的单体化已完成。


Cesium是一种用于三维虚拟地球和地理空间数据可视的开源JavaScript库。要实现建筑物的单体,也就是分栋分层,可以利用Cesium的强大功能。 首先,我们需要获取建筑物的相关数据,包括建筑物的位置、高度、楼层信息等。这些数据可以通过各种途径获得,例如由卫星影像获得建筑物的形状和位置,由地理信息系统获得楼层信息等。 接下来,我们可以使用Cesium的实体对象来表示建筑物的每个分块。可以为每一栋建筑物创建一个实体对象,然后根据楼层信息,为每层创建额外的实体对象。实体对象可以设置其位置、尺寸、颜色等属性来呈现建筑物的外观。 然后,将这些实体对象添加到Cesium的场景中。Cesium的场景是一个三维世界,我们可以将建筑物的实体对象放置在其中的适当位置。在场景中,我们可以调整建筑物的视角、缩放等来观察建筑物的外观。 除了基本的建筑物形状外,我们还可以使用Cesium的高级功能来增添建筑物的细节和交互性。例如,可以为建筑物添加纹理、贴图或其他表面属性,以增加其真实感。同时,我们还可以使用Cesium的交互式功能,例如单击建筑物实体对象时显示详细信息窗口等。 总的来说,利用Cesium库,我们可以以三维的方式实现建筑物的单体,即通过将建筑物分块并添加到Cesium的场景中来呈现建筑物的外观。这种方法可以提供更直观、交互性更强的建筑物展示方式,有助于对建筑物的理解和规划。
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值