ModelFeature

new Cesium.ModelFeature(options)

A feature of a ModelExperimental.

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 ModelExperimental 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) {
    var feature = scene.pick(movement.endPosition);
    if (feature instanceof Cesium.ModelFeature) {
        console.log(feature);
    }
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
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.

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.
Default Value: Color.WHITE
Gets or sets if the feature will be shown. This is set for all features when a style's show is evaluated.
Default Value: 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.
var propertyNames = feature.getPropertyNames();
var length = propertyNames.length;
for (var i = 0; i < length; ++i) {
    var propertyName = propertyNames[i];
    console.log(propertyName + ': ' + feature.getProperty(propertyName));
}

getPropertyInherited(name)*

Returns a copy of the feature's property with the given name, examining all the metadata from the EXT_mesh_features 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:
  1. Feature metadata property by semantic
  2. Feature metadata property by property ID

See the EXT_mesh_features Extension as well as the previous EXT_feature_metadata Extension for glTF.

Name Type Description
name String 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

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.

getPropertyNames(results)Array.<String>

Returns an array of property names for the feature.
Name Type Description
results Array.<String> optional An array into which to store the results.
Returns:
The names of the feature's properties.

hasProperty(name)Boolean

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.

setProperty(name, value)Boolean

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:
var height = feature.getProperty('Height'); // e.g., the height of a building
var name = 'clicked';
if (feature.getProperty(name)) {
    console.log('already clicked');
} else {
    feature.setProperty(name, true);
    console.log('first click');
}