GroundPrimitive
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
Types
Properties
When true
, each geometry instance will only be pickable with Scene.pick. When false
, GPU memory is saved.
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.
Determines if the geometry instances will be created and batched on a web worker.
Determines whether terrain, 3D Tiles or both will be classified.
When true
, geometry vertices are compressed, which will save memory.
This property is for debugging only; it is not for production use nor is it optimized.
This property is for debugging only; it is not for production use nor is it optimized.
The geometry instances rendered with this primitive. This may be undefined
if options.releaseGeometryInstances
is true
when the primitive is constructed.
Determines if geometry vertex attributes are interleaved, which can slightly improve rendering performance.
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.
When true
, the primitive does not keep a reference to the input geometryInstances
to save memory.
When true
, geometry vertices are optimized for the pre and post-vertex-shader caches.
Functions
Returns the modifiable per-instance attributes for a GeometryInstance.
Returns true if this object was destroyed; otherwise, false.
Called when Viewer or CesiumWidget render the scene to get the draw commands needed to render this primitive.