GroundPrimitive(贴地图元),表示在场景
Scene
中覆盖在地形,或者3D Tiles上的图形。
图元(Primitive)将几何图形实例(geometry instances)和外观(Appearance
)结合在一起,包括Material
and RenderState
。
大致上几何图形实例定义了结构和位置, 外观定义了视觉效果。
需要支持WEBGL_depth_texture扩展来使用除PerInstanceColorAppearance外,还具有不同perinstancecolor颜色或材质的几何实例。
纹理贴地图元是为概念模式而设计的,并不意味着精确地将纹理映射到地形。请使用SingleTileImageryProvider
。
为了正确的渲染,这个特性需要EXT_frag_depth WebGL扩展。对于不支持此扩展的硬件,将在某些视角呈现渲染伪像。
支持的集合图形有 CircleGeometry
,CorridorGeometry
,EllipseGeometry
,PolygonGeometry
,和RectangleGeometry
.
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
optional
具有下列属性的对象:
|
Example:
// 例1: 使用单个实例创建图元
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
}));
// 例2: 批量实例
var color = new Cesium.ColorGeometryInstanceAttribute(0.0, 1.0, 1.0, 0.5); //两个实例必须具有相同的颜色。
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]
}));
See:
Members
-
Default Value:
true
appearance : Appearance
用于给图元着色的
Appearance
. 每个几何实例都以相同的外观着色, 有些外观,如PerInstanceColorAppearance
允许赋予每个实例唯一的值。
-
Default Value:
undefined
确定图元是异步创建(true)还是阻塞直到准备就绪。
-
Default Value:
true
classificationType : ClassificationType
确定是贴到地形上还是3DTiles上。
-
Default Value:
ClassificationType.BOTH
当
true
时, 几何顶点被压缩,这将节省内存。
-
Default Value:
true
只是用来调试,是否显示图元的包围球。
-
Default Value:
false
只是用来调试
为图元中的每个几何图形绘制阴影体积。
-
Default Value:
false
readonlygeometryInstances : Array|GeometryInstance
这个图元渲染的几何实例,它有可能为undefined(当构造图元时,如果
options.releaseGeometryInstances
属性为true)。
在图元被渲染后,更改此属性无效。
-
Default Value:
undefined
当
true
时, 几何顶点属性是交错的,这可以略微提高渲染性能,但增加了加载时间。
-
Default Value:
false
确定图元是否完成并准备渲染。如果为true,将在下一次调用
Primitive#update
时渲染图元。
readonlyreadyPromise : Promise.<GroundPrimitive>
获取一个Promise,该Promise在准备好渲染图元时解析。
当
true
时, 该图元不保留对输入geometryInstances
的引用,以节省内存。
-
Default Value:
true
图元是否显示,这将影响到所有的几何实例(geometryInstances)
-
Default Value:
true
当
true
时, 几何顶点被优化为前后顶点着色器缓存。
-
Default Value:
true
Methods
初始化最小和最大地形高度。只有在同步创建GroundPrimitive时才需要调用它。
Returns:
一个promise,一旦地形高度已加载将解析。
确定是否支持渲染GroundPrimitive。
Name | Type | Description |
---|---|---|
scene |
Scene | The scene. |
Returns:
如果支持返回true,不支持返回false。
检查给定场景是否支持基本材质。
GroundPrimitives上的材质需要支持WEBGL_depth_texture扩展。
Name | Type | Description |
---|---|---|
scene |
Scene | 当前的场景。 |
Returns:
当前场景是否支持GroundPrimitives。
销毁此对象持有的WebGL资源。
一旦对象被销毁,它将不能在使用; 调用除
一旦对象被销毁,它将不能在使用; 调用除
isDestroyed
之外的任何函数都会导致DeveloperError
异常。
因此,将返回值(undefined
)赋给对象,如示例所示。
Throws:
-
DeveloperError : 对象已经被销毁。
Example:
e = e && e.destroy();
See:
返回 GeometryInstance 的每个实例的可修改属性。
Name | Type | Description |
---|---|---|
id |
* |
GeometryInstance 的id. |
Returns:
以属性格式表示的类型化数组.
Throws:
-
DeveloperError : 必须在调用getGeometryInstanceAttributes之前调用update。
Example:
var attributes = primitive.getGeometryInstanceAttributes('an id');
attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA);
attributes.show = Cesium.ShowGeometryInstanceAttribute.toValue(true);
Returns:
false
Throws:
-
DeveloperError : 对于同步的GroundPrimitive,您必须调用GroundPrimitive. initializeterrainheights()并等待返回的promise解析。
-
DeveloperError : 所有实例几何图形必须具有相同的图元类型。
-
DeveloperError : 外观和材质有统一的名称。