English中文

Cesium3DTileFeature

new Cesium.Cesium3DTileFeature()

一个特点是 A feature of a Cesium3DTileset.

提供对存储在图块批处理表中的功能属性的访问,以及显示/隐藏功能和更改其突出显示颜色的能力 Provides access to a feature's properties stored in the tile's batch table, as well as the ability to show/hide a feature and change its highlight color via Cesium3DTileFeature#show and Cesium3DTileFeature#color,分别。 , respectively.

修改为 Modifications to a Cesium3DTileFeature 对象具有图块内容的生命周期。如果图块的内容被卸载,例如,由于它超出了视图范围并且需要在缓存中释放可见图块的空间,请收听 object have the lifetime of the tile's content. If the tile's content is unloaded, e.g., due to it going out of view and needing to free space in the cache for visible tiles, listen to the Cesium3DTileset#tileUnload 事件来保存任何修改。还听听 event to save any modifications. Also listen to the Cesium3DTileset#tileVisible 重新应用任何修改的事件。 event to reapply any modifications.

不要直接构建它。通过访问它 Do not construct this directly. Access it through Cesium3DTileContent#getFeature 或使用采摘 or picking using Scene#pick.

示例: Example:
// On mouse over, display all the properties for a feature in the console log.
handler.setInputAction(function(movement) {
    const feature = scene.pick(movement.endPosition);
    if (feature instanceof Cesium.Cesium3DTileFeature) {
        const propertyIds = feature.getPropertyIds();
        const length = propertyIds.length;
        for (let i = 0; i < length; ++i) {
            const propertyId = propertyIds[i];
            console.log(`{propertyId}: ${feature.getProperty(propertyId)}`);
        }
    }
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

成员 Members

获取或设置突出显示颜色与要素颜色的乘积。当它为白色时,要素的颜色不会改变。这是在评估样式颜色时为所有功能设置的。 Gets or sets the highlight color multiplied with the feature's color. When this is white, the feature's color is not changed. This is set for all features when a style's color is evaluated.
默认值: Default Value: Color.WHITE
获取与此功能关联的功能 ID。对于 3D Tiles 1.0,返回批次 ID。对于 EXT_mesh_features,这是所选要素 ID 集中的要素 ID。 Get the feature ID associated with this feature. For 3D Tiles 1.0, the batch ID is returned. For EXT_mesh_features, this is the feature ID from the selected feature ID set.
实验性 Experimental

此功能使用的是 3D Tiles 规范的一部分,该规范不是最终版本,并且可能会在没有 Cesium 的标准弃用政策的情况下进行更改。 This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.

polylinePositions : Float64Array

获取包含折线 ECEF 位置的类型化数组。如果返回未定义 Gets a typed array containing the ECEF positions of the polyline. Returns undefined if Cesium3DTileset#vectorKeepDecodedPositions 为 false 或该要素不是矢量切片中的折线。 is false or the feature is not a polyline in a vector tile.
实验性 Experimental

此功能使用的是 3D Tiles 规范的一部分,该规范不是最终版本,并且可能会在没有 Cesium 的标准弃用政策的情况下进行更改。 This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.

返回的所有对象 All objects returned by Scene#pick 有一个 have a primitive 财产。这将返回包含该要素的图块集。 property. This returns the tileset containing the feature.
获取或设置是否显示该功能。这是在评估样式的显示时为所有功能设置的。 Gets or sets if the feature will be shown. This is set for all features when a style's show is evaluated.
默认值: Default Value: true
获取包含该要素的图块集。 Gets the tileset containing the feature.

方法 Methods

static Cesium.Cesium3DTileFeature.getPropertyInherited(content, batchId, name)*

返回具有给定名称的要素属性的副本,检查 3D Tiles 1.0 格式、EXT_structural_metadata 和旧版 EXT_feature_metadata glTF 扩展的所有元数据,以及切片集 JSON (3D Tiles 1.1) 或 3DTILES_metadata 3D Tiles 扩展中存在的元数据。元数据根据名称从最具体到最一般进行检查,并返回第一个匹配项。元数据按以下顺序检查: Returns a copy of the feature's property with the given name, examining all the metadata from 3D Tiles 1.0 formats, the EXT_structural_metadata and legacy EXT_feature_metadata glTF extensions, and the metadata present either in the tileset JSON (3D Tiles 1.1) or in the 3DTILES_metadata 3D Tiles extension. Metadata is checked against name from most specific to most general and the first match is returned. Metadata is checked in this order:
  1. 按语义划分的批处理表(结构元数据)属性 Batch table (structural metadata) property by semantic
  2. 按属性 ID 划分的批处理表(结构元数据)属性 Batch table (structural metadata) property by property ID
  3. 按语义划分的内容元数据属性 Content metadata property by semantic
  4. 按属性划分的内容元数据属性 Content metadata property by property
  5. 按语义平铺元数据属性 Tile metadata property by semantic
  6. 按属性 ID 平铺元数据属性 Tile metadata property by property ID
  7. 按语义划分的子树元数据属性 Subtree metadata property by semantic
  8. 按属性 ID 划分的子树元数据属性 Subtree metadata property by property ID
  9. 按语义对元数据属性进行分组 Group metadata property by semantic
  10. 按属性 ID 对元数据属性进行分组 Group metadata property by property ID
  11. 按语义划分的图块集元数据属性 Tileset metadata property by semantic
  12. 按属性 ID 划分的图块集元数据属性 Tileset metadata property by property ID
  13. 否则,返回未定义 Otherwise, return undefined

有关 3D Tiles Next 详细信息,请参阅 For 3D Tiles Next details, see the 3DTILES_metadata Extension 对于 3D Tiles,以及 for 3D Tiles, as well as the EXT_structural_metadata Extension 对于 glTF。对于旧版 glTF 扩展,请参阅 for glTF. For the legacy glTF extension, see EXT_feature_metadata Extension

名称 Name 类型 Type 说明 Description
content Cesium3DTileContent 用于访问元数据的内容 The content for accessing the metadata
batchId number 要获取其属性的要素的批次 ID(或要素 ID) The batch ID (or feature ID) of the feature to get a property for
name string 功能的语义或属性 ID。在元数据的每个粒度中,在属性 ID 之前检查语义。 The semantic or property ID of the feature. Semantics are checked before property IDs in each granularity of metadata.
返回: Returns:
财产的价值或 The value of the property or undefined 如果该功能没有此属性。 if the feature does not have this property.
实验性 Experimental

此功能使用的是 3D Tiles 规范的一部分,该规范不是最终版本,并且可能会在没有 Cesium 的标准弃用政策的情况下进行更改。 This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.

返回具有给定名称的要素属性值的副本。这包括使用批处理表层次结构时来自该功能的类和继承类的属性。 Returns a copy of the value of the feature's property with the given name. This includes properties from this feature's class and inherited classes when using a batch table hierarchy.
名称 Name 类型 Type 说明 Description
name string 属性的名称区分大小写。 The case-sensitive name of the property.
返回: Returns:
财产的价值或 The value of the property or undefined 如果该功能没有此属性。 if the feature does not have this property.
示例: Example:
// Display all the properties for a feature in the console log.
const propertyIds = feature.getPropertyIds();
const length = propertyIds.length;
for (let i = 0; i < length; ++i) {
    const propertyId = propertyIds[i];
    console.log(`{propertyId}: ${feature.getProperty(propertyId)}`);
}
另见: See:

getPropertyIds(results)Array.<string>

返回该功能的属性 ID 数组。这包括使用批处理表层次结构时来自该功能的类和继承类的属性。 Returns an array of property IDs for the feature. This includes properties from this feature's class and inherited classes when using a batch table hierarchy.
名称 Name 类型 Type 说明 Description
results Array.<string> 可选 optional 用于存储结果的数组。 An array into which to store the results.
返回: Returns:
要素属性的 ID。 The IDs of the feature's properties.
另见: See:

hasProperty(name)boolean

返回该功能是否包含此属性。这包括使用批处理表层次结构时来自该功能的类和继承类的属性。 Returns whether the feature contains this property. This includes properties from this feature's class and inherited classes when using a batch table hierarchy.
名称 Name 类型 Type 说明 Description
name string 属性的名称区分大小写。 The case-sensitive name of the property.
返回: Returns:
该功能是否包含此属性。 Whether the feature contains this property.
另见: See:
设置具有给定名称的要素属性的值。 Sets the value of the feature's property with the given name.

如果具有给定名称的属性不存在,则会创建该属性。 If a property with the given name doesn't exist, it is created.

名称 Name 类型 Type 说明 Description
name string 属性的名称区分大小写。 The case-sensitive name of the property.
value * 将复制的属性的值。 The value of the property that will be copied.
抛出: Throws:
  • DeveloperError :继承的批处理表层次结构属性是只读的。 : Inherited batch table hierarchy property is read only.
示例: Examples:
const height = feature.getProperty('Height'); // e.g., the height of a building
const name = 'clicked';
if (feature.getProperty(name)) {
    console.log('already clicked');
} else {
    feature.setProperty(name, true);
    console.log('first click');
}
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.