GroundPrimitive

new Cesium.GroundPrimitive ( options )

地面图元表示在 Scene 中的地形或3D Tiles上叠加的几何图形。

基本体将几何实例与描述完整阴影的 Appearance 组合在一起,包括 材料 和 RenderState 。大致而言,几何实例定义了结构和位置,外观定义了视觉特征。去耦几何形状和外观使我们能够混合并匹配其中的大多数,并彼此独立地添加新的几何形状或外观。

要使用具有不同PerInstanceColors的GeometryInstances,需要支持WEBGL_depth_texture扩展或除PerInstanceColorAppearance之外的其他材料。

带纹理的GroundPrimitives是专为概念性图案设计的,并不用于精确映射地形纹理-对于该用例,请使用 SingleTileImageryProvider 。

为了正确渲染,此功能需要EXT_frag_depth WebGL扩展。对于不支持此扩展的硬件,将在某些视角呈现渲染伪像。

有效的几何图形是 CircleGeometry , CorridorGeometry ,< a href =' EllipseGeometry.html'> EllipseGeometry , PolygonGeometry 和 RectangleGeometry 。

Name Type Description
options Object optional Object with the following properties:
Name Type Default Description
geometryInstances Array | GeometryInstance 可选 要渲染的几何实例。
appearance Appearance 可选 用于渲染图元的外观。当GeometryInstances具有color属性时,默认为平坦的PerInstanceColorAppearance。
show Boolean true 可选 确定是否将显示此原语。
vertexCacheOptimize Boolean false 可选 如果为 true ,则为顶点着色器之前和之后的缓存优化几何顶点。
interleave Boolean false 可选 当 true 时,将交错几何图形顶点属性,这可以稍微改善渲染性能,但会增加加载时间。
compressVertices Boolean true 可选 当 true 时,将压缩几何顶点,这将节省内存。
releaseGeometryInstances Boolean true 可选 如果为 true ,则该原语不保留对输入的 geometryInstances 的引用以节省内存。
allowPicking Boolean true 可选 如果为 true ,则只能使用 Scene#pick 来拾取每个几何实例。如果 false ,则保存GPU内存。
asynchronous Boolean true 可选 确定基元是异步创建还是阻塞直到准备就绪。如果为false,则必须首先调用initializeTerrainHeights()。
classificationType ClassificationType ClassificationType.BOTH 可选 确定是对地形,3D拼贴还是对两者进行分类。
debugShowBoundingVolume Boolean false 可选 仅用于调试。确定是否显示此图元命令的边界球。
debugShowShadowVolume Boolean false 可选 仅用于调试。确定是否绘制图元中每个几何的阴影体积。必须为 true 在释放几何图形之前创建要创建的卷,或者options.releaseGeometryInstance必须为 false 。
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]
}));
See:

Members

readonly allowPicking : Boolean

如果为 true ,则只能使用 Scene#pick 来拾取每个几何实例。如果 false ,则保存GPU内存。
Default Value: true
外观 用于为该原语着色。每个几何实例以相同的外观着色。一些外观,例如 PerInstanceColorAppearance 允许给每个实例唯一属性。
Default Value: undefined

readonly asynchronous : Boolean

确定是否将在Web Worker上创建几何实例并进行批处理。
Default Value: true
确定是对地形,3D拼贴还是对两者进行分类。
Default Value: ClassificationType.BOTH

readonly compressVertices : Boolean

当 true 时,将压缩几何顶点,这将节省内存。
Default Value: true

debugShowBoundingVolume : Boolean

此属性仅用于调试。它不是用于生产用途,也不是经过优化的。

为图元中的每个绘制命令绘制边界球。

Default Value: false

debugShowShadowVolume : Boolean

此属性仅用于调试。它不是用于生产用途,也不是经过优化的。

为图元中的每个几何图形绘制阴影体积。

Default Value: false

readonly geometryInstances : Array| GeometryInstance

用该图元渲染的几何实例。这可能如果 options.releaseGeometryInstances 为 undefined 构造基元时为 true 。

渲染图元后更改此属性无效。

Default Value: undefined

readonly interleave : Boolean

确定是否交错几何图形顶点属性,这可以稍微改善渲染性能。
Default Value: false

readonly ready : Boolean

确定图元是否完整并且可以渲染。如果此属性是true,则下一次 GroundPrimitive#update 时,将渲染图元。叫做。

readonly readyPromise : Promise.< GroundPrimitive >

获取一个承诺,该承诺在准备好渲染图元时解析。

readonly releaseGeometryInstances : Boolean

如果为 true ,则该原语不保留对输入的 geometryInstances 的引用以节省内存。
Default Value: true
确定是否显示图元。这会影响所有几何原语中的实例。
Default Value: true

readonly vertexCacheOptimize : Boolean

如果为 true ,则为顶点着色器之前和之后的缓存优化几何顶点。
Default Value: true

Methods

static Cesium.GroundPrimitive.initializeTerrainHeights () → Promise

初始化最小和最大地形高度。仅当您正在创建同步接地。
Returns:
一旦加载了地形高度,该承诺就会解决。

static Cesium.GroundPrimitive.isSupported (scene) → Boolean

确定是否支持GroundPrimitive渲染。
Name Type Description
scene Scene 现场。
Returns:
真正 如果支持GroundPrimitives;否则,返回 假

static Cesium.GroundPrimitive.supportsMaterials (scene) → Boolean

检查给定的场景是否支持GroundPrimitives上的材质。GroundPrimitives上的材料需要支持WEBGL_depth_texture扩展。
Name Type Description
scene Scene 当前场景。
Returns:
当前场景是否支持GroundPrimitives上的材质。
销毁此对象拥有的WebGL资源。销毁对象可以确定性释放WebGL资源,而不是依靠垃圾回收器来破坏此对象。

一旦物体被破坏,就不应使用。调用除 isDestroyed 将导致 DeveloperError 异常。因此,如示例中所述,将返回值( undefined )分配给对象。

Throws:
Example:
e = e && e.destroy();
See:

getGeometryInstanceAttributes (id) → Object

返回 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);

isDestroyed () → Boolean

如果此对象已销毁,则返回true;否则返回false。否则为假。

如果该对象被破坏,则不应使用。调用除 isDestroyed 将导致 DeveloperError 异常。

Returns:
真正 该物体是否被破坏;除此以外, 假 。
See:
在 Viewer 或 CesiumWidget 渲染场景时调用至获取渲染该图元所需的绘制命令。

不要直接调用此函数。这只是为了列出渲染场景时可能传播的异常:

Throws:
  • DeveloperError :对于同步的GroundPrimitive,必须调用GroundPrimitive.initializeTerrainHeights()并等待返回的Promise解析。
  • DeveloperError :所有实例几何必须具有相同的primaryType。
  • DeveloperError :外观和材质具有相同名称的制服。