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
.
参数名称 | 类型 | 描述信息 | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Object with the following properties:
|
使用示例:
// 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);
成员(属性)
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
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
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
方法
Returns a copy of the value of the feature's property with the given name.
参数名称 | 类型 | 描述信息 |
---|---|---|
name |
string | The case-sensitive name of the property. |
返回值:
The value of the property or
undefined
if the feature does not have this property.
使用示例:
// 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));
}
Returns an array of property IDs for the feature.
参数名称 | 类型 | 描述信息 |
---|---|---|
results |
Array.<string> | 可选 An array into which to store the results. |
返回值:
The IDs of the feature's properties.
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
- structural metadata property by property ID
See the EXT_structural_metadata Extension as well as the previous EXT_feature_metadata Extension for glTF.
参数名称 | 类型 | 描述信息 |
---|---|---|
name |
string | The semantic or property ID of the feature. Semantics are checked before property IDs in each granularity of metadata. |
返回值:
The value of the property or
undefined
if the feature does not have this property.
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.
Returns whether the feature contains this property.
参数名称 | 类型 | 描述信息 |
---|---|---|
name |
string | The case-sensitive name of the property. |
返回值:
Whether the feature contains this property.
Sets the value of the feature's property with the given name.
参数名称 | 类型 | 描述信息 |
---|---|---|
name |
string | The case-sensitive name of the property. |
value |
* | The value of the property that will be copied. |
返回值:
true
if the property was set, false
otherwise.
Throws:
-
DeveloperError : Inherited batch table hierarchy property is read only.
使用示例s:
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');
}