GroundPrimitive

external class GroundPrimitive(options: GroundPrimitive.ConstructorOptions? = definedExternally)(source)

A ground primitive represents geometry draped over terrain or 3D Tiles in the Scene.

A primitive combines geometry instances with an Appearance that describes the full shading, including Material and RenderState. Roughly, the geometry instance defines the structure and placement, and the appearance defines the visual characteristics. Decoupling geometry and appearance allows us to mix and match most of them and add a new geometry or appearance independently of each other.

Support for the WEBGL_depth_texture extension is required to use GeometryInstances with different PerInstanceColors or materials besides PerInstanceColorAppearance.

Textured GroundPrimitives were designed for notional patterns and are not meant for precisely mapping textures to terrain - for that use case, use SingleTileImageryProvider.

For correct rendering, this feature requires the EXT_frag_depth WebGL extension. For hardware that do not support this extension, there will be rendering artifacts for some viewing angles.

Valid geometries are CircleGeometry, CorridorGeometry, EllipseGeometry, PolygonGeometry, and RectangleGeometry.

// Example 1: Create primitive with a single instance
const rectangleInstance = new GeometryInstance({
geometry : new RectangleGeometry({
rectangle : Rectangle.fromDegrees(-140.0, 30.0, -100.0, 40.0)
}),
id : 'rectangle',
attributes : {
color : new ColorGeometryInstanceAttribute(0.0, 1.0, 1.0, 0.5)
}
});
scene.primitives.add(new GroundPrimitive({
geometryInstances : rectangleInstance
}));

// Example 2: Batch instances
const color = new ColorGeometryInstanceAttribute(0.0, 1.0, 1.0, 0.5); // Both instances must have the same color.
const rectangleInstance = new GeometryInstance({
geometry : new RectangleGeometry({
rectangle : Rectangle.fromDegrees(-140.0, 30.0, -100.0, 40.0)
}),
id : 'rectangle',
attributes : {
color : color
}
});
const ellipseInstance = new GeometryInstance({
geometry : new EllipseGeometry({
center : Cartesian3.fromDegrees(-105.0, 40.0),
semiMinorAxis : 300000.0,
semiMajorAxis : 400000.0
}),
id : 'ellipse',
attributes : {
color : color
}
});
scene.primitives.add(new GroundPrimitive({
geometryInstances : [rectangleInstance, ellipseInstance]
}));

See also

Constructors

Link copied to clipboard
constructor(options: GroundPrimitive.ConstructorOptions? = definedExternally)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Properties

Link copied to clipboard

When true, each geometry instance will only be pickable with Scene.pick. When false, GPU memory is saved.

Link copied to clipboard

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.

Link copied to clipboard

Determines if the geometry instances will be created and batched on a web worker.

Link copied to clipboard

Determines whether terrain, 3D Tiles or both will be classified.

Link copied to clipboard

When true, geometry vertices are compressed, which will save memory.

Link copied to clipboard

This property is for debugging only; it is not for production use nor is it optimized.

Link copied to clipboard

This property is for debugging only; it is not for production use nor is it optimized.

Link copied to clipboard

The geometry instances rendered with this primitive. This may be undefined if options.releaseGeometryInstances is true when the primitive is constructed.

Link copied to clipboard

Determines if geometry vertex attributes are interleaved, which can slightly improve rendering performance.

Link copied to clipboard

Determines if the primitive is complete and ready to render. If this property is true, the primitive will be rendered the next time that GroundPrimitive.update is called.

Link copied to clipboard

When true, the primitive does not keep a reference to the input geometryInstances to save memory.

Link copied to clipboard

Determines if the primitive will be shown. This affects all geometry instances in the primitive.

Link copied to clipboard

When true, geometry vertices are optimized for the pre and post-vertex-shader caches.

Functions

Link copied to clipboard
fun destroy()

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.

Link copied to clipboard

Returns the modifiable per-instance attributes for a GeometryInstance.

Link copied to clipboard

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

Link copied to clipboard
fun update()

Called when Viewer or CesiumWidget render the scene to get the draw commands needed to render this primitive.