GroundPolylinePrimitive

new Cesium.GroundPolylinePrimitive(options)

GroundPolylinePrimitive 表示覆盖在 Scene 中的 terrain 或 3D 瓦片上的多段线。

仅用于包含 GroundPolylineGeometry 的 GeometryInstances。

Name Type Description
options object optional 对象,具有以下属性:
Name Type Default Description
geometryInstances Array | GeometryInstance optional 包含 GroundPolylineGeometry 的 GeometryInstance
appearance Appearance optional 用于渲染多段线的 Appearance。默认为 PolylineMaterialAppearance 上的白色 Material
show boolean true optional 决定是否显示此基元。
interleave boolean false optional 如果为 true,则几何顶点属性是交错的,这可以略微提高渲染性能,但会增加加载时间。
releaseGeometryInstances boolean true optional 如果为 true,则基元不会保留对输入 geometryInstances 的引用以节省内存。
allowPicking boolean true optional 如果为 true,则每个几何体实例只能使用 Scene#pick 进行拾取。 如果为 false,则保存 GPU 内存。
asynchronous boolean true optional 确定原语是异步创建还是阻塞直到准备就绪。如果为 false,则必须先调用 initializeTerrainHeights()。
classificationType ClassificationType ClassificationType.BOTH optional 确定是否对地形、3D 瓦片或两者进行分类。
debugShowBoundingVolume boolean false optional 仅用于调试。确定是否显示此基本体的命令的边界球体。
debugShowShadowVolume boolean false optional 仅用于调试。确定是否绘制基本体中每个几何体的阴影体积。必须在创建时为 true 才能生效。
Example:
// 1. Draw a polyline on terrain with a basic color material

const instance = new Cesium.GeometryInstance({
  geometry : new Cesium.GroundPolylineGeometry({
     positions : Cesium.Cartesian3.fromDegreesArray([
         -112.1340164450331, 36.05494287836128,
         -112.08821010582645, 36.097804071380715
     ]),
     width : 4.0
  }),
  id : 'object returned when this instance is picked and to get/set per-instance attributes'
});

scene.groundPrimitives.add(new Cesium.GroundPolylinePrimitive({
  geometryInstances : instance,
  appearance : new Cesium.PolylineMaterialAppearance()
}));

// 2. Draw a looped polyline on terrain with per-instance color and a distance display condition.
// Distance display conditions for polylines on terrain are based on an approximate terrain height
// instead of true terrain height.

const instance2 = new Cesium.GeometryInstance({
  geometry : new Cesium.GroundPolylineGeometry({
     positions : Cesium.Cartesian3.fromDegreesArray([
         -112.1340164450331, 36.05494287836128,
         -112.08821010582645, 36.097804071380715,
         -112.13296079730024, 36.168769146801104
     ]),
     loop : true,
     width : 4.0
  }),
  attributes : {
     color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromCssColorString('green').withAlpha(0.7)),
     distanceDisplayCondition : new Cesium.DistanceDisplayConditionGeometryInstanceAttribute(1000, 30000)
  },
  id : 'object returned when this instance is picked and to get/set per-instance attributes'
});

scene.groundPrimitives.add(new Cesium.GroundPolylinePrimitive({
  geometryInstances : instance2,
  appearance : new Cesium.PolylineColorAppearance()
}));

Members

readonly allowPicking : boolean

如果为 true,则每个几何体实例只能使用 Scene#pick 进行拾取。 如果为 false,则保存 GPU 内存。
Default Value: true
用于对此基元进行着色的 Appearance。每个几何体 实例以相同的外观进行着色。 一些外观,如 PolylineColorAppearance 允许为每个实例指定唯一的 性能。
Default Value: undefined

readonly asynchronous : boolean

确定是否将在 Web Worker 上创建和批处理 geometry 实例。
Default Value: true
确定是否对地形、3D 瓦片或两者进行分类。
Default Value: ClassificationType.BOTH

debugShowBoundingVolume : boolean

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

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

Default Value: false

readonly debugShowShadowVolume : boolean

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

如果为 true,则为基元中的每个几何体绘制阴影体积。

Default Value: false
使用此基元渲染的几何体实例。这可能会 如果 options.releaseGeometryInstancesundefined 在构造基元时为 true

在渲染基元后更改此属性不起作用。

Default Value: undefined
确定几何体顶点属性是否交错,这可以略微提高渲染性能。
Default Value: false
确定基元是否完整并准备好进行渲染。 如果此属性为 true,则基元将在下次 GroundPolylinePrimitive#update 时渲染 被调用。

readonly releaseGeometryInstances : boolean

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

Methods

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

初始化最小和最大地形高度。仅当您正在创建 GroundPolylinePrimitive 同步。
Returns:
一个 Promise,一旦地形高度被加载,它就会被解析。

static Cesium.GroundPolylinePrimitive.isSupported(scene)boolean

检查给定的 Scene 是否支持 GroundPolylinePrimitives。 GroundPolylinePrimitives 需要支持 WEBGL_depth_texture 扩展。
Name Type Description
scene Scene 当前场景。
Returns:
当前场景是否支持 GroundPolylinePrimitives。
销毁此对象持有的 WebGL 资源。 销毁对象允许确定性 释放 WebGL 资源,而不是依赖垃圾回收器来销毁这个对象。

一旦对象被销毁,就不应该使用它;调用 isDestroyed 将导致 DeveloperError 异常。 因此 将返回值 (undefined) 分配给对象,如示例中所示。

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

getGeometryInstanceAttributes(id)object

返回 GeometryInstance 的可修改的每实例属性。
Name Type Description
id * GeometryInstance 的 ID。
Returns:
属性格式的类型化数组,如果没有 id 的实例,则为 undefined。
Throws:
  • DeveloperError : 必须在调用 getGeometryInstanceAttributes 之前调用 update。
Example:
const attributes = primitive.getGeometryInstanceAttributes('an id');
attributes.color = Cesium.ColorGeometryInstanceAttribute.toValue(Cesium.Color.AQUA);
attributes.show = Cesium.ShowGeometryInstanceAttribute.toValue(true);
如果此对象已销毁,则返回 true;否则为 false。

如果此对象已销毁,则不应使用;调用 isDestroyed 将导致 DeveloperError 异常。

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

请勿直接调用此函数。 这记录下来只是为了 列出渲染场景时可能传播的异常:

Throws:
  • DeveloperError : 对于同步 GroundPolylinePrimitives,您必须调用 GroundPolylinePrimitives.initializeTerrainHeights() 并等待返回的 Promise 解析。
  • DeveloperError : 所有 GeometryInstances 都必须具有颜色属性,才能将 PolylineColorAppearance 与 GroundPolylinePrimitive 一起使用。
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.