可渲染的广告牌集合。广告牌与视口对齐 在3D场景中定位的图像。

Example billboards
BillboardCollection#add
添加和删除集合中的广告牌
和BillboardCollection#remove
。集合中的广告牌会自动共享纹理
对于具有相同标识符的图像。Performance:
为了获得最佳性能,最好选择几个集合,每个集合都有许多广告牌 许多收藏品每个只有几块广告牌。收集广告牌 更新频率相同的是在同一个集合中,也就是说,没有更新频率的广告牌 改变应该在一个集合中;改变每一帧的广告牌应该在另一个集合中 收集;等等。
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | optional
具有以下属性的对象:
|
Example:
// Create a billboard collection with two billboards
var 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
广告牌混合选项。默认设置用于渲染不透明和半透明的广告牌。
但是,如果所有的广告牌都是完全不透明的或者都是完全透明的,
将技术设置为混合。不透明或者混合半透明可以改进
性能提高2倍。
-
Default Value:
BlendOption.OPAQUE_AND_TRANSLUCENT
此属性仅用于调试;它不用于生产用途,也不进行优化。
Draws the bounding sphere for each draw command in the primitive.
-
Default Value:
false
此属性仅用于调试;它不用于生产用途,也不进行优化。
Draws the texture atlas for this BillboardCollection as a fullscreen quad.
-
Default Value:
false
返回此集合中的公告牌数。通常用于
BillboardCollection#get
遍历所有的广告牌
收藏中。modelMatrix : Matrix4
4x4变换矩阵,将此集合中的每个广告牌从模型转换为世界坐标。
当这是身份矩阵时,广告牌以世界坐标系绘制,即地球的WGS84坐标系。
局部参考帧可以通过提供不同的转换矩阵来使用,就像返回的那样
通过
Transforms.eastNorthUpToFixedFrame
。-
Default Value:
Matrix4.IDENTITY
Example:
var 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:
Methods
add(options) → Billboard
创建并向集合添加具有指定初始属性的公告牌。
将返回添加的公告牌,以便以后可以修改或从集合中删除它。
Performance:
调用add
应为常量时间。但是,集合的顶点缓冲区
重写-O(n)
操作也会导致CPU到GPU的开销。为
最好的性能,请在拨打update
之前添加尽可能多的广告牌。
Name | Type | Description |
---|---|---|
options |
Object | optional 描述公告牌属性的模板,如示例1所示。 |
Returns:
添加到收藏中的广告牌。
Throws:
-
DeveloperError :此对象已销毁,即调用destroy()。
Examples:
// Example 1: Add a billboard, specifying all the default values.
var 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.
var b = billboards.add({
position : Cesium.Cartesian3.fromDegrees(longitude, latitude, height)
});
See:
检查此集合是否包含给定的公告牌。
Name | Type | Description |
---|---|---|
billboard |
Billboard | optional 要检查的广告牌。 |
Returns:
如果此集合包含公告牌,则为true,否则为false。
销毁此对象持有的WebGL资源。销毁一个对象允许确定性 释放WebGL资源,而不是依赖垃圾回收器销毁此对象。 一旦一个对象被销毁,就不应该使用它;调用除
isDestroyed
将导致DeveloperError
异常。因此,
如示例所示,将返回值(undefined
)分配给对象。Throws:
-
DeveloperError :此对象已销毁,即调用destroy()。
Example:
billboards = billboards && billboards.destroy();
See:
get(index) → Billboard
返回集合中指定索引处的公告牌。索引基于零
随着广告牌的增加而增加。拆卸广告牌后,将所有广告牌移动
向左,改变了他们的指数。此函数通常用于
BillboardCollection#length
在所有的广告牌上迭代
在集合里。Performance:
预期恒定时间。如果广告牌被从收藏品中移除 不是6861166,是6866166 执行操作。
Name | Type | Description |
---|---|---|
index |
Number | 广告牌的从零开始的索引。 |
Returns:
在指定索引处的广告牌。
Throws:
-
DeveloperError :此对象已销毁,即调用destroy()。
Example:
// Toggle the show property of every billboard in the collection
var len = billboards.length;
for (var i = 0; i < len; ++i) {
var b = billboards.get(i);
b.show = !b.show;
}
See:
Returns:
如果此对象被销毁,则为
true
;否则为false
。从收藏中移除广告牌。
Performance:
调用remove
应为常量时间。但是,集合的顶点缓冲区
重写-O(n)
操作也会导致CPU到GPU的开销。为
最好的性能,在拨打update
之前,尽可能多地移除广告牌。
如果你打算暂时隐藏广告牌,打电话通常更有效
Billboard#show
,而不是移除和重新添加广告牌。
Name | Type | Description |
---|---|---|
billboard |
Billboard | 要移除的广告牌。 |
Returns:
如果广告牌被移除,则为
true
;如果在集合中未找到广告牌,则为false
。Throws:
-
DeveloperError :此对象已销毁,即调用destroy()。
Example:
var b = billboards.add(...);
billboards.remove(b); // Returns true
See:
从集合中移除所有广告牌。
Performance:
O(n)
去掉所有的广告牌更有效
从一个集合中添加新的集合,而不是完全创建一个新集合。
Throws:
-
DeveloperError :此对象已销毁,即调用destroy()。
Example:
billboards.add(...);
billboards.add(...);
billboards.removeAll();
See:
当
Viewer
或CesiumWidget
将场景渲染到
获取渲染此基本体所需的draw命令。
Do not call this function directly. This is documented just to list the exceptions that may be propagated when the scene is rendered:
Throws:
-
RuntimeError :带id的图像必须在图集中。