【cesium-3】cesium建筑体添加和使用

发布时间:2023年12月26日
Cesium.Ion.defaultAccessToken ='';
        
const viewer = new Cesium.Viewer('cesiumContainer',{
    baseLayerPicker:false,
    terrainProvider: await Cesium.createWorldTerrainAsync({
        requestWaterMask: true,
        requestVertexNormals: true
   }),
});

const tileset = viewer.scene.primitives.add(
    await Cesium.Cesium3DTileset.fromIonAssetId(96188)
);

viewer.scene.camera.setView({
    destination:Cesium.Cartesian3.fromDegrees(121.49,31.23,3000),
    orientation:{
       heading:0,
       pitch:-90,
       roll:0
    }
})

//模型数据样式修改
tileset.style = new Cesium.Cesium3DTileStyle({
    color:"color('blue',0.5)",
    show:true
})

?根据建筑物高度显示颜色

Cesium.Ion.defaultAccessToken = '';

const viewer = new Cesium.Viewer('cesiumContainer', {
    baseLayerPicker: false,
    terrainProvider: await Cesium.createWorldTerrainAsync({
        requestWaterMask: true,
        requestVertexNormals: true
    }),
});

const tileset = viewer.scene.primitives.add(
    await Cesium.Cesium3DTileset.fromIonAssetId(75343)
);

viewer.camera.setView({
    destination: new Cesium.Cartesian3(1333597.29, -4667718.24, 4147626.344),
    orientation: {
        heading: 0.8,
        pitch: -1.2,
        roll: 0
    }
})

tileset.style = new Cesium.Cesium3DTileStyle({
    color: {
        conditions: [
            ['${Height} >= 300', 'color("yellow", 0.4)'],
            ['${Height} >= 100', 'color("purple", 0.5)'],
            ['${Height} >= 50', 'color("red")'],
            ['true', 'color("blue")']
        ]
    },
    show: '${Height} > 0',
    meta: {
        description: '"Building id ${id} has height ${Height}."'
    }
});

文章来源:https://blog.csdn.net/WXG1011/article/details/135214479
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。