CloudCollection

new Cesium.CloudCollection(options)

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


积云示例


Clouds are added and removed from the collection using 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 的幂。为了获得最佳效果,请将此值设为 8.032.0 之间(含)的 2 的幂。

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:

Calling add is expected constant time. However, the collection's vertex buffer is rewritten - an O(n) operation that also incurs CPU to GPU overhead. For best performance, add as many clouds as possible before calling 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:
返回集合中指定索引处的云。索引从零开始, 并随着云的添加而增加。移除一朵云会使它之后的所有云向左移动, 从而改变它们的索引。此函数通常与 CloudCollection#length 配合使用,以遍历集合中的所有云。
Performance:

Expected constant time. If clouds were removed from the collection and CloudCollection#update was not called, an implicit O(n) operation is performed.

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). It is more efficient to remove all the clouds from a collection and then add new ones than to create a new collection entirely.

Throws:
Example:
clouds.add(...);
clouds.add(...);
clouds.removeAll();
See:
需要帮助?获取答案的最快方式是在 Cesium 论坛 上向社区和团队提问。