CloudCollection

new Cesium.CloudCollection(options)

3D 场景中的云的可渲染集合。


积云示例


使用 云 在集合中添加和删除 CloudCollection#add and CloudCollection#remove.
Name Type Description
options object optional 对象,具有以下属性:
Name Type Default Description
show boolean true optional 是否显示云。
noiseDetail number 16.0 optional 噪声纹理中所需的细节量。
noiseOffset number Cartesian3.ZERO optional 噪声纹理中数据的所需平移。
debugBillboards boolean false optional 仅用于调试。确定公告板是否使用不透明颜色渲染。
debugEllipsoids boolean false optional 仅用于调试。确定云是否将渲染为不透明的椭球体。
Example:
// Create a cloud collection with two cumulus clouds
const clouds = scene.primitives.add(new Cesium.CloudCollection());
clouds.add({
  position : new Cesium.Cartesian3(1.0, 2.0, 3.0),
  maximumSize: new Cesium.Cartesian3(20.0, 12.0, 8.0)
});
clouds.add({
  position : new Cesium.Cartesian3(4.0, 5.0, 6.0),
  maximumSize: new Cesium.Cartesian3(15.0, 9.0, 9.0),
  slice: 0.5
});
Demo:
See:

Members

debugBillboards : boolean

此属性仅用于调试;它不用于生产用途,也未进行优化。

为了调试,使用一种不透明颜色渲染公告板。

Default Value: false

debugEllipsoids : boolean

此属性仅用于调试;它不用于生产用途,也未进行优化。

为了调试,将云绘制为不透明的单色椭球体。 如果 debugBillboards 也为 true,则椭球体将绘制在公告板的顶部。

Default Value: false
返回此集合中的云数。

控制在预计算的噪点纹理中捕获的细节量 用于渲染积云。为了使纹理可平铺, 这必须是 2 的幂。为获得最佳效果,请将其设置为 2 的幂数 介于 8.032.0(含)之间。

clouds.noiseDetail = 8.0;
clouds.noiseDetail = 32.0;
Default Value: 16.0

将平移应用于噪波纹理坐标以生成不同的数据。 如果默认噪声没有生成好看的云,则可以修改此项。

default
clouds.noiseOffset = new Cesium.Cartesian3(10, 20, 10);
Default Value: Cartesian3.ZERO
确定是否显示此集合中的公告板。
Default Value: true

Methods

创建具有指定初始属性的云并将其添加到集合中。 将返回添加的云,以便以后可以对其进行修改或从集合中删除。
Performance:

调用 add 是预期的常数时间。 但是,集合的顶点缓冲区 被重写 - 一个 O(n) 操作,也会产生 CPU 到 GPU 的开销。 为 最佳性能,在调用 Update 之前添加尽可能多的云。

Name Type Description
options object optional 描述云属性的模板,如示例 1 所示。
Returns:
添加到集合中的云。
Throws:
Examples:
// Example 1:  Add a cumulus cloud, specifying all the default values.
const c = clouds.add({
  show : true,
  position : Cesium.Cartesian3.ZERO,
  scale : new Cesium.Cartesian2(20.0, 12.0),
  maximumSize: new Cesium.Cartesian3(20.0, 12.0, 12.0),
  slice: -1.0,
  cloudType : CloudType.CUMULUS
});
// Example 2:  Specify only the cloud's cartographic position.
const c = clouds.add({
  position : Cesium.Cartesian3.fromDegrees(longitude, latitude, height)
});
See:

contains(cloud)boolean

检查此集合是否包含给定的云。
Name Type Description
cloud CumulusCloud optional 要检查的云。
Returns:
true(如果此集合包含云),否则为 false。
See:
销毁此对象持有的 WebGL 资源。 销毁对象允许确定性 释放 WebGL 资源,而不是依赖垃圾回收器来销毁这个对象。

一旦对象被销毁,就不应该使用它;调用 isDestroyed 将导致 DeveloperError 异常。 因此 将返回值 (undefined) 分配给对象,如示例中所示。
Throws:
Example:
clouds = clouds && clouds.destroy();
See:
返回集合中位于指定索引处的云。索引从 0 开始 并随着云的添加而增加。移除云会在之后移动所有云 它向左移动,更改其索引。此功能通常用于 CloudCollection#length 迭代集合中的所有云。
Performance:

预期恒定时间。如果云已从集合中删除,并且 CloudCollection#update 未调用,则隐式 O(n) 执行操作。

Name Type Description
index number 云的从零开始的索引。
Returns:
指定索引处的云。
Throws:
Example:
// Toggle the show property of every cloud in the collection
const len = clouds.length;
for (let i = 0; i < len; ++i) {
  const c = clouds.get(i);
  c.show = !c.show;
}
See:
如果此对象已销毁,则返回 true;否则为 false。

如果此对象已销毁,则不应使用;调用 isDestroyed 将导致 DeveloperError 异常。
Returns:
true,如果此对象被销毁;否则为 false
See:

remove(cloud)boolean

从集合中移除云。
Name Type Description
cloud CumulusCloud 要移除的云。
Returns:
true(如果云已被删除);如果在集合中找不到云,则为 false
Throws:
Example:
const c = clouds.add(...);
clouds.remove(c);  // Returns true
See:
从集合中删除所有云。
Performance:

O(n) 去除所有云层更有效 从集合中,然后添加新的集合,而不是完全创建一个新集合。

Throws:
Example:
clouds.add(...);
clouds.add(...);
clouds.removeAll();
See:
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.