一个特点是
A feature of a Model.
提供对存储在模型特征表中的特征属性的访问。 Provides access to a feature's properties stored in the model's feature table.
修改为 Modifications to a ModelFeature 对象具有模型的生命周期。 object have the lifetime of the model.
不要直接构建它。通过使用选择来访问它 Do not construct this directly. Access it through picking using Scene#pick.
| 名称 Name |
类型 Type |
说明 Description |
options |
object
|
具有以下属性的对象: Object with the following properties:
| 名称 Name |
类型 Type |
说明 Description |
model |
Model
|
该特征所属的模型。 The model the feature belongs to. |
featureId |
number
|
此功能的唯一整体标识符。 The unique integral identifier for this feature. |
|
示例: 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
获取或设置突出显示颜色与要素颜色的乘积。当它为白色时,要素的颜色不会改变。这是在评估样式颜色时为所有功能设置的。 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.
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.
获取或设置是否显示该功能。这是在评估样式的显示时为所有功能设置的。 Gets or sets if the feature will be shown. This is set for all features when a style's show is evaluated.
true
方法 Methods
返回具有给定名称的要素属性值的副本。 Returns a copy of the value of the feature's property with the given name.
| 名称 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));
}
返回该功能的属性 ID 数组。 Returns an array of property IDs for the feature.
| 名称 Name |
类型 Type |
说明 Description |
results |
Array.<string>
|
可选 optional
用于存储结果的数组。 An array into which to store the results. |
返回: Returns:
要素属性的 ID。 The IDs of the feature's properties.
返回具有给定名称的要素属性的副本,检查 EXT_structural_metadata 和旧版 EXT_feature_metadata glTF 扩展中的所有元数据。元数据根据名称从最具体到最一般进行检查,并返回第一个匹配项。元数据按以下顺序检查:
Returns a copy of the feature's property with the given name, examining all the metadata from the EXT_structural_metadata and legacy EXT_feature_metadata glTF extensions. Metadata is checked against name from most specific to most general and the first match is returned. Metadata is checked in this order:
- 按语义划分的结构元数据属性 structural metadata property by semantic
- 按属性 ID 划分的结构元数据属性 structural metadata property by property ID
请参阅 See the EXT_structural_metadata Extension 以及之前的 as well as the previous EXT_feature_metadata Extension 对于 glTF。 for glTF.
| 名称 Name |
类型 Type |
说明 Description |
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 whether the feature contains this property.
| 名称 Name |
类型 Type |
说明 Description |
name |
string
|
属性的名称区分大小写。 The case-sensitive name of the property. |
返回: Returns:
该功能是否包含此属性。 Whether the feature contains this property.
设置具有给定名称的要素属性的值。 Sets the value of the feature's property with the given name.
| 名称 Name |
类型 Type |
说明 Description |
name |
string
|
属性的名称区分大小写。 The case-sensitive name of the property. |
value |
*
|
将复制的属性的值。 The value of the property that will be copied. |
返回: Returns:
true 如果设置了该属性, if the property was set, false otherwise.
抛出: 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');
}