# CloudCollection

#### new Cesium.CloudCollection(options)
Scene/CloudCollection.js 101

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`.

Name | Type | Description
--- | --- | ---
`options` | Object | optional Object with the following properties:
Name | Type | Default | Description
--- | --- | --- | ---
`show` | Boolean | `true` | optional Whether to display the clouds.
`noiseDetail` | Number | `16.0` | optional Desired amount of detail in the noise texture.
`noiseOffset` | Number | `Cartesian3.ZERO` | optional Desired translation of data in noise texture.
`debugBillboards` | Boolean | `false` | optional For debugging only. Determines if the billboards are rendered with an opaque color.
`debugEllipsoids` | Boolean | `false` | optional For debugging only. Determines if the clouds will be rendered as opaque ellipsoids.

##### Example:

    // Create a cloud collection with two cumulus clouds
    var 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:

- Cesium Sandcastle Clouds Demo
- Cesium Sandcastle Cloud Parameters Demo

##### See:

- CloudCollection#add
- CloudCollection#remove
- CumulusCloud

### Members

#### debugBillboards : Boolean
Scene/CloudCollection.js 211

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.

Default Value: `false`

#### debugEllipsoids : Boolean
Scene/CloudCollection.js 225

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.

Default Value: `false`

#### length : Number
Scene/CloudCollection.js 235

Returns the number of clouds in this collection.

#### noiseDetail : Number
Scene/CloudCollection.js 140

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;`

Default Value: `16.0`

#### noiseOffset : Cartesian3
Scene/CloudCollection.js 164

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);`

Default Value: `Cartesian3.ZERO`

#### show : Boolean
Scene/CloudCollection.js 197

Determines if billboards in this collection will be shown.

Default Value: `true`

### Methods

#### add(options) → CumulusCloud
Scene/CloudCollection.js 286

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`.

Name | Type | Description
--- | --- | ---
`options` | Object | optional A template describing the cloud's properties as shown in Example 1.

##### Returns:

The cloud that was added to the collection.

##### Throws:

- DeveloperError : This object was destroyed, i.e., destroy() was called.

##### Examples:

    // Example 1:  Add a cumulus cloud, specifying all the default values.
    var 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.
    var c = clouds.add({
      position : Cesium.Cartesian3.fromDegrees(longitude, latitude, height)
    });

##### See:

- CloudCollection#remove
- CloudCollection#removeAll

#### contains(cloud) → Boolean
Scene/CloudCollection.js 396

Check whether this collection contains a given cloud.

Name | Type | Description
--- | --- | ---
`cloud` | CumulusCloud | optional The cloud to check for.

##### Returns:

true if this collection contains the cloud, false otherwise.

##### See:

- CloudCollection#get

#### destroy()
Scene/CloudCollection.js 982

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.

##### Example:

    clouds = clouds && clouds.destroy();

##### See:

- CloudCollection#isDestroyed

#### get(index) → CumulusCloud
Scene/CloudCollection.js 426

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.

Name | Type | Description
--- | --- | ---
`index` | Number | The zero-based index of the cloud.

##### Returns:

The cloud at the specified index.

##### Throws:

- DeveloperError : This object was destroyed, i.e., destroy() was called.

##### Example:

    // Toggle the show property of every cloud in the collection
    var len = clouds.length;
    for (var i = 0; i < len; ++i) {
      var c = clouds.get(i);
      c.show = !c.show;
    }

##### See:

- CloudCollection#length

#### isDestroyed() → Boolean
Scene/CloudCollection.js 962

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.

##### Returns:

`true` if this object was destroyed; otherwise, `false`.

##### See:

- CloudCollection#destroy

#### remove(cloud) → Boolean
Scene/CloudCollection.js 323

Removes a cloud from the collection.

Name | Type | Description
--- | --- | ---
`cloud` | CumulusCloud | The cloud to remove.

##### Returns:

`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.

##### Example:

    var c = clouds.add(...);
    clouds.remove(c);  // Returns true

##### See:

- CloudCollection#add
- CloudCollection#removeAll
- CumulusCloud#show

#### removeAll()
Scene/CloudCollection.js 351

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.

##### Example:

    clouds.add(...);
    clouds.add(...);
    clouds.removeAll();

##### See:

- CloudCollection#add
- CloudCollection#remove