ClassificationPrimitive

new Cesium.ClassificationPrimitive(options)

分类基元表示在 Scene 中封闭几何体的体积,以便高亮显示。

基元将几何体实例与描述完整着色的 Appearance 组合在一起,包括 MaterialRenderState 的 RenderState} 中。 粗略地说,geometry 实例定义了结构和位置, 和外观定义视觉特征。 解耦的几何图形和外观使我们能够混合 并匹配其中的大多数,并彼此独立地添加新的几何图形或外观。 此时仅支持在所有实例中具有相同颜色的 PerInstanceColorAppearance 使用 ClassificationPrimitive 径直. 要获得完整的 Appearance 支持,请在对地形或 3D 瓦片进行分类时改用 GroundPrimitive

为了正确渲染,此功能需要 EXT_frag_depth WebGL 扩展。对于不支持此扩展的硬件,有 将在某些视角下渲染伪影。

有效的几何图形包括 BoxGeometryCylinderGeometryEllipsoidGeometryPolylineVolumeGeometrySphereGeometry

跟随椭球体表面的几何图形,例如 CircleGeometryCorridorGeometryEllipseGeometryPolygonGeometryRectangleGeometry, 如果它们是凸出体积,则它们也有效;否则,它们将不会被渲染。

Name Type Description
options object optional 对象,具有以下属性:
Name Type Default Description
geometryInstances Array | GeometryInstance optional 要渲染的几何体实例。这可以是单个实例,也可以是长度为 1 的数组。
appearance Appearance optional 用于渲染基元的外观。当 GeometryInstance 具有 color 属性时,默认为 PerInstanceColorAppearance。
show boolean true optional 决定是否显示此基元。
vertexCacheOptimize boolean false optional 如果为 true,则几何体顶点将针对顶点着色器前和后着色器缓存进行优化。
interleave boolean false optional 如果为 true,则几何顶点属性是交错的,这可以略微提高渲染性能,但会增加加载时间。
compressVertices boolean true 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 creation (要在释放几何体之前创建的卷) 或 options.releaseGeometryInstance 必须为 false
See:

Members

readonly allowPicking : boolean

如果为 true,则每个几何体实例只能使用 Scene#pick 进行拾取。 如果为 false,则保存 GPU 内存。
Default Value: true

readonly asynchronous : boolean

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

readonly compressVertices : boolean

如果为 true,则压缩几何顶点,这将节省内存。
Default Value: true

debugShowBoundingVolume : boolean

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

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

Default Value: false

debugShowShadowVolume : boolean

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

为基本体中的每个几何体绘制阴影体积。

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

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

由于使用的渲染技术,所有几何实例必须具有相同的颜色。 如果存在具有不同颜色的实例,将引发 DeveloperError 在第一次尝试渲染时。

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

readonly releaseGeometryInstances : boolean

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

readonly vertexCacheOptimize : boolean

如果为 true,则几何体顶点将针对前顶点着色器缓存和后顶点着色器缓存进行优化。
Default Value: true

Methods

static Cesium.ClassificationPrimitive.isSupported(scene)boolean

确定是否支持 ClassificationPrimitive 渲染。
Name Type Description
scene Scene 场景。
Returns:
true(如果支持 ClassificationPrimitives);否则,返回 false
销毁此对象持有的 WebGL 资源。 销毁对象允许确定性 释放 WebGL 资源,而不是依赖垃圾回收器来销毁这个对象。

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

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

getGeometryInstanceAttributes(id)object

返回 GeometryInstance 的可修改的每实例属性。
Name Type Description
id * GeometryInstance 的 ID。
Returns:
属性格式的类型化数组,如果不是 inst,则为 undefinedance 替换为 id。
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 : 所有实例几何体必须具有相同的 primitiveType。
  • DeveloperError : 外观和材质具有相同的名称。
  • DeveloperError : 并非所有的几何实例都具有相同的 color 属性。
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.