A collection of
VirtualSun instances that provide cascaded shadow maps
for directional lights. Virtual suns are automatically updated each frame and
their shadow maps are pushed to the frame state for rendering.
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
options |
object |
optional
Object with the following properties:
|
Example:
// Add multiple virtual suns for different light sources
const sun1 = scene.virtualSuns.add({
direction: new Cesium.Cartesian3(1, 0, -1)
});
const sun2 = scene.virtualSuns.add({
direction: new Cesium.Cartesian3(-1, 0, -1)
});
// Remove a specific virtual sun
scene.virtualSuns.remove(sun1);
// Remove all virtual suns
scene.virtualSuns.removeAll();
Members
The number of virtual suns in the collection.
Methods
add(options) → VirtualSun
Creates and adds a virtual sun to the collection.
| Name | Type | Description |
|---|---|---|
options |
object |
Options for the virtual sun. See VirtualSun constructor. |
Returns:
The newly created virtual sun.
Throws:
-
DeveloperError : options.direction is required.
Example:
const virtualSun = scene.virtualSuns.add({
direction: new Cesium.Cartesian3(0, 0, -1),
castShadows: true,
softShadows: true
});
Returns true if the collection contains the specified virtual sun.
| Name | Type | Description |
|---|---|---|
virtualSun |
VirtualSun | The virtual sun to check. |
Returns:
True if the collection contains the virtual sun.
Destroys the resources held by this object.
Returns:
Returns the virtual sun at the specified index.
| Name | Type | Description |
|---|---|---|
index |
number | The zero-based index of the virtual sun. |
Returns:
The virtual sun at the specified index.
Throws:
-
DeveloperError : index is required.
-
DeveloperError : index must be valid.
Example:
const virtualSun = scene.virtualSuns.get(0);
Returns true if this object was destroyed; otherwise, false.
Returns:
Removes a virtual sun from the collection.
| Name | Type | Description |
|---|---|---|
virtualSun |
VirtualSun | The virtual sun to remove. |
Returns:
True if the virtual sun was found and removed; false otherwise.
Example:
const success = scene.virtualSuns.remove(virtualSun);
Removes all virtual suns from the collection.
Example:
scene.virtualSuns.removeAll();