GroundPolylinePrimitive

new Cesium.GroundPolylinePrimitive(options)

GroundPolylinePrimitive 表示在场景中贴地地形或者3DTiles上的折线。 仅用于包含GroundPolylineGeometry的GeometryInstances。

Name Type Description
options Object optional 具有下列属性的对象:
Name Type Default Description
geometryInstances Array | GeometryInstance optional 包含GroundPolylineGeometry的GeometryInstances。
appearance Appearance optional 用来渲染折线的外观,在PolylineMaterialAppearance上默认为白色Material
show Boolean true optional 是否显示此图元。
interleave Boolean false optionaltrue时,对几何顶点属性进行交叉处理,可以略微提高渲染性能,但会增加加载时间。
releaseGeometryInstances Boolean true optionaltrue时, 该图元不保留对输入geometryInstances的引用,以节省内存。
allowPicking Boolean true optionaltrue时, 每个几何体实例只能用Scene#pick来拾取。 当false时, 节省GPU内存。
asynchronous Boolean true optional 确定图元是异步创建(true)还是阻塞直到准备就绪。
classificationType ClassificationType ClassificationType.BOTH optional 确定是贴到地形上,还是贴到3DTiles上。
debugShowBoundingVolume Boolean false optional 仅用于调试,是否显示图元的包围球。
debugShowShadowVolume Boolean false optional 只是用来调试, 确定是否绘制图元中每个几何图形的阴影体积。 Must be true on creation to have effect.
Example:
// 1.用基本颜色材质在地形上画一条折线
var 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. 用每个实例的颜色和距离显示条件在地形上绘制环形折线。
// 地形折线的距离显示条件是基于近似的地形高度,而不是真实的地形高度。
var instance = 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 : instance,
  appearance : new Cesium.PolylineColorAppearance()
}));

Members

readonlyallowPicking : Boolean

true时,每个几何体实例只能用Scene#pick来拾取。当false时,节省GPU内存。
Default Value: true
用于给图元着色的Appearance。每个几何实例都以相同的外观着色, 有些外观,如 PolylineColorAppearance允许赋予每个实例唯一的值。
Default Value: undefined

readonlyasynchronous : Boolean

确定图元是异步创建(true)还是阻塞直到准备就绪。
Default Value: true
确定是贴到地形上,还是贴到3DTiles上。
Default Value: ClassificationType.BOTH

debugShowBoundingVolume : Boolean

此属性仅用于调试;它既不用于生产,也不是最优的。

是否显示图元的包围球。

Default Value: false

readonlydebugShowShadowVolume : Boolean

此属性仅用于调试;它既不用于生产,也不是最优的。

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

Default Value: false

readonlygeometryInstances : Array|GeometryInstance

这个图元渲染的几何实例,它有可能为undefined(当构造图元时,如果options.releaseGeometryInstances属性为true)。

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

Default Value: undefined

readonlyinterleave : Boolean

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

readonlyready : Boolean

确定图元是否完成并准备渲染。如果为true,将在下一次调用GroundPolylinePrimitive#update时渲染图元。
获取一个Promise,该Promise在准备好渲染图元时解析。

readonlyreleaseGeometryInstances : Boolean

true时,该图元不保留对输入geometryInstances的引用,以节省内存。
Default Value: true
是否显示此图元,这将影响图元中的所有几何实例。
Default Value: true

Methods

staticCesium.GroundPolylinePrimitive.initializeTerrainHeights()Promise

初始化最小和最大地形高度。只有在同步创建GroundPolylinePrimitive时才需要调用它。
Returns:
一个promise,一旦地形高度已加载将解析。

staticCesium.GroundPolylinePrimitive.isSupported(scene)Boolean

检查给定的场景Scene是否支持GroundPolylinePrimitives。 GroundPolylinePrimitives需要支持WEBGL_depth_texture扩展。
Name Type Description
scene Scene 当前的场景。
Returns:
当前场景是否支持GroundPolylinePrimitives。
销毁此对象持有的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

如果该对象没被销毁,返回false。

如果该对象已经被销毁,使用isDestroyed 会触发 DeveloperError 异常。
Returns:
false
See:
ViewerCesiumWidget渲染场景以获得渲染此图元所需的draw命令时调用。

不要直接调用这个函数。这被记录下来只是为了列出在场景渲染时可能传播的异常:

Throws:
  • DeveloperError : 对于同步的GroundPolylinePrimitives,您必须调用GroundPolylinePrimitives.initializeTerrainHeights()并等待返回的promise解析。
  • DeveloperError : 所有的几何实例必须有颜色属性才能使用PolylineColorAppearance和GroundPolylinePrimitive。