ModelFeature

new Cesium.ModelFeature(options)

Model 的一个功能。

提供对存储在模型特征表中的特征属性的访问。

ModelFeature 对象的修改具有模型的生命周期。

不要直接构造它。通过使用 Scene#pick 进行选取来访问它。

Name Type Description
options object 对象,具有以下属性:
Name Type Description
model Model 特征所属的模型。
featureId number 此功能的唯一整数标识符。
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.ModelFeature) {
        console.log(feature);
    }
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

Members

获取或设置高亮颜色 (highlight color) 与特征颜色相乘。 什么时候 这是白色的,特征的颜色不会改变。这是为所有功能设置的 当评估样式的颜色时。
Default Value: Color.WHITE

readonly featureId : number

获取与此功能关联的功能 ID。对于 3D 瓦片 1.0, 返回批处理 ID。对于EXT_mesh_features,这是 所选特征 ID 集。
Experimental

此功能使用的是 3D Tiles 规范的一部分,该规范不是最终版本,并且可能会在没有 Cesium 标准弃用策略的情况下进行更改。

获取或设置是否功能。这是为所有功能设置的 评估样式的显示时。
Default Value: true

Methods

返回具有给定名称的功能属性的值的副本。
Name Type Description
name string 属性的区分大小写的名称。
Returns:
属性的值,如果特征没有此属性,则为undefined
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));
}

getPropertyIds(results)Array.<string>

返回功能的属性 ID 数组。
Name Type Description
results Array.<string> optional 存储结果的数组。
Returns:
功能属性的 ID。

getPropertyInherited(name)*

返回具有给定名称的功能属性的副本,检查所有 来自 glTF EXT_structural_metadata 和旧版 EXT_feature_metadata 的元数据 扩展。根据名称从最具体到最详细检查元数据 general,并返回第一个匹配项。元数据按以下顺序检查:
  1. 语义的结构元数据属性
  2. 按属性 ID 划分的结构元数据属性

参见 EXT_structural_metadata Extension 以及 上一页 EXT_feature_metadata Extension 来表示 glTF。

Name Type Description
name string 特征的语义或属性 ID。在每个元数据粒度中,在属性 ID 之前检查语义。
Returns:
属性的值,如果功能没有此属性,则为 undefined
Experimental

此功能使用的是 3D Tiles 规范的一部分,该规范并非最终版本,并且可能会在没有 Cesium 标准弃用政策的情况下进行更改。

hasProperty(name)boolean

返回功能是否包含此属性。
Name Type Description
name string 属性的区分大小写的名称。
Returns:
特征是否包含此属性。

setProperty(name, value)boolean

使用给定名称设置功能属性的值。
Name Type Description
name string 属性的区分大小写的名称。
value * 将要复制的属性的值。
Returns:
true(如果设置了该属性),否则false,。
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.