supermap iclient3d for cesium中entity使用

目标将西南石油大学部分区域围起来,然后引个标签显示名称,最后弄个飞机绕学校飞(这个时间有点晚了,明天弄)

围墙:

复制代码
  wall:{
                positions:Cesium.Cartesian3.fromDegreesArrayHeights([
            104.173,30.822,500,
            104.178,30.837,500,
            104.19,30.837, 500,
            104.185,30.82,500,
            104.173,30.822,500,
            ]),
            material:Cesium.Color.RED.withAlpha(.4),
            outline: true,
          
            },

线条

复制代码
 polyline:{
                positions:Cesium.Cartesian3.fromDegreesArrayHeights([
                104.18,30.83,0,
                104.18,30.83,1600
            ]),
            material:Cesium.Color.BLUE,
            width:5
            },

标签,这个坐标你需要在外面设定

复制代码
new Cesium.Entity({
            position:Cesium.Cartesian3.fromDegrees(
                104.18,30.83,1650
            ),
            label: {
      text: "好的大学没有围墙!!", 
      font: "14px sans-serif", 
      showBackground: true,
      backgroundColor:new Cesium.Color(50,50,50,.6)
    },
        })

然后就是加载一个飞机,文档里面说了只能gltf格式

飞机的位置也要在写在外面,会和标签重合,所以重新创建一个对象,

模型需要自己下载

复制代码
 var plane=new Cesium.Entity({
            position:Cesium.Cartesian3.fromDegrees(
                104.173,30.822,600
            ),
            model: {
                uri:"src/assets/gltf/plane/scene.gltf",
                minimumPixelSize: 128, //模型最小像素
                maximumScale: 200, //模型最大放大倍数
                },
                orientation:Cesium.Transforms.headingPitchRollQuaternion(
                    Cesium.Cartesian3.fromDegrees(
                104.173,30.822,600
            ),
                new Cesium.HeadingPitchRoll(
                    Cesium.Math.toRadians(-90),    // 设置顺时针旋转的角度值
                    Cesium.Math.toRadians(0),
                    Cesium.Math.toRadians(0)
                )
            )
        })

效果

全部代码

复制代码
<template>
    <div class="PartOneBox">
        <div id="cesiumContainer"></div>
    </div>
</template>

<script setup lang='ts'>
import { ref, reactive,onMounted} from 'vue'

onMounted(async()=>
{
        let viewer = new Cesium.Viewer('cesiumContainer')
        var utc=Cesium.JulianDate.fromDate(new Date("2024/08/26 9:30:00"))
        viewer.clock.currentTime=Cesium.JulianDate.addHours(utc,8,new Cesium.JulianDate())
        var labelImagery = new Cesium.TiandituImageryProvider({
            mapStyle: Cesium.TiandituMapsStyle["IMG_C"],//天地图全球中文注记服务
            token: "你自己申请的" //由天地图官网申请的密钥
        });
   
        viewer.imageryLayers.addImageryProvider(labelImagery);
        viewer.camera.setView({
            destination: Cesium.Cartesian3.fromDegrees(
                104.18,30.83,3500
            )
        })

        var geo  = new Cesium.Entity({
            position:Cesium.Cartesian3.fromDegrees(
                104.18,30.83,1650
            ),
            wall:{
                positions:Cesium.Cartesian3.fromDegreesArrayHeights([
            104.173,30.822,500,
            104.178,30.837,500,
            104.19,30.837, 500,
            104.185,30.82,500,
            104.173,30.822,500,
            ]),
            material:Cesium.Color.RED.withAlpha(.4),
            outline: true,
          
            },
            polyline:{
                positions:Cesium.Cartesian3.fromDegreesArrayHeights([
                104.18,30.83,0,
                104.18,30.83,1600
            ]),
            material:Cesium.Color.BLUE,
            width:5
            },
            label: {
      text: "好的大学没有围墙!!", 
      font: "14px sans-serif", 
      showBackground: true,
      backgroundColor:new Cesium.Color(50,50,50,.6)
    },
        })

        var plane=new Cesium.Entity({
            position:Cesium.Cartesian3.fromDegrees(
                104.173,30.822,600
            ),
            model: {
                uri:"src/assets/gltf/plane/scene.gltf",
                minimumPixelSize: 128, //模型最小像素
                maximumScale: 200, //模型最大放大倍数
                },
                orientation:Cesium.Transforms.headingPitchRollQuaternion(
                    Cesium.Cartesian3.fromDegrees(
                104.173,30.822,600
            ),
                new Cesium.HeadingPitchRoll(
                    Cesium.Math.toRadians(-90),    // 设置这个属性即可(顺时针旋转的角度值)
                    Cesium.Math.toRadians(0),
                    Cesium.Math.toRadians(0)
                )
            )
        })
        viewer.entities.add(geo)
        viewer.entities.add(plane)
})

</script>

<style scoped lang='scss'>
.PartOneBox
{
    width:1200px;
    height:1000px;
    margin:50px auto;
    position:relative;
    .cesiumContainer
    {
        width:100%;
        height:100%;
    }
}


</style>
相关推荐
2501_9209317042 分钟前
React Native鸿蒙跨平台采用ScrollView的horizontal属性实现横向滚动实现特色游戏轮播和分类导航
javascript·react native·react.js·游戏·ecmascript·harmonyos
0思必得02 小时前
[Web自动化] Selenium处理动态网页
前端·爬虫·python·selenium·自动化
东东5163 小时前
智能社区管理系统的设计与实现ssm+vue
前端·javascript·vue.js·毕业设计·毕设
catino3 小时前
图片、文件的预览
前端·javascript
mocoding4 小时前
Flutter 3D 翻转动画flip_card三方库在鸿蒙版天气预报卡片中的实战教程
flutter·3d·harmonyos
2501_920931704 小时前
React Native鸿蒙跨平台实现推箱子游戏,完成玩家移动与箱子推动,当所有箱子都被推到目标位置时,玩家获胜
javascript·react native·react.js·游戏·ecmascript·harmonyos
layman05285 小时前
webpack5 css-loader:从基础到原理
前端·css·webpack
半桔5 小时前
【前端小站】CSS 样式美学:从基础语法到界面精筑的实战宝典
前端·css·html
AI老李5 小时前
PostCSS完全指南:功能/配置/插件/SourceMap/AST/插件开发/自定义语法
前端·javascript·postcss
_OP_CHEN5 小时前
【前端开发之CSS】(一)初识 CSS:网页化妆术的终极指南,新手也能轻松拿捏页面美化!
前端·css·html·网页开发·样式表·界面美化