在3D场景中定位的视口对齐图像,即 并使用
BillboardCollection
进行渲染。创建了一个广告牌,其初始
属性通过调用BillboardCollection#add
设置。

Example billboards
Performance:
读取属性(例如Billboard#show
)是恒定时间。
为属性赋值是恒定时间,但会导致
调用BillboardCollection#update
时CPU到GPU的流量。每个广告牌的流量是
不管更新了多少属性,都是一样的。如果一个集合中的大多数广告牌需要
更新后,使用BillboardCollection#removeAll
清除集合可能更有效
增加新的广告牌,而不是修改每一个。
Throws:
-
DeveloperError : 缩放距离.far必须大于scaleByDistance.近
-
DeveloperError :translucencyByDistance.far公司必须大于translucencyByDistance.近
-
DeveloperError :像素ffsetScaleByDistance.far距离必须大于pixelOffsetScaleByDistance.近
-
DeveloperError :距离取消显示条件.far必须大于距离取消显示条件。接近
Members
alignedAxis : Cartesian3
Examples:
// Example 1.
// Have the billboard up vector point north
billboard.alignedAxis = Cesium.Cartesian3.UNIT_Z;
// Example 2.
// Have the billboard point east.
billboard.alignedAxis = Cesium.Cartesian3.UNIT_Z;
billboard.rotation = -Cesium.Math.PI_OVER_TWO;
// Example 3.
// Reset the aligned axis
billboard.alignedAxis = Cesium.Cartesian3.ZERO;
color : Color
获取或设置与公告牌纹理相乘的颜色。这有两个常见的用例。第一, 相同的白色纹理可能会被许多不同的广告牌使用,每一个都有不同的颜色,以创造 COL
red
广告牌。其次,颜色的alpha
成分可以用来使广告牌半透明,如下所示。
0.0
的alpha使公告牌透明,而1.0
使公告牌不透明。
default ![]() |
alpha : 0.5 ![]() |
green
、blue
和alpha value
由值的红色、绿色表示,
蓝色和alpha属性,如示例1所示。这些部件的范围为0.0
(无强度)至1.0
(全强度)。Examples:
// Example 1. Assign yellow.
b.color = Cesium.Color.YELLOW;
// Example 2. Make a billboard 50% translucent.
b.color = new Cesium.Color(1.0, 1.0, 1.0, 0.5);
distanceDisplayCondition : DistanceDisplayCondition
-
Default Value:
undefined
eyeOffset : Cartesian3
获取或设置应用于e
y
e坐标的三维笛卡尔偏移量。眼睛坐标是左手的
坐标系,其中x
指向观看者的右侧,y指向上,并且
z
指向屏幕。眼睛坐标使用与世界坐标和模型坐标相同的比例,
通常是米。
眼偏移通常用于在同一位置排列多个广告牌或物体,例如
在相应的三维模型上方放置一个广告牌。
下面,广告牌被定位在地球的中心,但眼睛的偏移使它总是
无论观测者或地球的方位如何,都会出现在地球的顶部。
![]() |
![]() |
b.eyeOffset = new Cartesian3(0.0, 8000000.0, 0.0);
heightReference : HeightReference
-
Default Value:
HeightReference.NONE
horizontalOrigin : HorizontalOrigin
获取或设置此公告牌的水平原点,它确定公告牌是否 在其锚定位置的左侧、中心或右侧。

Example:
// Use a bottom, left origin
b.horizontalOrigin = Cesium.HorizontalOrigin.LEFT;
b.verticalOrigin = Cesium.VerticalOrigin.BOTTOM;
Gets or sets the image to be used for this billboard. If a texture has already been created for the given image, the existing texture is used.
This property can be set to a loaded Image, a URL which will be loaded as an Image automatically, a canvas, or another billboard's image property (from the same billboard collection).
Example:
// load an image from a URL
b.image = 'some/image/url.png';
// assuming b1 and b2 are billboards in the same billboard collection,
// use the same image for both billboards.
b2.image = b1.image;
pixelOffset : Cartesian2
获取或设置屏幕空间中距此公告牌原点的pi
x
el偏移量。这是常见的y
在同一位置对齐多个广告牌和标签,如图像和文本。这个
屏幕空间原点是画布的左上角;x从
从右到下,从右到下依次递增。
default ![]() |
b.pixeloffset = new Cartesian2(50, 25); ![]() |
pixelOffsetScaleByDistance : NearFarScalar
NearFarScalar#nearValue
和
NearFarScalar#farValue
,摄像机距离在上下限范围内
指定的NearFarScalar#near
和NearFarScalar#far
。
在这些范围之外,公告牌的像素偏移比例保持在最近的边界。如果未定义,
pixelOffsetScaleByDistance将被禁用。Examples:
// Example 1.
// Set a billboard's pixel offset scale to 0.0 when the
// camera is 1500 meters from the billboard and scale pixel offset to 10.0 pixels
// in the y direction the camera distance approaches 8.0e6 meters.
b.pixelOffset = new Cesium.Cartesian2(0.0, 1.0);
b.pixelOffsetScaleByDistance = new Cesium.NearFarScalar(1.5e2, 0.0, 8.0e6, 10.0);
// Example 2.
// disable pixel offset by distance
b.pixelOffsetScaleByDistance = undefined;
position : Cartesian3
true
时,此公告牌已准备好渲染,即图像
已下载并创建WebGL资源。-
Default Value:
false
获取或设置与公告牌的图像大小(以像素为单位)相乘的统一比例。 比例尺
1.0
不会改变广告牌的大小;比例尺大于
1.0
放大广告牌;小于1.0
的正比例缩小
广告牌。

From left to right in the above image, the scales are
0.5
, 1.0
,
and 2.0
.
scaleByDistance : NearFarScalar
NearFarScalar#nearValue
和
NearFarScalar#farValue
,摄像机距离在上下限范围内
指定的NearFarScalar#near
和NearFarScalar#far
。
在这些范围之外,广告牌的刻度保持在最近的范围内。如果未定义,
scaleByDistance将被禁用。Examples:
// Example 1.
// Set a billboard's scaleByDistance to scale by 1.5 when the
// camera is 1500 meters from the billboard and disappear as
// the camera distance approaches 8.0e6 meters.
b.scaleByDistance = new Cesium.NearFarScalar(1.5e2, 1.5, 8.0e6, 0.0);
// Example 2.
// disable scaling by distance
b.scaleByDistance = undefined;
-
Default Value:
true
true
以米为单位调整广告牌的尺寸;
否则,大小以像素为单位。-
Default Value:
false
translucencyByDistance : NearFarScalar
NearFarScalar#nearValue
和
NearFarScalar#farValue
,摄像机距离在上下限范围内
指定的NearFarScalar#near
和NearFarScalar#far
。
在这些范围之外,广告牌的半透明性保持在最近的边界。如果未定义,
半透明ByDistance将被禁用。Examples:
// Example 1.
// Set a billboard's translucency to 1.0 when the
// camera is 1500 meters from the billboard and disappear as
// the camera distance approaches 8.0e6 meters.
b.translucencyByDistance = new Cesium.NearFarScalar(1.5e2, 1.0, 8.0e6, 0.0);
// Example 2.
// disable translucency by distance
b.translucencyByDistance = undefined;
verticalOrigin : VerticalOrigin
获取或设置此公告牌的垂直原点,它确定公告牌是否 在其锚位置的上方、下方或中心。

Example:
// Use a bottom, left origin
b.horizontalOrigin = Cesium.HorizontalOrigin.LEFT;
b.verticalOrigin = Cesium.VerticalOrigin.BOTTOM;
Methods
computeScreenSpacePosition(scene, result) → Cartesian2
y
6E和pix
el偏移。
屏幕空间原点是画布的左上角;x从
从右到下,从右到下依次递增。Name | Type | Description |
---|---|---|
scene |
Scene | 现场。 |
result |
Cartesian2 | optional 要将结果存储到的对象。 |
Returns:
Throws:
-
DeveloperError :广告牌必须在集合中。
Example:
console.log(b.computeScreenSpacePosition(scene).toString());
See:
Name | Type | Description |
---|---|---|
other |
Billboard | 比较平等的广告牌。 |
Returns:
true
;否则为false
。Sets the image to be used for this billboard. If a texture has already been created for the given id, the existing texture is used.
This function is useful for dynamically creating textures that are shared across many billboards. Only the first billboard will actually call the function and create the texture, while subsequent billboards created with the same id will simply re-use the existing texture.
To load an image from a URL, setting the Billboard#image
property is more convenient.
Name | Type | Description |
---|---|---|
id |
String | 图像的id。这可以是唯一标识图像的任何字符串。 |
image |
HTMLImageElement | HTMLCanvasElement | String | Resource | Billboard.CreateImageCallback | 要加载的图像。此参数 可以是加载的图像,也可以是画布,URL将作为图像自动加载, 或者调用一个函数来创建图像,如果它还没有加载。 |
Example:
// create a billboard image dynamically
function drawImage(id) {
// create and draw an image using a canvas
var canvas = document.createElement('canvas');
var context2D = canvas.getContext('2d');
// ... draw image
return canvas;
}
// drawImage will be called to create the texture
b.setImage('myImage', drawImage);
// subsequent billboards created in the same collection using the same id will use the existing
// texture, without the need to create the canvas or draw the image
b2.setImage('myImage', drawImage);
Name | Type | Description |
---|---|---|
id |
String | 要使用的映像的id。 |
subRegion |
BoundingRectangle | 图像的子区域。 |
Throws:
-
RuntimeError :带id的图像必须在图集中
Type Definitions
Cesium.Billboard.CreateImageCallback(id) → HTMLImageElement|HTMLCanvasElement|Promise.<(HTMLImageElement|HTMLCanvasElement)>
Name | Type | Description |
---|---|---|
id |
String | 要加载的图像的标识符。 |