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>
相关推荐
武帝为此几秒前
【Shell 变量作用域详解】
前端·chrome
henry10101030 分钟前
Deepseek辅助生成的HTML5网页版抄经典《弟子规》
前端·javascript·css·html·html5
少云清35 分钟前
【UI自动化测试】2_web自动化测试 _Selenium环境搭建(重点)
前端·selenium·测试工具·web自动化测试
大模型玩家七七1 小时前
关系记忆不是越完整越好:chunk size 的隐性代价
java·前端·数据库·人工智能·深度学习·算法·oracle
全栈前端老曹1 小时前
【Redis】Pipeline 与性能优化——批量命令处理、提升吞吐量、减少网络延迟
前端·网络·数据库·redis·缓存·性能优化·全栈
一 乐1 小时前
林业资源管理|基于java + vue林业资源管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·林业资源管理系统
扶苏10021 小时前
深入 Vue 3 computed:原理、实战与避坑指南
前端·javascript·vue.js
盛夏绽放2 小时前
流式响应 线上请求出现“待处理”问题
前端·后端·nginx·proxy
weixin199701080162 小时前
虾皮商品详情页前端性能优化实战
前端·性能优化
高德开放平台2 小时前
高德开放平台JS API插件支持WebMCP:重新定义AI与网页交互的新时代
javascript·人工智能·开发者·高德地图