<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/PhysicalMetricsConverter",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI24PhysicalMetricsConverterV"
  },
  "title" : "PhysicalMetricsConverter"
}
-->

# PhysicalMetricsConverter

A physical metrics converter provides conversion between point values and
their extent in 3D space, in the form of physical length measurements.

```
@MainActor @preconcurrency struct PhysicalMetricsConverter
```

## Overview

Converters are available from the environment of a `View` or other type that
inherits a `View`‘s environments, and are associated with the scene that
contains that environment. The conversions expect (or emit) values in points
in that scene’s coordinate system, and convert these to (or from) measurements
of length in the user’s or scene’s reference frame.

To obtain a converter, use the [`physicalMetrics`](/documentation/SwiftUI/EnvironmentValues/physicalMetrics) key:

```swift
struct MyView: View {
    @Environment(\.physicalMetrics) var physicalMetrics
    …
}
```

When user action modifies a scene so that measurements have changed (e.g., by
changing its scale), the view that accessed that environment key and its hierarchy
will be reevaluated.

Attempting to obtain a converter inside a type not associated with a scene’s
contents (for example, from an [`App`](/documentation/SwiftUI/App) or [`Scene`](/documentation/SwiftUI/Scene)’s environment) is not
supported.

## Compensating for World Scaling

By default in apps linked against the visionOS 2.0 SDK or later, these conversions
match the scene’s coordinate system, including any scale applied to it by the system.
If you’re using meters as the unit, this will match the notion of meters in an
unscaled `RealityView` in the same scene.

To obtain measurements that are accurate to the user’s surroundings, use the
[`worldScalingCompensation(_:)`](/documentation/SwiftUI/PhysicalMetricsConverter/worldScalingCompensation(_:))
method to enable an appropriate compensation mode for the scale.

## Topics

### Converting a unit length

[`func convert(_:from:)`](/documentation/SwiftUI/PhysicalMetricsConverter/convert(_:from:))

Converts a length in the specified unit
to a length in points suitable for use in the environment this
converter is associated with.

[`func convert(_:to:)`](/documentation/SwiftUI/PhysicalMetricsConverter/convert(_:to:))

Converts a point’s coordinates to physical length
measurements in the specified unit.

### Instance Properties

[`var worldScalingCompensation: WorldScalingCompensation`](/documentation/SwiftUI/PhysicalMetricsConverter/worldScalingCompensation)

Provides the current world scale compensation of this converter.

### Instance Methods

[`func worldScalingCompensation(WorldScalingCompensation) -> PhysicalMetricsConverter`](/documentation/SwiftUI/PhysicalMetricsConverter/worldScalingCompensation(_:))

Obtains a new converter with a different world scale compensation
behavior.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`Equatable`](/documentation/Swift/Equatable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)