OrbPro2 a Cesium distribution

VirtualSunCollection

new Cesium.VirtualSunCollection(options)

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:
Name Type Description
scene Scene The scene that owns this collection.
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

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:
Example:
const virtualSun = scene.virtualSuns.add({
  direction: new Cesium.Cartesian3(0, 0, -1),
  castShadows: true,
  softShadows: true
});

contains(virtualSun)boolean

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:
Example:
const virtualSun = scene.virtualSuns.get(0);
Returns true if this object was destroyed; otherwise, false.
Returns:

remove(virtualSun)boolean

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();
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.