# StructuralMetadata

class in `3d-tiles-renderer/three/plugins`

```js
import { StructuralMetadata } from '3d-tiles-renderer/three/plugins';
```

Provides access to `EXT_structural_metadata` property tables, property textures, and
property attributes for a GLTF scene or primitive. Instances are created by
`GLTFStructuralMetadataExtension` and attached to `scene.userData.structuralMetadata`
and `mesh.userData.structuralMetadata`.

## Constructor

```js
new StructuralMetadata( definition: Object, textures: Array<Texture>, buffers: Array<ArrayBuffer>, nodeMetadata?: Object | null, object?: Object3D | null )
```

- `definition`, `Object`: The root `EXT_structural_metadata` extension object.
- `textures`, `Array<Texture>`: Loaded GLTF textures referenced by property textures.
- `buffers`, `Array<ArrayBuffer>`: Loaded GLTF buffer views referenced by property tables.
- `nodeMetadata`, `Object | null`, optional, default `null`: Per-primitive metadata indices (property texture / attribute refs).
- `object`, `Object3D | null`, optional, default `null`: The three.js object associated with `nodeMetadata`.

## Methods

### .getPropertyTableData

```js
.getPropertyTableData( tableIndices: number | Array<number>, ids: number | Array<number>, target?: Object | Array | null ): Object | Array
```

Returns data from one or more property tables. Pass a single table index and row ID to
get one object, or parallel arrays of table indices and row IDs to get an array of
results. Each returned object conforms to the structure class referenced in the schema.

- `tableIndices`, `number | Array<number>`: Table index or array of table indices.
- `ids`, `number | Array<number>`: Row ID or array of row IDs.
- `target`, `Object | Array | null`, optional, default `null`: Optional target object or array to write into.

### .getPropertyTableInfo

```js
.getPropertyTableInfo( tableIndices?: Array<number> | null ): Array<{name: string, className: string}> | Object
```

Returns name and class information for one or more property tables. Defaults to all
tables when `tableIndices` is `null`.

- `tableIndices`, `Array<number> | null`, optional, default `null`

### .getPropertyTextureData

```js
.getPropertyTextureData( triangle: number, barycoord: Vector3, target?: Array ): Array
```

Returns data from property textures at the given point on the mesh. Takes the triangle
index and barycentric coordinate from a raycast result. See `MeshFeatures.getFeatures`
for how to obtain these values.

- `triangle`, `number`: Triangle index from a raycast hit.
- `barycoord`, `Vector3`: Barycentric coordinate of the hit point.
- `target`, `Array`, optional, default `[]`: Optional target array to write into.

### .getPropertyTextureDataAsync

```js
async .getPropertyTextureDataAsync( triangle: number, barycoord: Vector3, target?: Array ): Array
```

Returns the same data as `getPropertyTextureData` but performs texture reads
asynchronously.

- `triangle`, `number`: Triangle index from a raycast hit.
- `barycoord`, `Vector3`: Barycentric coordinate of the hit point.
- `target`, `Array`, optional, default `[]`: Optional target array to write into.

### .getPropertyTextureInfo

```js
.getPropertyTextureInfo(  ): Array<{name: string, className: string, properties: Object}>
```

Returns information about the property texture accessors, including their class names
and per-property channel/texcoord mappings.

### .getPropertyAttributeData

```js
.getPropertyAttributeData( attributeIndex: number, target?: Array ): Array
```

Returns data stored as property attributes for the given vertex index.

- `attributeIndex`, `number`: Vertex index.
- `target`, `Array`, optional, default `[]`: Optional target array to write into.

### .getPropertyAttributeInfo

```js
.getPropertyAttributeInfo(  ): Array<{name: string, className: string}>
```

Returns name and class information for all property attribute accessors.

### .dispose

```js
.dispose(  )
```

Disposes all texture, table, and attribute accessors.
