Skip to content

KBE3D / KBCore / Cesium / Cesium3DTileFeature

类: Cesium3DTileFeature

A feature of a Cesium3DTileset. <p> 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 Cesium3DTileFeature#show and Cesium3DTileFeature#color, respectively. </p> <p> Modifications to a <code>Cesium3DTileFeature</code> 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 Cesium3DTileset#tileUnload event to save any modifications. Also listen to the Cesium3DTileset#tileVisible event to reapply any modifications. </p> <p> Do not construct this directly. Access it through Cesium3DTileContent#getFeature or picking using Scene#pick. </p>

示例

ts
// 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.Cesium3DTileFeature) {
        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)}`);
        }
    }
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

属性

show

show: boolean

Gets or sets if the feature will be shown. This is set for all features when a style's show is evaluated.


color

color: Color

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.


polylinePositions

polylinePositions: Float64Array

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


tileset

readonly tileset: Cesium3DTileset

Gets the tileset containing the feature.


primitive

readonly primitive: Cesium3DTileset

All objects returned by Scene#pick have a <code>primitive</code> property. This returns the tileset containing the feature.


featureId

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.

方法

getPropertyInherited()

static getPropertyInherited(content: Cesium3DTileContent, batchId: number, name: string): any

Returns a copy of the feature's property with the given name, examining all the metadata from 3D Tiles 1.0 formats, the EXT_structural_metadata and legacy EXT_feature_metadata glTF extensions, and the metadata present either in the tileset JSON (3D Tiles 1.1) or in 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:

<ol> <li>Batch table (structural metadata) property by semantic</li> <li>Batch table (structural metadata) property by property ID</li> <li>Content metadata property by semantic</li> <li>Content metadata property by property</li> <li>Tile metadata property by semantic</li> <li>Tile metadata property by property ID</li> <li>Subtree metadata property by semantic</li> <li>Subtree metadata property by property ID</li> <li>Group metadata property by semantic</li> <li>Group metadata property by property ID</li> <li>Tileset metadata property by semantic</li> <li>Tileset metadata property by property ID</li> <li>Otherwise, return undefined</li> </ol> <p> For 3D Tiles Next details, see the 3DTILES_metadata Extension

for 3D Tiles, as well as the EXT_structural_metadata Extension for glTF. For the legacy glTF extension, see EXT_feature_metadata Extension </p>

参数

content

Cesium3DTileContent

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.

返回

any

The value of the property or undefined if the feature does not have this property.


hasProperty()

hasProperty(name: string): 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

string

The case-sensitive name of the property.

返回

boolean

Whether the feature contains this property.


getPropertyIds()

getPropertyIds(results?: string[]): string[]

Returns an array of property IDs for the feature. This includes properties from this feature's class and inherited classes when using a batch table hierarchy.

参数

results?

string[]

An array into which to store the results.

返回

string[]

The IDs of the feature's properties.


getProperty()

getProperty(name: string): any

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

string

The case-sensitive name of the property.

返回

any

The value of the property or undefined if the feature does not have this property.

示例

ts
// 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)}`);
}

setProperty()

setProperty(name: string, value: any): void

Sets the value of the feature's property with the given name. <p> If a property with the given name doesn't exist, it is created. </p>

参数

name

string

The case-sensitive name of the property.

value

any

The value of the property that will be copied.

返回

void

Examples

ts
const height = feature.getProperty('Height'); // e.g., the height of a building
ts
const name = 'clicked';
if (feature.getProperty(name)) {
    console.log('already clicked');
} else {
    feature.setProperty(name, true);
    console.log('first click');
}

构造函数

构造函数

new Cesium3DTileFeature(): Cesium3DTileFeature

返回

Cesium3DTileFeature

KBE3D @3.0.0 Copyright © 2024-present KBE3D