internal constructor new Cesium.Billboard(options, billboardCollection)

广告牌被创建和初始 properties are set by calling BillboardCollection#add. Do not call the constructor directly.
在3D 场景中定位的视图端口映像, 将创建 and rendered using a BillboardCollection.


Example billboards
Performance:

Reading a property, e.g., Billboard#show, is constant time. 分配给财产是持续的时间,但会导致 CPU to GPU traffic when BillboardCollection#update is called. The per-billboard traffic is 同样的,无论更新了多少个属性。 如果收藏品中的大多数广告牌需要 updated, it may be more efficient to clear the collection with BillboardCollection#removeAll 并添加新的广告牌,而不是修改每个广告牌.

Name Type Description
options Billboard.ConstructorOptions 描述初始化选项的对象
billboardCollection BillboardCollection 公告牌收集实例
Throws:
  • DeveloperError : scaleByDistance.far must be greater than scaleByDistance.near
  • DeveloperError : translucencyByDistance.far must be greater than translucencyByDistance.near
  • DeveloperError : pixelOffsetScaleByDistance.far must be greater than pixelOffsetScaleByDistance.near
  • DeveloperError : distanceDisplayCondition.far must be greater than distanceDisplayCondition.near
Demo:
See:

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

获得或设置与公告牌的纹理相乘的颜色. 这有两个常用的案例。 首先,我们.., 同样的白色纹理可能被许多不同的告示牌使用,每个牌子都有不同的颜色,用来创建 彩色广告牌. 第二,颜色的α成分可以用来使公告牌半透明如下所示. NT+0 0.0 NT+1 的α使得公告牌透明,而 NT+2 1.0 NT+3 使得公告牌不透明.

default
alpha : 0.5

红色,绿色,蓝色,和α值由 , 绿色 表示, 如例1所示,NT+0 蓝色 NT+1 ,和 NT+2 alpha NT+3 属性. 这些组件范围从 NT 4 0.0 NT 5 (无强度)至 NT 0 1.0 NT 1 (全强度).
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);

disableDepthTestDistance : number|undefined

获取或设定与相机的距离,超过此距离,深度测试被解析——至, 例如,防止对地形进行剪切。 当设置为 NT 0 未定义 NT 1 或 0 ,深度测试始终应用. 设定为 Number.POSITIVE_INFINITY, the depth test is never applied.
Default Value: undefined

distanceDisplayCondition : DistanceDisplayCondition

获取或设置条件,指定该公告牌将显示的距离与相机的距离.
Default Value: undefined

eyeOffset : Cartesian3

在眼坐标上获取或设置适用于这个告示牌的3D笛卡尔偏移. 眼睛坐标是左手的 坐标系统,其中 NT 0 x NT 1 指向观众的右侧, NT 2 y NT 3 指向上方,以及 z points into the screen. Eye coordinates use the same scale as world and model coordinates, 这是典型的米.

双眼偏移通常用于在同一位置安排多个告示牌或对象, e.g 在相应的3D模型上方安排一个广告牌.

下面,广告牌的位置是地球的中心 但一个眼睛的偏移使得它总是 无论观众或地球的定位如何 都出现在地球顶部.

b.eyeOffset = new Cartesian3(0.0, 8000000.0, 0.0);

height : number|undefined

获得或设置一个高度的公告牌. 如果未定义,将使用图像高度 .

heightReference : HeightReference

获取或设定此公告牌的高度参考.
Default Value: HeightReference.NONE

horizontalOrigin : HorizontalOrigin

获得或设定此公告牌的横向来源,从而决定公告牌是否是 在它的锚位置的左、中或右侧.


Example:
// Use a bottom, left origin
b.horizontalOrigin = Cesium.HorizontalOrigin.LEFT;
b.verticalOrigin = Cesium.VerticalOrigin.BOTTOM;

id : *

获取或设置在选取公告牌时返回的自定义对象.

image : string

获取或设置用于此公告牌的图像. 如果已经为 给定图像,使用现有的纹理.

此属性可设置为已装入的图像, 将自动装入为图像的 NT% 0 , a画布,或另一个公告牌的图像属性(来自同一公告牌收藏).

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

从这个公告牌的源头获取或设置屏幕空间中的像素偏移. 这是常用的 在相同位置对齐多个告示牌和标签, e.g .,一个图像和文本. 那个 屏幕空间源是画布的顶部,左角; NT 0 x NT 1 从 左到右,和 NT 0 Y NT 1 从上到下增加.

default
b.pixeloffset = new Cartesian2(50, 25);
告示牌的起源以黄点表示.

pixelOffsetScaleByDistance : NearFarScalar

根据Billboard与相机的距离,获得或设置近和远像素抵消一个Billboard的缩放属性. A billboard's pixel offset will be scaled between the NearFarScalar#nearValue and NearFarScalar#farValue while the camera distance falls within the lower and upper bounds of the specified NearFarScalar#near and NearFarScalar#far. 在这些范围之外,广告牌的像素抵消尺度仍被夹在最接近的界限上。 如果未定义, 将禁用像素Offset ScaleByDistance .
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

获得或设定这个公告牌的笛卡尔位置.

readonly ready : boolean

当 NT 0 real NT 1 时,这个告示牌准备渲染 NT 2 has been downloaded and the WebGL resources are created.
Default Value: false

rotation : number

用弧度获取或设置旋转角.

scale : number

获得或设置与公告牌的图像大小成像素乘以的统一比例尺. 比例为 NT 0 1.0 NT 1 ========= NT#0 1.0 NT#+1 扩大公告牌;正比值小于 NT 2 1.0 NT +3 缩小 the billboard.


从左到右在以上图像中,比例尺为 NT 0 0.5 NT 1 , NT 2 1.0 NT Q 3 ,....., 和 2.0 .

scaleByDistance : NearFarScalar

根据Billboard与相机的距离,获取或设定Billboard的近距离和远距离的属性. A billboard's scale will interpolate between the NearFarScalar#nearValue and NearFarScalar#farValue while the camera distance falls within the lower and upper bounds of the specified NearFarScalar#near and NearFarScalar#far. 在这些范围之外,广告牌的标尺仍被夹在距离最近的界限上。 如果未定义, 缩放ByDistance 将被禁用.
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;

show : boolean

确定是否将显示此公告牌 。 用来隐藏或显示广告牌, 相反 将其删除并重新添加到收藏中.
Default Value: true

sizeInMeters : boolean

如果公告牌的尺寸是公尺或像素,则获得或设定. 以米计的广告牌尺寸; 否则,大小为像素.
Default Value: false

splitDirection : SplitDirection

获得或设置此公告牌的 SplitDirection .
Default Value: SplitDirection.NONE

translucencyByDistance : NearFarScalar

根据公告牌与相机的距离,获得或设置一个Billboard的近和远透明特性. A billboard's translucency will interpolate between the NearFarScalar#nearValue and NearFarScalar#farValue while the camera distance falls within the lower and upper bounds of the specified NearFarScalar#near and 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;

width : number|undefined

获得或设置广告牌的宽度. 如果未定义,将使用图像宽度 .

Methods

computeScreenSpacePosition(scene, result)Cartesian2

计算公告牌百强单曲榜原产地的屏幕-空间位置,同时考虑到眼和像素的抵消. 屏幕空间源是画布的顶端,左角; NT 0 x NT 1 从 左到右,和 NT 0 Y NT 1 从上到下增加.
Name Type Description
scene Scene The scene.
result Cartesian2 optional 存储结果的对象 .
Returns:
公告牌的屏幕-空间位置.
Throws:
Example:
console.log(b.computeScreenSpacePosition(scene).toString());
See:

equals(other)boolean

确定这个公告牌是否等于另一个公告牌. 如果广告牌的所有属性都是平等的 平等无边. 不同集合中的告示牌可以平等.
Name Type Description
other Billboard optional 告示牌来比较平等.
Returns:
如果告示牌是相等的,则使用 NT#0 real NT 1 ;否则, NT 2 false NT 3 .

setImage(id, image)

设置用于此公告牌的图像 。 如果已经为 ,使用现有的纹理.

这个功能对于动态生成在许多公告牌上共享的纹理很有用. 只有第一个告示牌将实际调用函数并创建纹理,而随后 用同样的id创建的告示牌会简单地重新使用现有的纹理.

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 要装入的图像 。 此参数 可以是装入的图像,也可以是自动装入的图像, 或一个功能,如果图像还没有被装入,它将被调用来创建图像 .
Example:
// create a billboard image dynamically
function drawImage(id) {
  // create and draw an image using a canvas
  const canvas = document.createElement('canvas');
  const 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);

setImageSubRegion(id, subRegion)

使用带有给定的ID的图像分区作为这个广告牌的图像, 从左下方以像素计量.
Name Type Description
id string 要使用的图像的标识 .
subRegion BoundingRectangle 影像的分区.
Throws:

Type Definitions

Cesium.Billboard.ConstructorOptions

Billboard 构造器第一段的初始化选项
Properties:
Name Type Attributes Default Description
position Cartesian3 公告牌的笛卡尔位置.
id * <optional>
A user-defined object to return when the billboard is picked with Scene#pick.
show boolean <optional>
true Determines if this billboard will be shown.
image string | HTMLImageElement | HTMLCanvasElement <optional>
装入的 HTML ImageElement, ImageData, 或用于公告牌的图像的url 到一个图像.
scale number <optional>
1.0 一个数字,指定与公告牌的图像大小乘以像素的一致比例.
pixelOffset Cartesian2 <optional>
Cartesian2.ZERO A Cartesian2 Specifying the pixel offset in screen space from the origin of this billboard.
eyeOffset Cartesian3 <optional>
Cartesian3.ZERO A Cartesian3 Specifying the 3D Cartesian offset applied to this billboard in eye coordinates.
horizontalOrigin HorizontalOrigin <optional>
HorizontalOrigin.CENTER A HorizontalOrigin Specifying the horizontal origin of this billboard.
verticalOrigin VerticalOrigin <optional>
VerticalOrigin.CENTER A VerticalOrigin Specifying the vertical origin of this billboard.
heightReference HeightReference <optional>
HeightReference.NONE A HeightReference Specifying the height reference of this billboard.
color Color <optional>
Color.WHITE A Color Specifying the color that is multiplied with the billboard's texture.
rotation number <optional>
0 A number specifying the rotation angle in radians.
alignedAxis Cartesian3 <optional>
Cartesian3.ZERO A Cartesian3 Specifying the aligned axis in world space.
sizeInMeters boolean <optional>
一个布尔指定广告牌大小是公尺还是像素.
width number <optional>
指定广告牌宽度的编号. 如果未定义,将使用图像宽度 .
height number <optional>
标注广告牌高度的编号. 如果未定义,将使用图像高度 .
scaleByDistance NearFarScalar <optional>
A NearFarScalar Specifying near and far scaling properties of a Billboard based on the billboard's distance from the camera.
translucencyByDistance NearFarScalar <optional>
A NearFarScalar Specifying near and far translucency properties of a Billboard based on the billboard's distance from the camera.
pixelOffsetScaleByDistance NearFarScalar <optional>
A NearFarScalar Specifying near and far pixel offset scaling properties of a Billboard based on the billboard's distance from the camera.
imageSubRegion BoundingRectangle <optional>
A BoundingRectangle Specifying the sub-region of the image to use for the billboard, rather than the entire image.
distanceDisplayCondition DistanceDisplayCondition <optional>
A DistanceDisplayCondition Specifying the distance from the camera at which this billboard will be displayed.
disableDepthTestDistance number <optional>
距离照相机的距离,超出这个距离的深度测试被禁用——例如,防止对地形进行剪切.
splitDirection SplitDirection <optional>
A SplitDirection Specifying the split property of the billboard.

Cesium.Billboard.CreateImageCallback(id)HTMLImageElement|HTMLCanvasElement|Promise.<(HTMLImageElement|HTMLCanvasElement)>

创建图像的函数 .
Name Type Description
id string 要加载的图像标识符 .
Returns:
图像,或承诺 将决定一个图像.
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.