ModelFeature

new Cesium.ModelFeature(options)

Model 的一个要素。

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

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

不要直接构造此对象。应通过拾取使用 Scene#pick 来访问。

Name Type Description
options object Object with the following properties:
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

获取或设置与要素颜色相乘的高亮颜色。当 该颜色为白色时,要素的颜色不会改变。在为所有要素 计算样式颜色时会设置此值。
Default Value: Color.WHITE

readonly featureId : number

获取与此要素关联的特征 ID。对于 3D Tiles 1.0, 返回批处理 ID。对于 EXT_mesh_features,这是来自 所选特征 ID 集合的特征 ID。
Experimental

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.

获取或设置要素是否显示。在为所有要素 计算样式的 show 时会设置此值。
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)*

返回具有给定名称的要素属性的副本,并检查来自 EXT_structural_metadata 以及旧版 EXT_feature_metadata glTF 扩展的所有元数据。元数据按从最具体到最通用的名称进行匹配, 并返回第一个匹配项。元数据按以下顺序检查:
  1. 按语义的结构化元数据属性
  2. 按属性 ID 的结构化元数据属性

有关 glTF 的 EXT_structural_metadata 扩展 以及之前 的 EXT_feature_metadata 扩展,请参阅相关文档。

Name Type Description
name string 要素的语义或属性 ID。在每种粒度的元数据中,都会先检查语义再检查属性 ID。
Returns:
属性的值;如果要素不具有该属性,则为 undefined
Experimental

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.

hasProperty(name)boolean

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

setProperty(name, value)boolean

设置具有给定名称的要素属性的值。
Name Type Description
name string 属性的区分大小写的名称。
value * 将被复制的属性值。
Returns:
true 如果属性已被设置,否则为 false
Throws:
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');
}
需要帮助?获取答案的最快方式是在 Cesium 论坛 上向社区和团队提问。