可渲染的广告牌集合。 公告板与视区对齐
位于 3D 场景中的图像。

广告牌示例
使用

广告牌示例
使用
BillboardCollection#add
在集合中添加和删除公告牌
和 BillboardCollection#remove
。 集合中的公告板会自动共享纹理
表示具有相同标识符的图像。
Performance:
为了获得最佳性能,最好使用几个集合,每个集合都有许多广告牌,而不是 许多收藏,每个收藏只有几个广告牌。 组织集合,以便 billboards 具有相同更新频率的 billboard 位于同一集合中,即 更改应在一个集合中;更改每个帧的广告牌应该在另一个 收集;等等。
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
对象,具有以下属性:
|
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
公告牌混合选项。默认设置用于渲染不透明和半透明公告板。
但是,如果所有广告牌都是完全不透明的,或者所有广告牌都是完全半透明的,
将技术设置为 BlendOption.OPAQUE 或 BlendOption.TRANSLUCENT 可以提高
性能提升高达 2 倍。
-
Default Value:
BlendOption.OPAQUE_AND_TRANSLUCENT
此属性仅用于调试;它不用于生产用途,也未进行优化。
为基元中的每个绘制命令绘制边界球体。
-
Default Value:
false
此属性仅用于调试;它不用于生产用途,也未进行优化。
将此 BillboardCollection 的纹理图集绘制为全屏四边形。
-
Default Value:
false
返回此集合中的 billboard 数量。 这通常与
BillboardCollection#get
迭代所有公告牌
在集合中。
modelMatrix : Matrix4
4x4 转换矩阵,用于将此集合中的每个 billboard 从模型转换为世界坐标。
当这是单位矩阵时,广告牌以世界坐标(即地球的 WGS84 坐标)绘制。
可以通过提供不同的转换矩阵来使用本地参考帧,就像返回的矩阵一样
由
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:
确定是否显示此集合中的公告板。
-
Default Value:
true
Methods
add(options) → Billboard
创建具有指定初始属性的广告牌并将其添加到集合中。
将返回添加的公告牌,以便以后可以对其进行修改或从集合中删除它。
Performance:
调用 add
是预期的常数时间。 但是,集合的顶点缓冲区
被重写 - 一个 O(n)
操作,也会产生 CPU 到 GPU 的开销。 为
最佳性能,在调用 update
之前添加尽可能多的 billboard。
Name | Type | Description |
---|---|---|
options |
Billboard.ConstructorOptions | optional 描述公告牌属性的模板,如示例 1 所示。 |
Returns:
已添加到集合中的 billboard。
Throws:
-
DeveloperError : 这个物体被摧毁了,destroy().
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:
Check whether this collection contains a given billboard.
Name | Type | Description |
---|---|---|
billboard |
Billboard | optional The billboard to check for. |
Returns:
true if this collection contains the billboard, 否则 false 。
销毁此对象持有的 WebGL 资源。 销毁对象允许确定性
释放 WebGL 资源,而不是依赖垃圾回收器来销毁这个对象。
一旦对象被销毁,就不应该使用它;调用
一旦对象被销毁,就不应该使用它;调用
isDestroyed
将导致 DeveloperError
异常。 因此
将返回值 (undefined
) 分配给对象,如示例中所示。
Throws:
-
DeveloperError : 这个物体被摧毁了,即, destroy().
Example:
billboards = billboards && billboards.destroy();
See:
get(index) → Billboard
返回集合中指定索引处的 billboard。 索引从 0 开始
并随着广告牌的添加而增加。 删除公告牌后,所有公告牌都会移动
它向左移动,更改其索引。 此功能通常用于
BillboardCollection#length
迭代所有公告牌
在集合中。
Performance:
预期恒定时间。 如果从集合中删除了 billboard,并且
BillboardCollection#update
未调用,隐式 O(n)
执行操作。
Name | Type | Description |
---|---|---|
index |
number | 公告牌的从零开始的索引。 |
Returns:
位于指定索引的公告牌。
Throws:
-
DeveloperError : 这个物体被摧毁了,destroy().
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:
Returns:
true
,如果此对象被销毁;否则为 false
。
从集合中删除公告牌。
Performance:
调用 remove
是预期的常数时间。 但是,集合的顶点缓冲区
被重写 - 一个 O(n)
操作,也会产生 CPU 到 GPU 的开销。 为
最佳性能,在调用 update
之前尽可能多地移除 billboard。
如果您打算暂时隐藏公告牌,通常调用
Billboard#show
,而不是删除并重新添加公告牌。
Name | Type | Description |
---|---|---|
billboard |
Billboard | 要移除的广告牌。 |
Returns:
true
(如果广告牌被删除);如果在集合中找不到 Billboard,则为 false
。
Throws:
-
DeveloperError : 这个物体被摧毁了,destroy().
Example:
const b = billboards.add(...);
billboards.remove(b); // Returns true
See:
从集合中删除所有公告牌。
Performance:
O(n)
移除所有广告牌效率更高
从集合中,然后添加新的集合,而不是完全创建一个新集合。
Throws:
-
DeveloperError : 这个物体被摧毁了,destroy().
Example:
billboards.add(...);
billboards.add(...);
billboards.removeAll();
See:
Throws:
-
RuntimeError : image with id must be in the atlas.