new GroundPrimitive(optionsopt)
Scene
. The geometry must be from a single GeometryInstance
.
Batching multiple geometries is not yet supported.
A primitive combines the geometry instance 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. Only the PerInstanceColorAppearance
is supported at this time.
Because of the cutting edge nature of this feature in WebGL, it requires the EXT_frag_depth extension, which is currently only supported in Chrome, Firefox, and Edge. Apple support is expected in iOS 9 and MacOS Safari 9. Android support varies by hardware and IE11 will most likely never support it. You can use webglreport.com to verify support for your hardware.
Valid geometries are CircleGeometry
, CorridorGeometry
, EllipseGeometry
, PolygonGeometry
, and RectangleGeometry
.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Object with the following properties:
Properties
|
- Source:
- See:
Example
// Example 1: Create primitive with a single instance
var rectangleInstance = new Cesium.GeometryInstance({
geometry : new Cesium.RectangleGeometry({
rectangle : Cesium.Rectangle.fromDegrees(-140.0, 30.0, -100.0, 40.0)
}),
id : 'rectangle',
attributes : {
color : new Cesium.ColorGeometryInstanceAttribute(0.0, 1.0, 1.0, 0.5)
}
});
scene.primitives.add(new Cesium.GroundPrimitive({
geometryInstances : rectangleInstance
}));
// Example 2: Batch instances
var color = new Cesium.ColorGeometryInstanceAttribute(0.0, 1.0, 1.0, 0.5); // Both instances must have the same color.
var rectangleInstance = new Cesium.GeometryInstance({
geometry : new Cesium.RectangleGeometry({
rectangle : Cesium.Rectangle.fromDegrees(-140.0, 30.0, -100.0, 40.0)
}),
id : 'rectangle',
attributes : {
color : color
}
});
var ellipseInstance = new Cesium.GeometryInstance({
geometry : new Cesium.EllipseGeometry({
center : Cesium.Cartesian3.fromDegrees(-105.0, 40.0),
semiMinorAxis : 300000.0,
semiMajorAxis : 400000.0
}),
id : 'ellipse',
attributes : {
color : color
}
});
scene.primitives.add(new Cesium.GroundPrimitive({
geometryInstances : [rectangleInstance, ellipseInstance]
}));
Members
(readonly) allowPicking :Boolean
true
, each geometry instance will only be pickable with Scene#pick
. When false
, GPU memory is saved.
Type:
- Boolean
- Default Value:
- true
- Source:
(readonly) asynchronous :Boolean
Type:
- Boolean
- Default Value:
- true
- Source:
(readonly) compressVertices :Boolean
true
, geometry vertices are compressed, which will save memory.
Type:
- Boolean
- Default Value:
- true
- Source:
debugShowBoundingVolume :Boolean
Draws the bounding sphere for each draw command in the primitive.
Type:
- Boolean
- Default Value:
- false
- Source:
debugShowShadowVolume :Boolean
Draws the shadow volume for each geometry in the primitive. Must be true
on
creation for the volumes to be created before the geometry is released or releaseGeometryInstances
must be false
Type:
- Boolean
- Default Value:
- false
- Source:
geometryInstances :Array|GeometryInstance
undefined
if options.releaseGeometryInstances
is true
when the primitive is constructed.
Changing this property after the primitive is rendered has no effect.
Because of the rendering technique used, all geometry instances must be the same color.
If there is an instance with a differing color, a DeveloperError
will be thrown
on the first attempt to render.
Type:
- Array | GeometryInstance
- Default Value:
- undefined
- Source:
(readonly) interleave :Boolean
Type:
- Boolean
- Default Value:
- false
- Source:
(readonly) ready :Boolean
GroundPrimitive#update
is called.
Type:
- Boolean
- Source:
(readonly) readyPromise :Promise.<GroundPrimitive>
Type:
- Promise.<GroundPrimitive>
- Source:
(readonly) releaseGeometryInstances :Boolean
true
, the primitive does not keep a reference to the input geometryInstances
to save memory.
Type:
- Boolean
- Default Value:
- true
- Source:
show :Boolean
Type:
- Boolean
- Default Value:
- true
- Source:
(readonly) vertexCacheOptimize :Boolean
true
, geometry vertices are optimized for the pre and post-vertex-shader caches.
Type:
- Boolean
- Default Value:
- true
- Source:
Methods
(static) initializeTerrainHeights() → {Promise}
- Source:
Returns:
- Type
- Promise
(static) isSupported(scene) → {Boolean}
Parameters:
Name | Type | Description |
---|---|---|
scene |
Scene | The scene. |
- Source:
Returns:
true
if GroundPrimitives are supported; otherwise, returns false
- Type
- Boolean
destroy() → {undefined}
Once an object is destroyed, it should not be used; calling any function other than
isDestroyed
will result in a DeveloperError
exception. Therefore,
assign the return value (undefined
) to the object as done in the example.
- Source:
- See:
Throws:
-
This object was destroyed, i.e., destroy() was called.
- Type
- DeveloperError
Returns:
- Type
- undefined
Example
e = e && e.destroy();
getGeometryInstanceAttributes(id) → {Object}
GeometryInstance
.
Parameters:
Name | Type | Description |
---|---|---|
id |
Object | The id of the GeometryInstance . |
- Source:
Throws:
-
must call update before calling getGeometryInstanceAttributes.
- Type
- DeveloperError
Returns:
- Type
- Object
Example
var attributes = primitive.getGeometryInstanceAttributes('an id');
attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA);
attributes.show = Cesium.ShowGeometryInstanceAttribute.toValue(true);
isDestroyed() → {Boolean}
If this object was destroyed, it should not be used; calling any function other than
isDestroyed
will result in a DeveloperError
exception.
- Source:
- See:
Returns:
true
if this object was destroyed; otherwise, false
.
- Type
- Boolean
update()
Viewer
or CesiumWidget
render the scene to
get the draw commands needed to render this primitive.
Do not call this function directly. This is documented just to list the exceptions that may be propagated when the scene is rendered:
- Source:
Throws:
-
-
All instance geometries must have the same primitiveType.
- Type
- DeveloperError
-
-
-
Appearance and material have a uniform with the same name.
- Type
- DeveloperError
-
-
-
Not all of the geometry instances have the same color attribute.
- Type
- DeveloperError
-