Model 的一个特性。
提供对存储在模型特性表中的特性的属性的访问。
对 ModelFeature 对象的修改在模型的生命周期内有效。
请勿直接构造此对象。通过使用 Scene#pick 进行选择来访问它。
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
具有以下属性的对象:
|
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
获取与此特性相关联的特征 ID。对于 3D Tiles 1.0,返回的是批次 ID。对于 EXT_mesh_features,
返回的是来自所选特征 ID 集的特征 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));
}
返回特性的属性 ID 数组。
| Name | Type | Description |
|---|---|---|
results |
Array.<string> | optional 一个数组,用于存储结果。 |
Returns:
特性属性的 ID。
返回具有给定名称的特性属性的副本,检查来自 EXT_structural_metadata 和旧版 EXT_feature_metadata glTF
扩展的所有元数据。元数据按从最具体到最一般的名称进行检查,返回第一个匹配项。元数据的检查顺序如下:
- 按语义检查结构化元数据属性
- 按属性 ID 检查结构化元数据属性
请参阅 EXT_structural_metadata Extension 以及 之前的 EXT_feature_metadata Extension 以了解 glTF 的相关信息。
| Name | Type | Description |
|---|---|---|
name |
string | 特性的语义或属性 ID。语义在每个元数据粒度中优先于属性 ID 进行检查。 |
Returns:
属性的值,如果特性没有此属性,则返回
undefined。
Experimental
该功能使用的是 3D Tiles 规范中的一部分,该部分尚未确定,可能会在不遵循 Cesium 标准弃用政策的情况下发生更改。
返回特性是否包含此属性。
| Name | Type | Description |
|---|---|---|
name |
string | 属性的区分大小写名称。 |
Returns:
特性是否包含此属性。
设置具有给定名称的特性属性的值。
| Name | Type | Description |
|---|---|---|
name |
string | 属性的区分大小写名称。 |
value |
* | 要复制的属性值。 |
Returns:
如果属性设置成功则返回
true,否则返回 false。
Throws:
-
DeveloperError : 继承的批次表层次属性是只读的。
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');
}
