Readonly
allowWhen true
, each geometry instance will only be pickable with Scene#pick. When false
, GPU memory is saved. *
Blend value for region coloring.
The Appearance used to shade this primitive. Each geometry instance is shaded with the same appearance. Some appearances, like PerInstanceColorAppearance allow giving each instance unique properties.
Camera aspect ratio.
Readonly
asynchronousDetermines if the geometry instances will be created and batched on a web worker.
Movable entity marking the viewshed origin.
Readonly
compressWhen true
, geometry vertices are compressed, which will save memory.
When true
, the renderer frustum culls and horizon culls the primitive's commands
based on their bounding volume. Set this to false
for a small performance gain
if you are manually culling the primitive.
This property is for debugging only; it is not for production use nor is it optimized.
Draws the bounding sphere for each draw command in the primitive.
Bias value for shadow map precision.
The Appearance used to shade this primitive when it fails the depth test. Each geometry instance is shaded with the same appearance. Some appearances, like PerInstanceColorAppearance allow giving each instance unique properties.
When using an appearance that requires a color attribute, like PerInstanceColorAppearance, add a depthFailColor per-instance attribute instead.
Requires the EXT_frag_depth WebGL extension to render properly. If the extension is not supported, there may be artifacts.
True once resources are released.
Set true once a camera/target have been positioned.
Camera field of view in degrees.
Readonly
geometryThe geometry instances rendered with this primitive. This may
be undefined
if options.releaseGeometryInstances
is true
when the primitive is constructed.
Changing this property after the primitive is rendered has no effect.
Readonly
interleaveDetermines if geometry vertex attributes are interleaved, which can slightly improve rendering performance.
RGBA color for visible region in the viewshed.
The 4x4 transformation matrix that transforms the primitive (all geometry instances) from model to world coordinates. When this is the identity matrix, the primitive is drawn in world coordinates, i.e., Earth's WGS84 coordinates. Local reference frames can be used by providing a different transformation matrix, like that returned by Transforms.eastNorthUpToFixedFrame.
This property is only supported in 3D mode.
Readonly
readyDetermines if the primitive is complete and ready to render. If this property is true, the primitive will be rendered the next time that Primitive#update is called.
// Wait for a primitive to become ready before accessing attributes
const removeListener = scene.postRender.addEventListener(() => {
if (!frustumPrimitive.ready) {
return;
}
const attributes = primitive.getGeometryInstanceAttributes('an id');
attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA);
removeListener();
});
Readonly
releaseWhen true
, the primitive does not keep a reference to the input geometryInstances
to save memory.
RGBA color for non-visible region in the viewshed.
Determines whether this primitive casts or receives shadows from light sources.
Determines if the primitive will be shown. This affects all geometry instances in the primitive.
Movable entity marking the viewshed focal point.
Readonly
vertexWhen true
, geometry vertices are optimized for the pre and post-vertex-shader caches.
Field of view X in degrees. Updates internal frustum as well.
Field of view Y in degrees. Updates internal frustum.
Camera height offset property helper (for interactive placement).
maxDistance property with getter/setter.
Shadow map resolution size property; can be number or function for live lookup.
Internal: Attaches/shares the post-process viewshed shader and recipe to the scene.
Internal utility: Create/refresh Cesium shadow map for this viewshed, using interactive camera/target. Uses PerspectiveFrustum for the field-of-view and placement.
Internal: Initializes event listener to enable post-processing only after the shadow map texture becomes available.
Internal helper: Updates shadow map/camera/focus geometry as required (for movement/scale changes).
Cancels and destroys the viewshed tool if not yet finalized.
True if cancelled (destroyed), false otherwise.
Cleans up and releases all resources: drops shadow maps, event listeners, camera/target markers, and scene entries.
Returns the modifiable per-instance attributes for a GeometryInstance.
The id of the GeometryInstance.
The typed array in the attribute's format or undefined if the is no instance with id.
const attributes = primitive.getGeometryInstanceAttributes('an id');
attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA);
attributes.show = Cesium.ShowGeometryInstanceAttribute.toValue(true);
attributes.distanceDisplayCondition = Cesium.DistanceDisplayConditionGeometryInstanceAttribute.toValue(100.0, 10000.0);
attributes.offset = Cesium.OffsetGeometryInstanceAttribute.toValue(Cartesian3.IDENTITY);
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
.
Register a callback to be invoked when both camera and target points are set/placed.
Cesium per-frame update hook. Updates the shadow map state.
Viewshed – Encapsulates viewshed/visibility analysis as a dynamic shadow map using Cesium post-processing.
Handles shadow map/camera creation, shader uniform management, FOV/frustum math, and in-scene interactive placement. Supports dynamic reconfiguration for colors, blending, size, field-of-view, depth bias, etc. Ties to two draggable PointEntity markers—"camera" and "target"—and auto-recomputes when they move.
Param: app
Application/viewer instance.
Param: viewshedFS
Fragment shader code (GLSL).
Param: options
Param: options.lightColor
Overlay color for visible area.
Param: options.shadowColor
Overlay color for occluded area.
Param: options.alpha
Blend value for overlays.
Param: options.size
Shadow map size (resolution).
Param: options.maxDistance
Max draw distance.
Param: options.depthBias
Bias for shadow computation.
Param: options.fov
Camera field of view (degrees).
Param: options.aspectRatio
Camera aspect ratio.
Param: options.heightOffset
Camera height above surface.
Param: options.frustum
Initial frustum definition.
Method
onSet(callback) - Register a callback for when the viewshed is positioned.
Method
cancel() - Cancel and destroy if not finalized/placed.
Method
destroy() - Remove shadow maps, scene primitives, and mark destroyed.
Method
_createShadowMap() - Build/refresh shadow map state for internal use.
Method
_addPostProcess() - Attach post-process/shader to the Cesium scene.
Method
_initUpdateListener() - Poll for shadow map readiness and manage shader activation.
Method
_updateShadowMap() - Updates the light camera and map according to view geometry.
Method
update(frameState) - Cesium update hook (pushed shadow map to frame state).
Example