CloudCollection

new Cesium.CloudCollection(options)

A renderable collection of clouds in the 3D scene.


Example cumulus clouds


Clouds are added and removed from the collection using CloudCollection#add and CloudCollection#remove.
参数名称 类型 描述信息
options object 可选 Object with the following properties:
参数名称 类型 默认值 描述信息
show boolean true 可选 Whether to display the clouds.
noiseDetail number 16.0 可选 Desired amount of detail in the noise texture.
noiseOffset number Cartesian3.ZERO 可选 Desired translation of data in noise texture.
debugBillboards boolean false 可选 For debugging only. Determines if the billboards are rendered with an opaque color.
debugEllipsoids boolean false 可选 For debugging only. Determines if the clouds will be rendered as opaque ellipsoids.
使用示例:
// 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:
参考:

成员(属性)

debugBillboards : boolean

This property is for debugging only; it is not for production use nor is it optimized.

Renders the billboards with one opaque color for the sake of debugging.

默认值: false

debugEllipsoids : boolean

This property is for debugging only; it is not for production use nor is it optimized.

Draws the clouds as opaque, monochrome ellipsoids for the sake of debugging. If debugBillboards is also true, then the ellipsoids will draw on top of the billboards.

默认值: false
Returns the number of clouds in this collection.

Controls the amount of detail captured in the precomputed noise texture used to render the cumulus clouds. In order for the texture to be tileable, this must be a power of two. For best results, set this to be a power of two between 8.0 and 32.0 (inclusive).

clouds.noiseDetail = 8.0;
clouds.noiseDetail = 32.0;
默认值: 16.0

Applies a translation to noise texture coordinates to generate different data. This can be modified if the default noise does not generate good-looking clouds.

default
clouds.noiseOffset = new Cesium.Cartesian3(10, 20, 10);
默认值: Cartesian3.ZERO
Determines if billboards in this collection will be shown.
默认值: true

方法

Creates and adds a cloud with the specified initial properties to the collection. The added cloud is returned so it can be modified or removed from the collection later.
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.

参数名称 类型 描述信息
options object 可选 A template describing the cloud's properties as shown in Example 1.
返回值:
The cloud that was added to the collection.
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
使用示例s:
// 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)
});
参考:

contains(cloud)boolean

Check whether this collection contains a given cloud.
参数名称 类型 描述信息
cloud CumulusCloud 可选 The cloud to check for.
返回值:
true if this collection contains the cloud, false otherwise.
参考:
Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.

Once an object is destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception. Therefore, assign the return value (undefined) to the object as done in the example.
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
使用示例:
clouds = clouds && clouds.destroy();
参考:
Returns the cloud in the collection at the specified index. Indices are zero-based and increase as clouds are added. Removing a cloud shifts all clouds after it to the left, changing their indices. This function is commonly used with CloudCollection#length to iterate over all the clouds in the collection.
Performance:

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

参数名称 类型 描述信息
index number The zero-based index of the cloud.
返回值:
The cloud at the specified index.
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
使用示例:
// 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;
}
参考:
Returns true if this object was destroyed; otherwise, false.

If this object was destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception.
返回值:
true if this object was destroyed; otherwise, false.
参考:

remove(cloud)boolean

Removes a cloud from the collection.
参数名称 类型 描述信息
cloud CumulusCloud The cloud to remove.
返回值:
true if the cloud was removed; false if the cloud was not found in the collection.
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
使用示例:
const c = clouds.add(...);
clouds.remove(c);  // Returns true
参考:
Removes all clouds from the collection.
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:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
使用示例:
clouds.add(...);
clouds.add(...);
clouds.removeAll();
参考: