---
title: "addByResolutionMetric(to:levels:boundingBox:)"
framework: realitykit
role: symbol
role_heading: Type Method
path: "realitykit/levelofdetailcomponent/addbyresolutionmetric(to:levels:boundingbox:)"
---

# addByResolutionMetric(to:levels:boundingBox:)

Adds Level of Detail configuration using resolution metric-based switching to an entity.

## Declaration

```swift
static func addByResolutionMetric(to entity: Entity, levels: [(entities: LevelOfDetailComponent.DetailLevel, switchingResolutions: LevelOfDetailComponent.SelectionStrategy.ResolutionMetric.DirectionalSwitchingResolutions)], boundingBox: BoundingBox)
```

## Parameters

- `levels`: An array of levels, where each level specifies the entities to display and the level’s associated directional switching resolutions.
- `boundingBox`: The bounding box of the entity used when calculating the switching resolutions .

## Discussion

Discussion Each level pairs a set of entities with a directional switching resolutions struct. Level 0 should have an empty directional switching resolutions struct. Entities within a level are shown or hidden together. Each entity in the provided levels is added as a child of the entity the component will be added to. Children not included in any level are unaffected by LOD switching.

## See Also

### Creating a component

- [init(levels:switchingAt:)](realitykit/levelofdetailcomponent/init(levels:switchingat:).md)
- [addByCameraDistance(to:levels:)](realitykit/levelofdetailcomponent/addbycameradistance(to:levels:).md)
- [addByScreenArea(to:levels:)](realitykit/levelofdetailcomponent/addbyscreenarea(to:levels:).md)
