Cesium快速上手3-Billboard Label PointPrimitives图元使用讲解

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cesium快速上手3-Billboard Label PointPrimitives图元使用讲解相关的知识,希望对你有一定的参考价值。

参考技术A 面朝屏幕的图片

http://localhost:8080/Apps/Sandcastle/index.html?src=development%2FBillboards.html&label=Development

//链式返回,new Cesium.BillboardCollection() 生成一个对象,这个对象是另一个scene.primitives.add的参数
//position : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883)
//position 空间直角坐标系,由经纬度坐标转换而来;这里的经纬度省略了Z的参数
// 可以增加一句 var height = Cesium.defaultValue(444444);
// position : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883,height )

sizeInMeters : true, //图像的尺寸被指定成图像实际的尺寸,不随地图的缩放而变换大小

一次创建多个

//scaleByDistance 设置屏幕像素缩放比,150米的时候放大一倍,150000米的时候,缩放到0.5
//Cesium.NearFarScalar四个值,最近的距离,最远的距离,缩放比例范围

translucencyByDistance 改动透明度,地球缩放到很小时,透明度增大

pixelOffset : new Cesium.Cartesian2(0.0, -facilityHeight), //在原位置上偏移,防止叠在一起看不到了
pixelOffsetScaleByDistance : new Cesium.NearFarScalar(1.0e3, 1.0, 1.5e6, 0.0), //随着距离改变偏移量
translucencyByDistance : new Cesium.NearFarScalar(1.0e3, 1.0, 1.5e6, 0.1)//随着距离改变透明度

添加点的公告牌

增加marker的公告牌

在框架体系中增加广告牌,平移旋转缩放,全部围绕着billboards.modelMatrix
平移到某一点后,旋转X轴转到朝东,Y转到朝北,z轴转到正上方。
billboards.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(center);

特点:
始终面朝屏幕,即使旋转也面朝屏幕
注意创建的集群对象 Cesium.BillboardCollection
为什么不能创建单个Billboard?Entity来解决此问题

面朝屏幕的文字

http://localhost:8080/Apps/Sandcastle/index.html?src=development%2FLabels.html&label=Development
特点:

始终朝向屏幕
注意创建的是集群对象 Cesium.LabelCollection()
Label对象只能用在LabelCollection当中

http://localhost:8080/Apps/Sandcastle/index.html?src=development%2FPointPrimitives.html&label=Development

Cesium快速上手10-Viewer Entities组合

参考技术A

Viewer/Entities的作用:

方便创建直观的对象,同时做到性能优化(billboard、point等)
提供一些方便使用的函数:flyTo/zoomTo
赋予Entity对象时间这个属性,对象具备动态特性/Primitive不具备
提供一些UI(homeButton/sceneModePicker/projectionPicker/baseLayerPicker)
大量的快捷方式,camera等未必是好事。。
Datasource模式来加载大规模数据:Geojson
Datasource结构
Entities是一个快捷方式,其实返回的是viewer.dataSourceDisplay.defaultDatasource.entities ;

Entity结构

var viewer = new Cesium.Viewer(\'cesiumContainer\');

示例 可参考 Geometries

http://localhost:8080/Apps/Sandcastle/index.html?src=Box.html&label=Geometries

box 就是立方体
cylinder 是圆锥 圆柱

http://localhost:8080/Apps/Sandcastle/index.html?src=Cylinders%20and%20Cones.html&label=Geometries

topRadius = bottomRadius 是圆柱
topRadius=0, bottomRadius 大于0 是圆锥

Entity
Cesium.EntityCollection

每一个Datasource都挂在Entity下;

http://localhost:8080/Apps/Sandcastle/index.html?src=GeoJSON%20and%20TopoJSON.html&label=DataSources

http://localhost:8080/Apps/Sandcastle/index.html?src=GeoJSON%20simplestyle.html&label=DataSources

http://localhost:8080/Apps/Sandcastle/index.html?src=Custom%20DataSource.html&label=DataSources

以上是关于Cesium快速上手3-Billboard Label PointPrimitives图元使用讲解的主要内容,如果未能解决你的问题,请参考以下文章

使用 mongodb 的 Docker Image 快速上手系列 lab

Cesium基础使用介绍

Cesium应用篇:1快速搭建

快速搭建arcgis以及cesium环境

Cesium中级2 - 图层

大数据量的兴趣点如何在Cesium快速加载?