new Cesium.GroundPrimitive(options)

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, 而外观则定义了视觉特征. 调和几何和外观,让我们可以混合 并匹配其中的大部分,并添加一个新的几何或外观,彼此独立.

需要支持 WEBGL 深度 纹理扩展以使用不同色彩的几何结构 或除彩色外的材料.

纹理地面原型是按名义图案设计的,并非用于精确绘图 地形纹理 - 对于这个使用大小写,使用 SingleTileImageryProvider .

为了正确渲染,这个特性需要EXT frag 深度 WebGL 扩展. 对于不支持此扩展名的硬件, 这里 将会为某些取景角度制作文物.

有效的几何是 CircleGeometry , CorridorGeometry , EllipseGeometry , PolygonGeometry ,和 RectangleGeometry .

Name Type Description
options object optional 下列属性的对象 :
Name Type Default Description
geometryInstances Array | GeometryInstance optional 要渲染的几何实例 .
appearance Appearance optional 用来制造原始的外表 在几何Instances具有色彩属性时默认为平面的PerInstanceColorAppearance.
show boolean true optional Determines if this primitive will be shown.
vertexCacheOptimize boolean false optional When true, geometry vertices are optimized for the pre and post-vertex-shader caches.
interleave boolean false optional When true, geometry vertex attributes are interleaved, which can slightly improve rendering performance but increases load time.
compressVertices boolean true optional When true, the geometry vertices are compressed, which will save memory.
releaseGeometryInstances boolean true optional When true, the primitive does not keep a reference to the input geometryInstances to save memory.
allowPicking boolean true optional When true, each geometry instance will only be pickable with Scene#pick. When false, GPU memory is saved.
asynchronous boolean true optional Determines if the primitive will be created asynchronously or block until ready. If false initializeTerrainHeights() must be called first.
classificationType ClassificationType ClassificationType.BOTH optional Determines whether terrain, 3D Tiles or both will be classified.
debugShowBoundingVolume boolean false optional For debugging only. Determines if this primitive's commands' bounding spheres are shown.
debugShowShadowVolume boolean false optional For debugging only. Determines if the shadow volume for each geometry in the primitive is drawn. Must be true on 为在几何发布前创建的卷创建,或 options.releaseGeometryInstance 必须是 false .
Example:
// 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]
}));
See:

Members

readonly allowPicking : boolean

When true, each geometry instance will only be pickable with Scene#pick. When false, GPU memory is saved.
Default Value: true

appearance : Appearance

The Appearance used to shade this primitive. Each geometry 实例以相同的外观遮蔽。 一些外表,比如说 PerInstanceColorAppearance allow giving each instance unique properties.
Default Value: undefined

readonly asynchronous : boolean

确定是否创建几何实例并在网络工人上进行分批.
Default Value: true

classificationType : ClassificationType

确定是否对地形、3D平面或两者进行分类.
Default Value: ClassificationType.BOTH

readonly compressVertices : boolean

当 NT 0 real NT 1 时,几何顶点被压缩,这将保存内存.
Default Value: true

debugShowBoundingVolume : boolean

此属性仅用于调试;不用于生产,也不优化.

绘制原始中每个绘图命令的边框.

Default Value: false

debugShowShadowVolume : boolean

此属性仅用于调试;不用于生产,也不优化.

为原始的每个几何绘制阴影音量.

Default Value: false

readonly geometryInstances : Array|GeometryInstance

用这个原始的几何学实例。 这可能 如果 NT 0 未定义 NT 1 如果 NT 4 is true when the primitive is constructed.

原始化后改变这个属性没有效果.

Default Value: undefined

readonly interleave : boolean

确定几何顶点属性是否互换,这可以略微改善渲染性能.
Default Value: false

readonly ready : boolean

确定原始的是否完整,是否准备制成. 如果这是 true, the primitive will be rendered the next time that GroundPrimitive#update is called.

readonly releaseGeometryInstances : boolean

When true, the primitive does not keep a reference to the input geometryInstances to save memory.
Default Value: true

show : boolean

确定是否将显示原始文件 。 这影响到所有几何 原始中的例子.
Default Value: true

readonly vertexCacheOptimize : boolean

当 NT 0 true NT 1 时,几何顶点被优化为前端和后端阴影缓存.
Default Value: true

Methods

static Cesium.GroundPrimitive.initializeTerrainHeights()Promise.<void>

初始化最小和最大地形高度. 只有您正在创建 GroundPrimitive synchronously.
Returns:
一旦地形高度升空 承诺就能解决.

static Cesium.GroundPrimitive.isSupported(scene)boolean

确定是否支持地面初级渲染 .
Name Type Description
scene Scene The scene.
Returns:
true if GroundPrimitives are supported; otherwise, returns false

static Cesium.GroundPrimitive.supportsMaterials(scene)boolean

检查给定的 NT 0 是否支持地面原始材料. 地面原始材料需要支持WEBGL 深度 纹理扩展.
Name Type Description
scene Scene 目前的场景.
Returns:
当前场景是否支持地面原始材料.

destroy()

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic 释放 WebGL 资源,而不是依赖垃圾收集器来摧毁此对象.

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.
Example:
e = e && e.destroy();
See:

getGeometryInstanceAttributes(id)object

Returns the modifiable per-instance attributes for a GeometryInstance.
Name Type Description
id * The id of the GeometryInstance.
Returns:
在属性格式中键入的数组, 如果无 id 实例, 则未定义 .
Throws:
  • DeveloperError : must call update before calling getGeometryInstanceAttributes.
Example:
const 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.

Returns:
true if this object was destroyed; otherwise, false.
See:

update()

Called when Viewer or CesiumWidget render the scene to 获得使这个原始化所需的绘图命令.

不要直接调用此函数 。 记录下来的只是 列出场景拍摄时可能宣传的例外情况:

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.
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.