new Cesium.BillboardCollection(options)

广告牌的收藏品 广告牌是视图-对齐的 图像位于3D场景.


Example billboards


使用 BillboardCollection#add 在收藏中添加并删除公告牌 和 BillboardCollection#remove . 收藏中的告示牌自动共享纹理 对于具有相同标识符的图像.
Performance:

For best performance, prefer a few collections, each with many billboards, to 许多藏品每本只有几块广告牌. 组织收藏,让广告牌 同一更新频率的公告牌是同一集, NT 0 更改应该放在一个集合中; 更改每个框的公告牌应该放在另一个框中 收藏; 等.

Name Type Description
options object optional 下列属性的对象 :
Name Type Default Description
modelMatrix Matrix4 Matrix4.IDENTITY optional The 4x4 transformation matrix that transforms each billboard from model to world coordinates.
debugShowBoundingVolume boolean false optional For debugging only. Determines if this primitive's commands' bounding spheres are shown.
scene Scene optional 对于使用高度参考属性的广告牌 或将进行全球深度测试的广告牌,必须经过.
blendOption BlendOption BlendOption.OPAQUE_AND_TRANSLUCENT optional The billboard blending option. The default 用于渲染不透明的和半透明的广告牌。 然而,如果所有的广告牌都完全不透明或者全部完全透明, 将技术设置为 BlendOption.OPAQUE 或 BlendOption.TRANSLUCENT ,可以提高性能最多2×.
show boolean true optional Determines if the billboards in the collection will be shown.
coarseDepthTestDistance number optional The distance from the camera, beyond which, billboards are depth-tested against an approximation of the globe ellipsoid rather than against the full globe depth buffer. If unspecified, the default value is determined relative to the value of Ellipsoid.default.
threePointDepthTestDistance number optional The distance from the camera, within which, billboards with a Billboard#heightReference value of HeightReference.CLAMP_TO_GROUND or HeightReference.CLAMP_TO_TERRAIN are depth tested against three key points. This ensures that if any key point of the billboard is visible, the whole billboard will be visible. If unspecified, the default value is determined relative to the value of Ellipsoid.default.
Example:
// Create a billboard collection with two billboards
const billboards = scene.primitives.add(new Cesium.BillboardCollection());
billboards.add({
  position : new Cesium.Cartesian3(1.0, 2.0, 3.0),
  image : 'url/to/image'
});
billboards.add({
  position : new Cesium.Cartesian3(4.0, 5.0, 6.0),
  image : 'url/to/another/image'
});
Demo:
See:

Members

blendOption : BlendOption

广告牌混合选项. 默认用于渲染不透明的和半透明的广告牌. 然而,如果所有的广告牌都完全不透明或者全部完全透明, 将技术设置为 NT 0 或 NT 1 可以改进 最多2x的表演.
Default Value: -NT=0=- 翻译:

coarseDepthTestDistance : number

离相机的距离, 超过它, 广告牌被深度测试 与近似 地球椭圆,而不是与全地球深度缓冲。 当设定为 NT 0 0 NT 1 时 通常采用近似深度测试。 当设定为 NT 时 从未应用过近似深度测试 .

This setting only applies when a billboard's Billboard#disableDepthTestDistance value would 否则可以进行深度测试 相机到广告牌的距离小于一个 billboard's Billboard#disableDepthTestDistance value.

debugShowBoundingVolume : boolean

此属性仅用于调试;不用于生产,也不优化.

绘制原始中每个绘图命令的边框.

Default Value: false

debugShowTextureAtlas : boolean

此属性仅用于调试;不用于生产,也不优化.

绘制此 Billboard Collection 的纹理图集为全屏四角.

Default Value: false

readonly length : number

返回此收藏中的公告牌数 。 这通常用于 BillboardCollection#get to iterate over all the billboards 在收藏中.

modelMatrix : Matrix4

4x4变换矩阵将本集中的每个公告牌从模型变为世界坐标. 当这是身份矩阵时,公告牌会绘制在世界坐标, i.e . 地球的 WGS84 坐标. 本地参考框架可以通过提供不同的变换矩阵来使用, 如返回的变换矩阵 by Transforms.eastNorthUpToFixedFrame.
Default Value: Matrix4.IDENTITY
Example:
const center = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883);
billboards.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(center);
billboards.add({
  image : 'url/to/image',
  position : new Cesium.Cartesian3(0.0, 0.0, 0.0) // center
});
billboards.add({
  image : 'url/to/image',
  position : new Cesium.Cartesian3(1000000.0, 0.0, 0.0) // east
});
billboards.add({
  image : 'url/to/image',
  position : new Cesium.Cartesian3(0.0, 1000000.0, 0.0) // north
});
billboards.add({
  image : 'url/to/image',
  position : new Cesium.Cartesian3(0.0, 0.0, 1000000.0) // up
});
See:

show : boolean

确定是否在此收藏中显示公告牌 .
Default Value: true

threePointDepthTestDistance : number

The distance from the camera, within which, billboards with a Billboard#heightReference value of HeightReference.CLAMP_TO_GROUND or HeightReference.CLAMP_TO_TERRAIN are depth tested 对三个关键点。 这确保了如果广告牌上的任何关键点可见,整个 告示牌将可见. 当设定为 NT 0 0 NT 1 时,此特性已禁用,并部分为 a 地形后面的广告牌被剪断.

This setting only applies when a billboard's Billboard#disableDepthTestDistance value would 否则可以进行深度测试 相机到广告牌的距离小于一个 billboard's Billboard#disableDepthTestDistance value.
See:

Methods

add(options)Billboard

在收藏中创建并添加带有指定初始属性的公告牌. 新增的告示牌被退回,以便日后可以修改或从收藏中移除.
Performance:

Calling add is expected constant time. However, the collection's vertex buffer is rewritten - an O(n) operation that also incurs CPU to GPU overhead. For 最佳表现,在拨打 NT 0 update NT 1 前加入尽可能多的公告牌.

Name Type Description
options Billboard.ConstructorOptions optional A template describing the billboard's properties as shown in Example 1.
Returns:
收藏中加入的告示牌.
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
Examples:
// Example 1:  Add a billboard, specifying all the default values.
const b = billboards.add({
  show : true,
  position : Cesium.Cartesian3.ZERO,
  pixelOffset : Cesium.Cartesian2.ZERO,
  eyeOffset : Cesium.Cartesian3.ZERO,
  heightReference : Cesium.HeightReference.NONE,
  horizontalOrigin : Cesium.HorizontalOrigin.CENTER,
  verticalOrigin : Cesium.VerticalOrigin.CENTER,
  scale : 1.0,
  image : 'url/to/image',
  imageSubRegion : undefined,
  color : Cesium.Color.WHITE,
  id : undefined,
  rotation : 0.0,
  alignedAxis : Cesium.Cartesian3.ZERO,
  width : undefined,
  height : undefined,
  scaleByDistance : undefined,
  translucencyByDistance : undefined,
  pixelOffsetScaleByDistance : undefined,
  sizeInMeters : false,
  distanceDisplayCondition : undefined
});
// Example 2:  Specify only the billboard's cartographic position.
const b = billboards.add({
  position : Cesium.Cartesian3.fromDegrees(longitude, latitude, height)
});
See:

contains(billboard)boolean

Check whether this collection contains a given billboard.
Name Type Description
billboard Billboard optional 要检查的广告牌.
Returns:
如果收藏品中包含广告牌,则真实无误.
See:

destroy()

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic 释放 WebGL 资源,而不是依赖垃圾收集器来摧毁此对象.

Once an object is destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception. Therefore, assign the return value (undefined) to the object as done in the example.
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
billboards = billboards && billboards.destroy();
See:

get(index)Billboard

以指定的索引返回收藏中的公告牌。 指数为零 并随着公告牌的加入而增加。 移除广告牌后所有广告牌 在左边,改变他们的指数。 此函数通常用于 BillboardCollection#length to iterate over all the billboards 在收藏中.
Performance:

Expected constant time. If billboards were removed from the collection and BillboardCollection#update was not called, an implicit O(n) 操作完成.

Name Type Description
index number 公告牌百强单曲榜零基指数.
Returns:
指定索引的告示牌.
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
// Toggle the show property of every billboard in the collection
const len = billboards.length;
for (let i = 0; i < len; ++i) {
  const b = billboards.get(i);
  b.show = !b.show;
}
See:

isDestroyed()boolean

如果此对象被销毁, 返回真实; 否则, 错误 .

If this object was destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception.
Returns:
true if this object was destroyed; otherwise, false.
See:

remove(billboard)boolean

从收藏中删除一个公告牌.
Performance:

Calling remove is expected constant time. However, the collection's vertex buffer is rewritten - an O(n) operation that also incurs CPU to GPU overhead. For 最佳表现,在拨打 NT 0 update NT 1 前,尽量去除公告牌. 如果你打算暂时隐藏一个广告牌,通常更高效的呼叫 Billboard#show instead of removing and re-adding the billboard.

Name Type Description
billboard Billboard 告示牌要删除.
Returns:
如果公告牌被移除,则使用#NT##0 true NT###1 ;如果公告牌在收藏中找不到,则使用#NT 2 false NT 3 .
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
const b = billboards.add(...);
billboards.remove(b);  // Returns true
See:

removeAll()

从收藏中删除所有公告牌.
Performance:

O(n). It is more efficient to remove all the billboards 从收藏开始,然后添加新收藏,而不是完全创建新收藏.

Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
billboards.add(...);
billboards.add(...);
billboards.removeAll();
See:

update()

Called when Viewer or CesiumWidget render the scene to 获得使这个原始化所需的绘图命令.

不要直接调用此函数 。 记录下来的只是 列出场景拍摄时可能宣传的例外情况:

Throws:
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.