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
.
参数名称 | 类型 | 描述信息 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
可选
Object with the following properties:
|
使用示例:
// Example 1: Create primitive with a single instance
const 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
const color = new Cesium.ColorGeometryInstanceAttribute(0.0, 1.0, 1.0, 0.5); // Both instances must have the same color.
const 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
}
});
const 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]
}));
参考:
成员(属性)
true
, each geometry instance will only be pickable with Scene#pick
. When false
, GPU memory is saved.
-
默认值:
true
appearance : Appearance
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.
-
默认值:
undefined
-
默认值:
true
classificationType : ClassificationType
-
默认值:
ClassificationType.BOTH
true
, geometry vertices are compressed, which will save memory.
-
默认值:
true
Draws the bounding sphere for each draw command in the primitive.
-
默认值:
false
Draws the shadow volume for each geometry in the primitive.
-
默认值:
false
readonly 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.
-
默认值:
undefined
-
默认值:
false
GroundPrimitive#update
is called.
true
, the primitive does not keep a reference to the input geometryInstances
to save memory.
-
默认值:
true
-
默认值:
true
true
, geometry vertices are optimized for the pre and post-vertex-shader caches.
-
默认值:
true
方法
返回值:
参数名称 | 类型 | 描述信息 |
---|---|---|
scene |
Scene | The scene. |
返回值:
true
if GroundPrimitives are supported; otherwise, returns false
参数名称 | 类型 | 描述信息 |
---|---|---|
scene |
Scene | The current scene. |
返回值:
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.
Throws:
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
使用示例:
e = e && e.destroy();
参考:
GeometryInstance
.
参数名称 | 类型 | 描述信息 |
---|---|---|
id |
* |
The id of the GeometryInstance . |
返回值:
Throws:
-
DeveloperError : must call update before calling getGeometryInstanceAttributes.
使用示例:
const attributes = primitive.getGeometryInstanceAttributes('an id');
attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA);
attributes.show = Cesium.ShowGeometryInstanceAttribute.toValue(true);
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
.
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:
Throws:
-
DeveloperError : For synchronous GroundPrimitive, you must call GroundPrimitive.initializeTerrainHeights() and wait for the returned promise to resolve.
-
DeveloperError : All instance geometries must have the same primitiveType.
-
DeveloperError : Appearance and material have a uniform with the same name.