cesium在地形上贴地添加各种entity

news2024/10/5 22:22:50

目录

添加带标签的点

 添加billboard

添加corridor

 添加面polygon

 添加带图片的面polygon

 添加矩形

添加glb模型

 被遮挡的线用其他颜色标注

添加贴地线


官方示例:Cesium Sandcastlehttps://sandcastle.cesium.com/?src=Clamp%20to%20Terrain.html&label=Tutorials 

添加带标签的点

<template>
  <div style="height: 100vh">
    <div id="cesiumContainer" />
  </div>
</template>

<script>
export default {
  name: "test",
  data() {
    return {};
  },
  mounted() {
    const viewer = new Cesium.Viewer("cesiumContainer", {
      terrainProvider: Cesium.createWorldTerrain(),
    });
    viewer.scene.globe.depthTestAgainstTerrain = true;

    const e = viewer.entities.add({
      position: Cesium.Cartesian3.fromDegrees(-122.1958, 46.1915),
      point: {
        color: Cesium.Color.SKYBLUE,
        pixelSize: 10,
        outlineColor: Cesium.Color.YELLOW,
        outlineWidth: 3,
        heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
      },
      label: {
        text: "紧贴地面",
        font: "14pt sans-serif",
        heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
        horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
        verticalOrigin: Cesium.VerticalOrigin.BASELINE,
        fillColor: Cesium.Color.BLACK,
        showBackground: true,
        backgroundColor: new Cesium.Color(1, 1, 1, 0.7),
        backgroundPadding: new Cesium.Cartesian2(8, 4),
        disableDepthTestDistance: Number.POSITIVE_INFINITY, // draws the label in front of terrain
      },
    });

    viewer.trackedEntity = e;
  },
};
</script>

 添加billboard

资源下载地址:https://sandcastle.cesium.com/images/facility.gif 

<template>
  <div style="height: 100vh">
    <div id="cesiumContainer" />
  </div>
</template>

<script>
export default {
  name: "test",
  data() {
    return {};
  },
  mounted() {
    const viewer = new Cesium.Viewer("cesiumContainer", {
      terrainProvider: Cesium.createWorldTerrain(),
    });
    viewer.scene.globe.depthTestAgainstTerrain = true;

    const e = viewer.entities.add({
      position: Cesium.Cartesian3.fromDegrees(-122.1958, 46.1915),
      billboard: {
        image: "facility.gif",
        heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
      },
    });

    viewer.trackedEntity = e;
  },
};
</script>

添加corridor

<template>
  <div style="height: 100vh">
    <div id="cesiumContainer" />
  </div>
</template>

<script>
export default {
  name: "test",
  data() {
    return {};
  },
  mounted() {
    const viewer = new Cesium.Viewer("cesiumContainer", {
      terrainProvider: Cesium.createWorldTerrain(),
    });
    viewer.scene.globe.depthTestAgainstTerrain = true;

    const e = viewer.entities.add({
      corridor: {
        positions: Cesium.Cartesian3.fromDegreesArray([
          -122.19, 46.1914, -122.21, 46.21, -122.23, 46.21,
        ]),
        width: 2000.0,
        material: Cesium.Color.GREEN.withAlpha(0.5),
      },
    });

    viewer.zoomTo(e);
  },
};
</script>

 添加面polygon

<template>
  <div style="height: 100vh">
    <div id="cesiumContainer" />
  </div>
</template>

<script>
export default {
  name: "test",
  data() {
    return {};
  },
  mounted() {
    const viewer = new Cesium.Viewer("cesiumContainer", {
      terrainProvider: Cesium.createWorldTerrain(),
    });
    viewer.scene.globe.depthTestAgainstTerrain = true;

    const e = viewer.entities.add({
      polygon: {
        hierarchy: {
          positions: [
            new Cesium.Cartesian3(
              -2358138.847340281,
              -3744072.459541374,
              4581158.5714175375
            ),
            new Cesium.Cartesian3(
              -2357231.4925370603,
              -3745103.7886602185,
              4580702.9757762635
            ),
            new Cesium.Cartesian3(
              -2355912.902205431,
              -3744249.029778454,
              4582402.154378103
            ),
            new Cesium.Cartesian3(
              -2357208.0209552636,
              -3743553.4420488174,
              4581961.863286629
            ),
          ],
        },
        material: Cesium.Color.BLUE.withAlpha(0.5),
      },
    });

    viewer.zoomTo(e);
  },
};
</script>

 添加带图片的面polygon

 

<template>
  <div style="height: 100vh">
    <div id="cesiumContainer" />
  </div>
</template>

<script>
export default {
  name: "test",
  data() {
    return {};
  },
  mounted() {
    const viewer = new Cesium.Viewer("cesiumContainer", {
      terrainProvider: Cesium.createWorldTerrain(),
    });
    viewer.scene.globe.depthTestAgainstTerrain = true;

    const e = viewer.entities.add({
      polygon: {
        hierarchy: {
          positions: [
            new Cesium.Cartesian3(
              -2358138.847340281,
              -3744072.459541374,
              4581158.5714175375
            ),
            new Cesium.Cartesian3(
              -2357231.4925370603,
              -3745103.7886602185,
              4580702.9757762635
            ),
            new Cesium.Cartesian3(
              -2355912.902205431,
              -3744249.029778454,
              4582402.154378103
            ),
            new Cesium.Cartesian3(
              -2357208.0209552636,
              -3743553.4420488174,
              4581961.863286629
            ),
          ],
        },
        material: "Cesium_Logo_Color.jpg",
        classificationType: Cesium.ClassificationType.TERRAIN,
        stRotation: Cesium.Math.toRadians(45),
      },
    });

    viewer.zoomTo(e);
  },
};
</script>

 添加矩形

<template>
  <div style="height: 100vh">
    <div id="cesiumContainer" />
  </div>
</template>

<script>
export default {
  name: "test",
  data() {
    return {};
  },
  mounted() {
    const viewer = new Cesium.Viewer("cesiumContainer", {
      terrainProvider: Cesium.createWorldTerrain(),
    });
    viewer.scene.globe.depthTestAgainstTerrain = true;

    const e = viewer.entities.add({
      rectangle: {
        coordinates: Cesium.Rectangle.fromDegrees(-122.3, 46.0, -122.0, 46.3),
        material: Cesium.Color.RED.withAlpha(0.5),
      },
    });

    viewer.zoomTo(e);
  },
};
</script>

添加glb模型

 

<template>
  <div style="height: 100vh">
    <div id="cesiumContainer" />
  </div>
</template>

<script>
export default {
  name: "test",
  data() {
    return {};
  },
  mounted() {
    const viewer = new Cesium.Viewer("cesiumContainer", {
      terrainProvider: Cesium.createWorldTerrain(),
    });
    viewer.scene.globe.depthTestAgainstTerrain = true;

    const e = viewer.entities.add({
      position: Cesium.Cartesian3.fromDegrees(-122.1958, 46.1915),
      model: {
        uri: "Cesium_Air.glb",
        heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
        minimumPixelSize: 128,
        maximumScale: 100,
      },
    });

    viewer.trackedEntity = e;
  },
};
</script>

 被遮挡的线用其他颜色标注

<template>
  <div style="height: 100vh">
    <div id="cesiumContainer" />
  </div>
</template>

<script>
export default {
  name: "test",
  data() {
    return {};
  },
  mounted() {
    const viewer = new Cesium.Viewer("cesiumContainer", {
      terrainProvider: Cesium.createWorldTerrain(),
    });
    viewer.scene.globe.depthTestAgainstTerrain = true;

    const length = 1000;

    const startLon = Cesium.Math.toRadians(86.953793);
    const endLon = Cesium.Math.toRadians(86.896497);

    const lat = Cesium.Math.toRadians(27.988257);

    const terrainSamplePositions = [];
    for (let i = 0; i < length; ++i) {
      const lon = Cesium.Math.lerp(endLon, startLon, i / (length - 1));
      const position = new Cesium.Cartographic(lon, lat);
      terrainSamplePositions.push(position);
    }

    Promise.resolve(
      Cesium.sampleTerrainMostDetailed(
        viewer.terrainProvider,
        terrainSamplePositions
      )
    ).then(function (samples) {
      let offset = 10.0;
      for (let i = 0; i < samples.length; ++i) {
        samples[i].height += offset;
      }

      viewer.entities.add({
        polyline: {
          positions:
            Cesium.Ellipsoid.WGS84.cartographicArrayToCartesianArray(samples),
          arcType: Cesium.ArcType.NONE,
          width: 5,
          material: new Cesium.PolylineOutlineMaterialProperty({
            color: Cesium.Color.ORANGE,
            outlineWidth: 2,
            outlineColor: Cesium.Color.BLACK,
          }),
          depthFailMaterial: new Cesium.PolylineOutlineMaterialProperty({
            color: Cesium.Color.RED,
            outlineWidth: 2,
            outlineColor: Cesium.Color.BLACK,
          }),
        },
      });

      const target = new Cesium.Cartesian3(
        300770.50872389384,
        5634912.131394585,
        2978152.2865545116
      );
      offset = new Cesium.Cartesian3(
        6344.974098678562,
        -793.3419798081741,
        2499.9508860763162
      );
      viewer.camera.lookAt(target, offset);
      viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
    });
  },
};
</script>

添加贴地线

<template>
  <div style="height: 100vh">
    <div id="cesiumContainer" />
  </div>
</template>

<script>
export default {
  name: "test",
  data() {
    return {};
  },
  mounted() {
    const viewer = new Cesium.Viewer("cesiumContainer", {
      terrainProvider: Cesium.createWorldTerrain(),
    });
    viewer.scene.globe.depthTestAgainstTerrain = true;
    viewer.entities.add({
      polyline: {
        positions: Cesium.Cartesian3.fromDegreesArray([
          86.953793, 27.928257, 86.953793, 27.988257, 86.896497, 27.988257,
        ]),
        clampToGround: true,
        width: 5,
        material: new Cesium.PolylineOutlineMaterialProperty({
          color: Cesium.Color.ORANGE,
          outlineWidth: 2,
          outlineColor: Cesium.Color.BLACK,
        }),
      },
    });

    const target = new Cesium.Cartesian3(
      300770.50872389384,
      5634912.131394585,
      2978152.2865545116
    );
    const offset = new Cesium.Cartesian3(
      6344.974098678562,
      -793.3419798081741,
      2499.9508860763162
    );
    viewer.camera.lookAt(target, offset);
    viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
  },
};
</script>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/37555.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

都已过35+程序员高危高龄,我为什么还要学习python?

前言 首先声明一点&#xff1a;学习PYTHON&#xff0c;绝不是要去当一名“憔悴的”程序猿~ &#xff08;文末送读者福利&#xff09; 去互联网大厂&#xff1f;则更是谈不上。就算我想去&#xff0c;大厂也是看不上。 年龄看不上&#xff08;已过程序员35岁之高龄&#xff0…

学生个人网页设计作品 学生个人网页模板 简单个人主页成品 个人网页制作 HTML学生个人网站作业设计代做

&#x1f389;精彩专栏推荐&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb;&#x1f447;&#x1f3fb; ✍️ 作者简介: 一个热爱把逻辑思维转变为代码的技术博主 &#x1f482; 作者主页: 【主页——&#x1f680;获取更多优质源码】 &#x1f393; web前端期末大作业…

LaTex常用技巧6:矩阵编写总结

本文记录和总结了LaTex编写矩阵的一些要点&#xff0c;具体参考这位博主半个冯博士的知乎文章如何用latex编写矩阵&#xff08;包括各类复杂、大型矩阵&#xff09;&#xff1f; 无括号矩阵圆括号矩阵方括号矩阵大括号矩阵行列式范数分块矩阵竖实线竖虚线横实线横虚线其他要点横…

redis的下载和安装详解

一、下载redis安装包 进入redis官网查看当前稳定版本&#xff1a; https://redis.io/download/发现此时的稳定版本是6.2.4&#xff0c; 此时可以去这个网站下载6.2.4稳定版本的tar包。 暂时不考虑不在windows上使用redis&#xff0c;那样将无法发挥redis的性能 二、上传tar…

智能疾病查询接口

一、接口介绍 最全的疾病大全&#xff0c;收集了数万种常见疾病&#xff0c;任何常见疾病都可查询。 二、功能体验 三、API文档 3.1 查询疾病科目 3.1.1接入点说明 查询疾病的类别。 3.1.2接口地址 http[s]&#x1f615;/www.idmayi.com/546-1?idmayi_appid替换自己的值&…

spring复习02,xml配置管理bean

spring复习02,xml配置管理bean获取bean的几种方式1. 通过id获取bean2. 通过class获取bean3. id和class结合来获取bean依赖注入的两种方式setter注入有参构造器注入依赖注入时一些特殊值的处理1.字面量2.null值3.xml实体4.CDATA节为类类属性赋值1.引入已经声明的bean的方式2.内部…

在springboot工程中修改使用quartz创建的定时任务

Quratz是什么: Quartz 是一个完全由 Java 编写的开源作业调度框架,为在 Java 应用程序中进行作业调度提供了简单却强大的机制。 Quartz 可以与 J2EE 与 J2SE 应用程序相结合也可以单独使用。 Quartz 允许程序开发人员根据时间的间隔来调度作业。 Quartz 实现了作业和触发器的…

CTF-misc练习(https://buuoj.cn)之第二页

目录 一、被劫持的神秘礼物 二、刷新过的图片 三、[BTF2020]认真你就输了 四、[BJDCTF2020]藏藏藏 五、被偷走的流量 九、菜刀666 十、秘密文件 十一、[BJDCTF2020]just_a_rar 十二、[BJDCTF2020]鸡你太美 十三、[BJDCTF2020]一叶障目 十四、神奇的二维码 十五、梅…

mysql必知必会

名词 数据库软件 &#xff1a; DBMS(database manager system) 数据库 &#xff1a;database, 通过DBMS创建和操作的容器, 保存有组织的数据的容器&#xff0c;&#xff0c;&#xff0c;通常是一个文件或者一组文件 表&#xff1a; 是一种结构化文件&#xff0c;&#xff0c;…

安科瑞水电预付费平台,远程控制,高校宿舍、员工宿舍、商场等多场合适用

安科瑞 司红霞 一、引言 预付费水表是一种为了适应“先付费后用水”的管理原则和系统而开发的水表产品其设计是在水表基表上加装了电子附加装置和控制阀&#xff0c;要求用户先预付&#xff0c;一定的费用或购置一定数量的水量&#xff0c;将预付费的信息输入水表后才可正常用…

四轴斜转魔方

目录 四轴斜转魔方 1&#xff0c;魔方三要素 2&#xff0c;公式推导 &#xff08;1&#xff09;调整8个角块位置 &#xff08;2&#xff09;调整6个中心块位置 &#xff08;3&#xff09;调整角块方向 四轴斜转魔方 1&#xff0c;魔方三要素 &#xff08;1&#xff09;组…

Sentinel实现服务降级并与api解耦

Sentinel怎样实现熔断降级 熔断降级介绍 sentinel支持服务的熔断降级 熔断类似于保险丝&#xff0c;在超出了阈值的情况下&#xff0c;在一定的时间内不会执行业务逻辑&#xff0c;直接执行服务降级的方法。服务降级利用本地fallback方法&#xff0c;返回一个有好的提示给客…

Scala配置和Spark配置以及Scala一些函数的用法(附带词频统计实例)

文章目录配置Spark配置Scala生成RDDfilter过滤器map方法flatMap方法reduceByKeyspark下wordcount程序参考先给出spark和Scala的下载地址&#xff0c;这是我用的版本https://pan.baidu.com/s/1rcG1xckk3zmp9BLmf74hsg?pwd1111也可以自己去官网下载。配置Spark 解压文件到softw…

public,private,protected,default的区别

public public&#xff08;公开&#xff09;表示任何人都可以访问和使用该元素&#xff1b; public class Test {public static void main(String[] args) {Person pnew Person();System.out.println(p.name);//输出小明} } class Person{public String name"小明"…

Go 开发环境安装之Goland和vscode

一、前言 Go语言或将成为新的主力开发语言&#xff0c;Go是google开发的一种静态强类型、编译型、并发型&#xff0c;并具有垃圾回收功能的编程语言&#xff0c;所以我们有必要学习并掌握它。第一件事情&#xff0c;就是把环境搭建起来&#xff0c;大家可以跟着步骤一起将Go语…

【计算机网络】数据链路层:点对点协议PPP

对于点对点链路&#xff0c;目前使用最为广泛的数据链路层协议是点对点协议PPP。 简单&#xff08;首要要求&#xff09; 封装成帧&#xff1a;保证数据传输的透明性 多种网络层协议&#xff1a;能够在同一条物理链路上同时支持多种网络层协议。 多种类型链路&#xff1a;能…

2020牛客暑期多校训练营(第十场)I.Tournament(构造/贪心)

题目 t(1<t<30)组样例&#xff0c;n(2<n<300)个球队&#xff0c; 每个球队都和其它所有球队比一场&#xff0c;一共有场比赛。 每天只比一场比赛&#xff0c;每个球队会在其第一场比赛开始时到&#xff0c;最后一场比赛后走。 安排一个日程表&#xff0c;使所有…

Linux多线程C++版(五) 线程同步和线程互斥

目录1.线程同步和线程互斥2.线程互斥案例---ATM取钱--没有使用互斥锁3.线程互斥----互斥锁(互斥量)4.互斥锁创建和销毁5.互斥锁上锁和解锁6.线程互斥案例---ATM取钱--使用互斥锁7.互斥锁属性创建和销毁8.互斥锁属性之一---进程共享属性操作9.互斥锁属性之一----互斥锁类型操作1…

[附源码]计算机毕业设计JAVA人口老龄化社区服务与管理平台

[附源码]计算机毕业设计JAVA人口老龄化社区服务与管理平台 项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; …

Apollo 应用与源码分析:Monitor监控 - Monitor_managerecurrent_runner分析

目录 monitor_manager 分析 结构分析 单例模式宏定义 描述现在的系统状态 HMI上显示的状态信息 仿真判断状态 判断是不是自动驾驶状态 日志缓存 当前node 所有monitor 的reader 管理map 开启一次监控 start frame分析 end frame分析 recurrent_runner 分析 结构…