English中文

GroundPolylinePrimitive

new Cesium.GroundPolylinePrimitive(options)

GroundPolylinePrimitive 表示覆盖在地形或 3D Tiles 上的折线 A GroundPolylinePrimitive represents a polyline draped over the terrain or 3D Tiles in the Scene.

仅适用于包含以下内容的 GeometryInstances Only to be used with GeometryInstances containing GroundPolylineGeometry.

名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 默认值 Default 说明 Description
geometryInstances Array | GeometryInstance 可选 optional 包含 GroundPolylineGeometry 的 GeometryInstances GeometryInstances containing GroundPolylineGeometry
appearance Appearance 可选 optional 用于渲染折线的外观。默认为白色 The Appearance used to render the polyline. Defaults to a white color Material 在一个 on a PolylineMaterialAppearance.
show boolean true 可选 optional 确定是否显示该原语。 Determines if this primitive will be shown.
interleave boolean false 可选 optional When true,几何体顶点属性是交错的,这可以稍微提高渲染性能但增加加载时间。 , geometry vertex attributes are interleaved, which can slightly improve rendering performance but increases load time.
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内存。 , GPU memory is saved.
asynchronous boolean true 可选 optional 确定基元是异步创建还是阻塞直到准备好。如果为 false,则必须首先调用initializeTerrainHeights()。 Determines if the primitive will be created asynchronously or block until ready. If false initializeTerrainHeights() must be called first.
classificationType ClassificationType ClassificationType.BOTH 可选 optional 确定是否对地形、3D 切片或两者进行分类。 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 creation to have effect.
示例: 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

When true,每个几何实例只能通过以下方式选取 , each geometry instance will only be pickable with Scene#pick。当 . When false,节省了GPU内存。 , GPU memory is saved.
默认值: Default Value: true
The Appearance 用于对这个基元进行着色。每个几何体实例都具有相同外观的阴影。有些外表,比如 used to shade this primitive. Each geometry instance is shaded with the same appearance. Some appearances, like PolylineColorAppearance 允许赋予每个实例独特的属性。 allow giving each instance unique properties.
默认值: Default Value: undefined

readonly asynchronous : boolean

确定是否将在 Web Worker 上创建和批处理几何实例。 Determines if the geometry instances will be created and batched on a web worker.
默认值: Default Value: true
确定是否对地形、3D 切片或两者进行分类。 Determines whether terrain, 3D Tiles or both will be classified.
默认值: Default Value: ClassificationType.BOTH

debugShowBoundingVolume : boolean

该属性仅用于调试;它不适合生产用途,也没有经过优化。 This property is for debugging only; it is not for production use nor is it optimized.

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

默认值: Default Value: false

readonly debugShowShadowVolume : boolean

该属性仅用于调试;它不适合生产用途,也没有经过优化。 This property is for debugging only; it is not for production use nor is it optimized.

如果为 true,则为图元中的每个几何体绘制阴影体积。 If true, draws the shadow volume for each geometry in the primitive.

默认值: Default Value: false
使用此图元渲染的几何实例。这可能是 The geometry instances rendered with this primitive. This may be undefined if options.releaseGeometryInstances is true 当构造原语时。 when the primitive is constructed.

在渲染图元后更改此属性没有任何效果。 Changing this property after the primitive is rendered has no effect.

默认值: Default Value: undefined
确定几何体顶点属性是否交错,这可以稍微提高渲染性能。 Determines if geometry vertex attributes are interleaved, which can slightly improve rendering performance.
默认值: Default Value: false
确定图元是否完整并准备好渲染。如果此属性为 true,则图元将在下一次渲染 Determines if the primitive is complete and ready to render. If this property is true, the primitive will be rendered the next time that GroundPolylinePrimitive#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
确定是否显示图元。这会影响基元中的所有几何体实例。 Determines if the primitive will be shown. This affects all geometry instances in the primitive.
默认值: Default Value: true

方法 Methods

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

初始化最小和最大地形高度。仅当您同步创建 GroundPolylinePrimitive 时才需要调用此函数。 Initializes the minimum and maximum terrain heights. This only needs to be called if you are creating the GroundPolylinePrimitive synchronously.
返回: Returns:
一旦加载了地形高度,这个承诺就会得到解决。 A promise that will resolve once the terrain heights have been loaded.

static Cesium.GroundPolylinePrimitive.isSupported(scene)boolean

检查给定场景是否支持 GroundPolylinePrimitives。 GroundPolylinePrimitives 需要支持 WEBGL_depth_texture 扩展。 Checks if the given Scene supports GroundPolylinePrimitives. GroundPolylinePrimitives require support for the WEBGL_depth_texture extension.
名称 Name 类型 Type 说明 Description
scene Scene 现在的场景。 The current scene.
返回: Returns:
当前场景是否支持 GroundPolylinePrimitives。 Whether or not the current scene supports GroundPolylinePrimitives.
销毁该对象持有的 WebGL 资源。销毁对象可以确定性地释放 WebGL 资源,而不是依赖垃圾收集器来销毁该对象。 Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.

一旦对象被销毁,就不应再使用;调用除 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 * 的 ID The id of the GeometryInstance.
返回: Returns:
属性格式的类型化数组,如果没有带 id 的实例,则为未定义。 The typed array in the attribute's format or undefined if the is no instance with id.
抛出: Throws:
  • DeveloperError :必须在调用 getGeometryInstanceAttributes 之前调用 update。 : 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);
如果该对象被销毁则返回 true;否则为假。 Returns true if this object was destroyed; otherwise, 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 如果该物体被摧毁;否则, if this object was destroyed; otherwise, false.
另见: See:
调用时间 Called when Viewer or CesiumWidget 渲染场景以获取渲染此图元所需的绘制命令。 render the scene to get the draw commands needed to render this primitive.

不要直接调用该函数。记录此内容只是为了列出渲染场景时可能传播的异常: 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 :对于同步 GroundPolylinePrimitives,您必须调用 GroundPolylinePrimitives.initializeTerrainHeights() 并等待返回的 Promise 解析。 : For synchronous GroundPolylinePrimitives, you must call GroundPolylinePrimitives.initializeTerrainHeights() and wait for the returned promise to resolve.
  • DeveloperError :所有 GeometryInstance 必须具有颜色属性才能将 PolylineColorAppearance 与 GroundPolylinePrimitive 结合使用。 : All GeometryInstances must have color attributes to use PolylineColorAppearance with GroundPolylinePrimitive.
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.