Example cumulus clouds
Clouds are added and removed from the collection using
CloudCollection#add
and CloudCollection#remove
.
参数名称 | 类型 | 描述信息 | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
可选
Object with the following properties:
|
使用示例:
// 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:
参考:
成员(属性)
Renders the billboards with one opaque color for the sake of debugging.
-
默认值:
false
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
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
noiseOffset : Cartesian3
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
-
默认值:
true
方法
add(options) → CumulusCloud
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. |
返回值:
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)
});
参考:
参数名称 | 类型 | 描述信息 |
---|---|---|
cloud |
CumulusCloud | 可选 The cloud to check for. |
返回值:
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();
参考:
get(index) → CumulusCloud
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. |
返回值:
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;
}
参考:
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
.
参数名称 | 类型 | 描述信息 |
---|---|---|
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
参考:
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();