FreedoPModelFeature

new Freedo.FreedoPModelFeature()

A feature of a FreedoPModelset.

Provides access to a feature's properties stored in the tile's batch table, as well as the ability to show/hide a feature and change its highlight color via FreedoPModelFeature#show and FreedoPModelFeature#color, respectively.

Modifications to a FreedoPModelFeature object have the lifetime of the tile's content. If the tile's content is unloaded, e.g., due to it going out of view and needing to free space in the cache for visible tiles, listen to the FreedoPModelset#tileUnload event to save any modifications. Also listen to the FreedoPModelset#tileVisible event to reapply any modifications.

Do not construct this directly. Access it through FreedoPModelContent#getFeature or picking using Scene#pick.

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 Freedo.FreedoPModelFeature) {
        const propertyNames = feature.getPropertyNames();
        const length = propertyNames.length;
        for (let i = 0; i < length; ++i) {
            const propertyName = propertyNames[i];
            console.log(propertyName + ': ' + feature.getProperty(propertyName));
        }
    }
}, Freedo.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.
Default Value: Color.WHITE

readonly featureId : Number

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 Freedo's standard deprecation policy.

polylinePositions : Float64Array

Gets a typed array containing the ECEF positions of the polyline. Returns undefined if FreedoPModelset#vectorKeepDecodedPositions is false or the feature is not a polyline in a vector tile.
Experimental

This feature is using part of the 3D Tiles spec that is not final and is subject to change without Freedo's standard deprecation policy.

All objects returned by Scene#pick have a primitive property. This returns the tileset containing the feature.
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
Gets the tileset containing the feature.

Methods

static Freedo.FreedoPModelFeature.getPropertyInherited(content, batchId, name)*

Returns a copy of the feature's property with the given name, examining all the metadata from 3D Tiles 1.0 formats, the EXT_mesh_features and legacy EXT_feature_metadata glTF extensions, and the 3DTILES_metadata 3D Tiles extension. Metadata is checked against name from most specific to most general and the first match is returned. Metadata is checked in this order:
  1. Batch table (feature metadata) property by semantic
  2. Batch table (feature metadata) property by property ID
  3. Tile metadata property by semantic
  4. Tile metadata property by property ID
  5. Group metadata property by semantic
  6. Group metadata property by property ID
  7. Tileset metadata property by semantic
  8. Tileset metadata property by property ID
  9. Otherwise, return undefined

For 3D Tiles Next details, see the 3DTILES_metadata Extension for 3D Tiles, as well as the EXT_mesh_features Extension for glTF. For the legacy glTF extension, see EXT_feature_metadata Extension

Name Type Description
content FreedoPModelContent The content for accessing the metadata
batchId Number The batch ID (or feature ID) of the feature to get a property for
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 Freedo's standard deprecation policy.

getAncestors(attributeName, results)Array.<String>

返回本Feature及其所有直接长辈关系节点的属性名为attributeName的属性值,注意这里只取Hierarchy Batch Table中的属性的值
Name Type Description
attributeName String 需要取的属性的名称
results Array.<String> 返回的属性值的数组
Returns:
Example:
// Display all the properties for a feature in the console log.
var components = feature.getAncestors('component');
var length = components.length;
for (var i = 0; i < length; ++i) {
    var componentValue = components[i];
}

getProperty(name)*

Returns a copy of the value of the feature's property with the given name. This includes properties from this feature's class and inherited classes when using a batch table hierarchy.
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 propertyNames = feature.getPropertyNames();
const length = propertyNames.length;
for (let i = 0; i < length; ++i) {
    const propertyName = propertyNames[i];
    console.log(propertyName + ': ' + feature.getProperty(propertyName));
}
See:

getPropertyNames(results)Array.<String>

Returns an array of property names for the feature. This includes properties from this feature's class and inherited classes when using a batch table hierarchy.
Name Type Description
results Array.<String> optional An array into which to store the results.
Returns:
The names of the feature's properties.
See:

hasHierarchyProperty(attributeName, attributeValue)Boolean

判断本Feature及其所有直接长辈关系的节点中是否有属性名为attributeName属性值为attributeValue的节点
Name Type Description
attributeName String 需要判断的属性名,例如 'component'
attributeValue String 需要判断的属性值
Returns:
如果有属性名为attributeName属性值为attributeValue的节点,返回true,否则false

hasProperty(name)Boolean

Returns whether the feature contains this property. This includes properties from this feature's class and inherited classes when using a batch table hierarchy.
Name Type Description
name String The case-sensitive name of the property.
Returns:
Whether the feature contains this property.
See:

setProperty(name, value)

Sets the value of the feature's property with the given name.

If a property with the given name doesn't exist, it is created.

Name Type Description
name String The case-sensitive name of the property.
value * The value of the property that will be copied.
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');
}