GroundPrimitive

new Cesium.GroundPrimitive(options)

地面基本体表示覆盖在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.

Name Type Description
options Object optional 具有以下属性的对象:
Name Type Default Description
geometryInstances Array | GeometryInstance optional 要渲染的几何体实例。
appearance Appearance optional 用于渲染基本体的外观。当GeometryInstances具有颜色属性时,默认为平坦的perinstancecolorApearance。
show Boolean true optional 确定是否显示此原语。
vertexCacheOptimize Boolean false optionaltrue时,几何体顶点将为顶点前和后着色器缓存进行优化。
interleave Boolean false optional 61166几何体交错渲染时,可以稍微提高66属性的渲染性能。
compressVertices Boolean true optionaltrue时,几何体顶点被压缩,这将节省内存。
releaseGeometryInstances Boolean true optionaltrue时,原语不保留对输入geometryInstances的引用以节省内存。
allowPicking Boolean true optional 当为true时,每个几何体实例将只能使用Scene#pick进行拾取。当false时,保存GPU内存。
asynchronous Boolean true optional 确定原语是异步创建还是阻塞直到准备就绪。If false initializerRailHeights()必须首先调用。
classificationType ClassificationType ClassificationType.BOTH optional 确定是对地形、三维分幅还是两者都进行分类。
debugShowBoundingVolume Boolean false optional 仅用于调试。确定是否显示了该图元的命令的边界球体。
debugShowShadowVolume Boolean false optional 仅用于调试。确定是否绘制基本体中每个几何体的阴影体积。必须接通6861166 在释放几何图形或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
Appearance是用来给这个原始人着色的。每个几何体 实例以相同的外观着色。一些表象,比如 PerInstanceColorAppearance允许给每个实例唯一 属性。
Default Value: undefined

readonly asynchronous : Boolean

确定几何体实例是否将在web工作器上创建和批处理。
Default Value: true
确定是对地形、三维分幅还是两者都进行分类。
Default Value: ClassificationType.BOTH

readonly compressVertices : Boolean

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

debugShowBoundingVolume : Boolean

此属性仅用于调试;它不用于生产用途,也不进行优化。

Draws the bounding sphere for each draw command in the primitive.

Default Value: false

debugShowShadowVolume : Boolean

此属性仅用于调试;它不用于生产用途,也不进行优化。

Draws the shadow volume for each geometry in the primitive.

Default Value: false

readonly geometryInstances : Array|GeometryInstance

使用此基本体渲染的几何体实例。今年五月 如果是options.releaseGeometryInstances,则为undefined 构造原语时为true

Changing this property after the primitive is rendered has no effect.

Default Value: undefined

readonly interleave : Boolean

确定几何体顶点属性是否交错,这可以稍微提高渲染性能。
Default Value: false

readonly ready : Boolean

确定基本体是否已完成并准备好渲染。如果这个属性是 真的,下一次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.<void>

初始化最小和最大地形高度。只有在创建 地面原始同步。
Returns:
一个一旦地形高度被加载就可以解决的承诺。

static Cesium.GroundPrimitive.isSupported(scene)Boolean

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

static Cesium.GroundPrimitive.supportsMaterials(scene)Boolean

如果场景上给定的材质支持,则检查。 GroundPrimitives上的材质需要支持WEBGL_depth_纹理扩展。
Name Type Description
scene Scene 当前场景。
Returns:
当前场景是否支持GroundPrimitives上的材质。
销毁此对象持有的WebGL资源。销毁一个对象允许确定性 释放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:
Example:
e = e && e.destroy();
See:

getGeometryInstanceAttributes(id)Object

返回GeometryInstance的每个实例的可修改属性。
Name Type Description
id * GeometryInstance的id。
Returns:
属性格式的类型化数组,如果不是id为的实例,则为未定义数组。
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。

If this object was destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception.

Returns:
如果此对象被销毁,则为true;否则为false
See:
ViewerCesiumWidget将场景渲染到 获取渲染此基本体所需的draw命令。

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 :对于同步GroundPrimitive,必须调用GroundPrimitive.initializeTerrainHeights()并等待返回的承诺解决。
  • DeveloperError :所有实例几何图形必须具有相同的基本类型。
  • DeveloperError :外观和材质具有相同名称的制服。