Billboard

Billboard

new Cesium.Billboard ()

创建了位于3D场景中的视口对齐图像并使用 BillboardCollection 进行渲染。创建一个广告牌及其首字母通过调用 BillboardCollection #add 来设置属性。
示例广告牌
Performance:

读取属性(例如 Billboard #show )是固定时间。分配给属性是固定时间,但结果是调用 BillboardCollection#update 时的CPU到GPU流量。每个广告牌的流量是无论更新了多少属性,都是一样的。如果集合中的大多数广告牌都需要更新后,使用 BillboardCollection #removeAll 清除集合可能更有效率并添加新的广告牌而不是修改每个广告牌。

Throws:
  • DeveloperError :scaleByDistance.far必须大于scaleByDistance.near
  • DeveloperError :translucencyByDistance.far必须大于translucencyByDistance.near
  • DeveloperError :pixelOffsetScaleByDistance.far必须大于pixelOffsetScaleByDistance.near
  • DeveloperError :distanceDisplayCondition.far必须大于distanceDisplayCondition.near
Demo:
See:

Members

获取或设置世界空间中对齐的轴。对齐轴是广告牌向上矢量指向的单位矢量。默认值为零向量,这意味着广告牌与屏幕向上矢量对齐。
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;
获取或设置与广告牌纹理相乘的颜色。这有两个常见的用例。第一,相同的白色纹理可以被许多不同的广告牌使用,每个广告牌都有不同的颜色来创建彩色广告牌。其次,颜色的alpha分量可用于使广告牌半透明,如下所示。 0.0 的alpha使广告牌透明, 1.0 使广告牌变得不透明。
default alpha:0.5 < /TD>
红色,绿色,蓝色和alpha值由 valueredgreen 表示, bluealpha 属性,如示例1所示。这些组件的范围从 0.0 (无强度)到 1.0 (全强度)。
Examples:
// Example 1. Assign yellow.
b.color = Cesium.Color.YELLOW;
// Example 2. Make a billboard 50{ac3c4da2cd0600a7fb5dd7ece3d30a0eed29da11cf2830143610191d982c65a1} translucent.
b.color = new Cesium.Color(1.0, 1.0, 1.0, 0.5);

disableDepthTestDistance : Number

获取或设置从摄像机到禁用深度测试的距离,例如,防止对地形进行裁剪。设置为零时,始终应用深度测试。设置为Number.POSITIVE_INFINITY时,永远不会应用深度测试。
获取或设置指定此广告牌将显示的距离相机的距离的条件。
Default Value: undefined
获取或设置应用于眼睛坐标中此广告牌的3D笛卡尔偏移。眼睛坐标是左撇子坐标系,其中 x 指向观察者的右侧, y 指向,并且 z 指向屏幕。眼睛坐标使用与世界和模型坐标相同的比例,这通常是米。 眼睛偏移通常用于在同一位置布置多个广告牌或物体,例如在相应的3D模型上方安排一个广告牌。 在下面,广告牌位于地球的中心,但眼睛偏移使它始终无论观者或地球的方向如何,都会出现在地球的顶部。
b.eyeOffset = new Cartesian3(0.0,8000000.0,0.0);

height : Number

获取或设置广告牌的高度。如果未定义,将使用图像高度。
获取或设置此广告牌的高度参考。
Default Value: HeightReference.NONE
获取或设置此广告牌的水平原点,以确定广告牌是否为其锚位置的左侧,中间或右侧。
Example:
// Use a bottom, left origin
b.horizontalOrigin = Cesium.HorizontalOrigin.LEFT;
b.verticalOrigin = Cesium.VerticalOrigin.BOTTOM;
获取或设置拾取广告牌时返回的用户定义对象。

image : String

获取或设置要用于此广告牌的图像。如果已经为其创建了纹理给定图像,使用现有纹理。

此属性可以设置为加载的Image,一个将自动加载为Image的URL,画布或其他广告牌的图像属性(来自同一个广告牌集合)。

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;
从此广告牌的原点获取或设置屏幕空间中的像素偏移量。这是常用的在同一位置对齐多个广告牌和标签,例如图像和文本。该屏幕空间原点是画布的左上角; x 增加从左到右, y 从上到下增加。
默认 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;
获取或设置此广告牌的笛卡尔位置。

readonly ready : Boolean

true 时,该广告牌已准备好呈现,即图像已下载并创建WebGL资源。
Default Value: false

rotation : Number

获取或设置以弧度为单位的旋转角度。

scale : Number

获取或设置与广告牌的图像大小相乘的统一比例(以像素为单位)。 1.0 的比例不会改变广告牌的大小;比例大于 1.0 扩大广告牌;小于 1.0 的正尺度缩小广告牌。
在上图中从左到右,比例为 0.51.0 ,和 2.0
根据广告牌与相机的距离,获取或设置广告牌的近距离和远距离缩放属性。广告牌的比例将在 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;

show : Boolean

确定是否显示此广告牌。用它来隐藏或显示广告牌删除它并将其重新添加到集合中。
Default Value: true

sizeInMeters : Boolean

获取或设置广告牌大小是以米还是像素为单位。 true 以米为单位调整广告牌的大小;否则,大小以像素为单位。
Default Value: false

translucencyByDistance : NearFarScalar

根据广告牌与相机的距离,获取或设置广告牌的近距离和远距离半透明属性。广告牌的半透明度将在 NearFarScalar #nearValue 之间进行插值, NearFarScalar#farValue ,而相机距离在上限和下限范围内指定的 NearFarScalar#near NearFarScalar#far 代码> 。在这些范围之外,广告牌的半透明度仍然被限制在最近的范围内。如果未定义,translucencyByDistance将被禁用。
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;
获取或设置此广告牌的垂直原点,确定广告牌是否为到其上方,下方或其锚定位置的中心。
Example:
// Use a bottom, left origin
b.horizontalOrigin = Cesium.HorizontalOrigin.LEFT;
b.verticalOrigin = Cesium.VerticalOrigin.BOTTOM;

width : Number

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

Methods

computeScreenSpacePosition (scene, result ) Cartesian2

计算广告牌原点的屏幕空间位置,同时考虑眼图和像素偏移。屏幕空间原点是画布的左上角; x 增加从左到右, y 从上到下增加。
NameTypeDescription
sceneScene现场。
resultCartesian2可选 要存储结果的对象。
Returns:
广告牌的屏幕空间位置。
Throws:
Example:
console.log(b.computeScreenSpacePosition(scene).toString());
See:

equals (other) Boolean

确定此广告牌是否等于另一个广告牌。如果所有属性都是平等的广告牌是平等的。不同馆藏中的广告牌可以是平等的。
NameTypeDescription
otherBillboard比较平等的广告牌。
Returns:
返回真,如果广告牌是平等的;除此以外,返回假      。

setImage (id, image)

设置要用于此广告牌的图像。如果已经为其创建了纹理给定id,使用现有纹理。

此功能对于动态创建在许多广告牌上共享的纹理非常有用。只有第一个广告牌实际上会调用该函数并创建纹理,而后续使用相同ID创建的广告牌将简单地重复使用现有纹理。

要从URL加载图像,设置 Billboard#image 属性会更方便。

NameTypeDescription
idString图像的ID。这可以是唯一标识图像的任何字符串。
imageImage | Canvas | String | Resource | Billboard~CreateImageCallback要加载的图像。这个参数       可以是加载的Image或Canvas,一个将自动加载为Image的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);

setImageSubRegion (id, subRegion)

使用具有给定id的图像的子区域作为该广告牌的图像,以左下角的像素为单位。
NameTypeDescription
idString要使用的图像的ID。
subRegionBoundingRectangle图像的子区域。
Throws:

Type Definitions

CreateImageCallback (id) Image|Canvas|Promise.<(Image|Canvas)>

创建图像的功能。
NameTypeDescription
idString要加载的图像的标识符。
Returns:
图像,或将解析为图像的承诺。
Documentation generated by JSDoc 3.5.5 翻译:http://cesium.xin

发表评论

电子邮件地址不会被公开。 必填项已用*标注