当前位置: 首页 > news >正文

cesium编程入门(五)绘制形状

通过Entity添加形状

先来看一个添加立方体的例子

var viewer = new Cesium.Viewer('cesiumContainer');
var redBox = **viewer.entities.add**({
  name : 'Red box with black outline',
  position: Cesium.Cartesian3.fromDegrees(-107.0, 40.0, 300000.0),
  box : {
    dimensions : new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
    material : Cesium.Color.RED.withAlpha(0.5),
    outline : true,
    outlineColor : Cesium.Color.BLACK
  }
});

viewer.zoomTo(viewer.entities);

效果如图:

Jietu20180108-214130.jpg

通过CZML添加

通过CZML也可以添加几何形状,而且CZML还可以描述动画(现在先有个印象,动画以后介绍)

先来看看官网上的说明,CZML是一种JSON格式的字符串,用于描述与时间有关的动画场景,CZML包含点、线、地标、模型、和其他的一些图形元素,并指明了这些元素如何随时间而变化。某种程度上说, Cesium 和 CZML的关系就像 Google Earth 和 KML。

var czml = [{
    "id" : "document",
    "name" : "box",
    "version" : "1.0"
},{
    "id" : "shape2",
    "name" : "Red box with black outline",
    "position" : {
        "cartographicDegrees" : [-107.0, 40.0, 300000.0]
    },
    "box" : {
        "dimensions" : {
            "cartesian": [400000.0, 300000.0, 500000.0]
        },
        "material" : {
            "solidColor" : {
                "color" : {
                    "rgba" : [255, 0, 0, 128]
                }
            }
        },
        "outline" : true,
        "outlineColor" : {
            "rgba" : [0, 0, 0, 255]
        }
    }
}];

var viewer = new Cesium.Viewer('cesiumContainer');
var dataSourcePromise = Cesium.CzmlDataSource.load(czml);
viewer.dataSources.add(dataSourcePromise);
viewer.zoomTo(dataSourcePromise);

可以看到单个的形状和Entity的描述基本一致,只不过是使用JSON语法来描述,关于形状描述可以参考官方API,下一节列出形状的相关信息

形状相关描述

下表来自于官方网站,但是连接改为本地链接了

   
PointpointGeometry.pngentity.point - Reference Build/Documentation
BoxesboxGeometry.pngentity.box - Code example - Reference Build/Documentation
Circles and EllipsesellipseGeometry.pngentity.ellipse - Code example - Reference Build/Documentation
CorridorcorridorGeometry.pngentity.corridor - Code example - Reference Build/Documentation
Cylinder and ConescylinderGeometry.pngentity.cylinder - Code example - Reference Build/Documentation
PolygonspolygonGeometry.pngentity.polygon - Code example - Reference Build/Documentation
PolylinespolylineGeometry.pngentity.polyline - Code example - Reference Build/Documentation
Polyline VolumespolylineVolumeGeometry.pngentity.polylineVolume - Code example - Reference Build/Documentation
RectanglesextentGeometry.pngentity.rectangle - Code example - Reference Build/Documentation
Spheres and EllipsoidsellipsoidGeometry.pngentity.ellipsoid - Code example - Reference Build/Documentation
WallswallGeometry.pngentity.wall - Code example - Reference Build/Documentation

转载于:https://www.cnblogs.com/huqi-code/p/8287497.html

相关文章:

  • CSS背景图片垂直居中center不起效果完美解决
  • iOS----------教你如何使用 GitHub Desktop
  • python目录操作整理
  • 【转】 缓存在高并发场景下的常见问题
  • Ubuntu16.04下安装sublime text3
  • 理解MySql的锁事务隔离级别
  • 多台Mac电脑使用一个apple开发者账号
  • String 类 常用函数
  • mybatis单笔批量保存
  • git push origin master错误
  • BZOJ1415 [Noi2005]聪聪和可可 【SPFA + 期望dp记忆化搜索】
  • C. Permute Digits dfs大模拟
  • r-mq实现顺序消费,不重复消费
  • 53. Maximum Subarray(动态规划)
  • 美国人教你这样用Google,你真的会变特工
  • 网络传输文件的问题
  • [rust! #004] [译] Rust 的内置 Traits, 使用场景, 方式, 和原因
  • “寒冬”下的金三银四跳槽季来了,帮你客观分析一下局面
  • 3.7、@ResponseBody 和 @RestController
  • bootstrap创建登录注册页面
  • const let
  • go语言学习初探(一)
  • HTTP传输编码增加了传输量,只为解决这一个问题 | 实用 HTTP
  • passportjs 源码分析
  • springMvc学习笔记(2)
  • SQLServer之创建显式事务
  • V4L2视频输入框架概述
  • 关于 Cirru Editor 存储格式
  • 简析gRPC client 连接管理
  • 免费小说阅读小程序
  • 强力优化Rancher k8s中国区的使用体验
  • 深入体验bash on windows,在windows上搭建原生的linux开发环境,酷!
  • 正则表达式
  • 如何用纯 CSS 创作一个菱形 loader 动画
  • # 再次尝试 连接失败_无线WiFi无法连接到网络怎么办【解决方法】
  • #我与Java虚拟机的故事#连载08:书读百遍其义自见
  • (13)Hive调优——动态分区导致的小文件问题
  • (c语言)strcpy函数用法
  • (react踩过的坑)antd 如何同时获取一个select 的value和 label值
  • (八)Spring源码解析:Spring MVC
  • (分布式缓存)Redis持久化
  • (切换多语言)vantUI+vue-i18n进行国际化配置及新增没有的语言包
  • (十三)Maven插件解析运行机制
  • (一) storm的集群安装与配置
  • (原創) 系統分析和系統設計有什麼差別? (OO)
  • .gitignore文件_Git:.gitignore
  • .gitignore文件—git忽略文件
  • .NET LINQ 通常分 Syntax Query 和Syntax Method
  • .NET6实现破解Modbus poll点表配置文件
  • .net利用SQLBulkCopy进行数据库之间的大批量数据传递
  • @GetMapping和@RequestMapping的区别
  • [ 代码审计篇 ] 代码审计案例详解(一) SQL注入代码审计案例
  • [1] 平面(Plane)图形的生成算法
  • [100天算法】-实现 strStr()(day 52)
  • [Django ]Django 的数据库操作