new GroundPolylinePrimitive()
用于在场景中Scene地形表面或 3D Tiles上绘制贴地折线图元类
仅限用于包含GroundPolylineGeometry(地面折线几何体)的几何体实例GroundPolylineGeometry。
| Name | Type | Default | Description |
|---|---|---|---|
options.geometryInstances |
Array | GeometryInstance |
可选
包含GroundPolylineGeometry的GeometryInstances |
|
options.appearance |
Appearance |
可选
用于渲染折线的外观(Appearance),默认在PolylineMaterialAppearance |
|
options.show |
Boolean | true |
可选
确定此图元是否显示。 |
options.interleave |
Boolean | false |
可选
当为true时,几何体顶点属性是交错的,这可以略微提高渲染性能,但会增加加载时间。 |
options.releaseGeometryInstances |
Boolean | true |
可选
当为true时,图元不会保留对输入的geometryInstances的引用,以节省内存。 |
options.allowPicking |
Boolean | true |
可选
当为true时,每个几何实例只能通过 |
options.asynchronous |
Boolean | true |
可选
确定图元是异步创建还是阻塞直到准备就绪。如果为false,则必须先调用initializeTerrainHeights()。 |
options.classificationType |
ClassificationType | ClassificationType.BOTH |
可选
确定是否对地形、3D Tiles 或两者进行分类。 |
options.debugShowBoundingVolume |
Boolean | false |
可选
仅用于调试。确定是否显示此图元命令的边界球体。 |
options.debugShowShadowVolume |
Boolean | false |
可选
仅用于调试。确定是否绘制图元中每个几何体的阴影体积。必须在创建时设置为true才有效。 |
Example
// 1. Draw a polyline on terrain with a basic color material
var instance = new SuperMap3D.GeometryInstance({
geometry : new SuperMap3D.GroundPolylineGeometry({
positions : SuperMap3D.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 SuperMap3D.GroundPolylinePrimitive({
geometryInstances : instance,
appearance : new SuperMap3D.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.
var instance = new SuperMap3D.GeometryInstance({
geometry : new SuperMap3D.GroundPolylineGeometry({
positions : SuperMap3D.Cartesian3.fromDegreesArray([
-112.1340164450331, 36.05494287836128,
-112.08821010582645, 36.097804071380715,
-112.13296079730024, 36.168769146801104
]),
loop : true,
width : 4.0
}),
attributes : {
color : SuperMap3D.ColorGeometryInstanceAttribute.fromColor(SuperMap3D.Color.fromCssColorString('green').withAlpha(0.7)),
distanceDisplayCondition : new SuperMap3D.DistanceDisplayConditionGeometryInstanceAttribute(1000, 30000)
},
id : 'object returned when this instance is picked and to get/set per-instance attributes'
});
scene.groundPrimitives.add(new SuperMap3D.GroundPolylinePrimitive({
geometryInstances : instance,
appearance : new SuperMap3D.PolylineColorAppearance()
}));
Members
-
readonly allowPickingBoolean
-
当为true时,每个几何实例只能通过
Scene#pick进行拾取。当为false时,可以节省 GPU 内存。- Default Value: true
appearanceAppearance
用于为这个图元着色的Appearance。
每个几何实例都使用相同的外观进行着色。
某些外观,如PolylineColorAppearance ,允许为每个实例提供独特的属性。
- Default Value: undefined
readonly asynchronousBoolean
确定几何实例是否会在 Web Worker 中创建和批量处理。
- Default Value: true
classificationTypeClassificationType
确定是否对地形、3D Tiles 或两者进行分类。
- Default Value: ClassificationType.BOTH
debugShowBoundingVolumeBoolean
这个属性仅用于调试 绘制图元中每个绘制命令的边界球体。
- Default Value: false
readonly debugShowShadowVolumeBoolean
这个属性仅用于调试 如果为true,则绘制图元中每个几何体的阴影体积。
- Default Value: false
readonly geometryInstancesArray
使用此图元渲染的几何实例。 如果在创建图元时options.releaseGeometryInstances为true,则此值可能未定义。 在图元渲染后更改此属性不会产生任何效果。
- Default Value: undefined
readonly interleaveBoolean
判断几何体顶点属性是否交错,这可以略微提高渲染性能。
- Default Value: false
readonly readyBoolean
确定图元是否完整且准备好渲染。 如果此属性为true,则在下次调用GroundPolylinePrimitive#update时,图元将被渲染。
readonly readyPromisePromise.<GroundPolylinePrimitive>
获取一个promise,当图元准备好渲染时,该promise将被解析。
readonly releaseGeometryInstancesBoolean
当为true时,图元不会保留对输入的geometryInstances的引用,以节省内存。
- Default Value: true
showBoolean
Determines if the primitive will be shown. This affects all geometry instances in the primitive.
- Default Value: true
Methods
-
static initializeTerrainHeights(){Promise}
-
初始化地形的最小高度和最大高度。 只有在同步创建GroundPolylinePrimitive时才需要调用此方法。
Returns:
Type Description Promise 一个一旦地形高度加载完毕就会解析的Promise。 -
static isSupported(scene){Boolean}
-
检查给定的Scene是否支持GroundPolylinePrimitives。 GroundPolylinePrimitives需要支持WEBGL_depth_texture扩展。
Name Type Description sceneScene 当前场景。
Returns:
Type Description Boolean 当前场景是否支持GroundPolylinePrimitives。 -
destroy()
-
销毁此对象持有的 WebGL 资源。销毁一个对象可以确定性地释放 WebGL 资源,而不是依赖垃圾回收器来销毁这个对象。 一旦一个对象被销毁,它就不应该再被使用;调用除isDestroyed之外的任何函数都将导致抛出一个
DeveloperError异常。 因此,应该像示例中那样,将返回值(undefined)赋值给该对象。Throws:
-
该对象已被销毁,即调用了
destroy()方法。 - Type
- DeveloperError
Example
e = e && e.destroy(); -
-
getGeometryInstanceAttributes(id){Object}
-
返回
GeometryInstance的可修改的每个实例的属性。Name Type Description id* GeometryInstance的idThrows:
-
在调用getGeometryInstanceAttributes之前,必须先调用update。
- Type
- DeveloperError
Returns:
Type Description Object 属性格式中的类型化数组,或者如果不存在具有该id的实例,则返回undefined。 Example
var attributes = primitive.getGeometryInstanceAttributes('an id'); attributes.color = SuperMap3D.ColorGeometryInstanceAttribute.toValue(SuperMap3D.Color.AQUA); attributes.show = SuperMap3D.ShowGeometryInstanceAttribute.toValue(true); -
-
isDestroyed(){Boolean}
-
如果该对象已被销毁,则返回 true;否则返回 false。 调用除isDestroyed之外的任何函数都将导致抛出一个
DeveloperError异常。Returns:
Type Description Boolean 如果该对象已被销毁,则为true;否则为false。 -
update()
-
当Viewer或Widget渲染场景时,调用此方法以获取渲染此图元所需的绘制命令。 不要直接调用此方法。这里只是列出在渲染场景时可能传播的异常:
Throws:
-
-
对于同步的GroundPolylinePrimitive,您必须调用GroundPolylinePrimitive.initializeTerrainHeights()并等待返回的承诺解析。
- Type
- DeveloperError
-
-
-
要使用PolylineColorAppearance与GroundPolylinePrimitive,所有GeometryInstances都必须具有颜色属性。
- Type
- DeveloperError
-
-