<!--
{
  "availability" : [
    "macOS: 27.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "SpatialPreview",
  "identifier" : "/documentation/SpatialPreview/USDPreviewSession",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Spatial Preview",
      "USDKit"
    ],
    "preciseIdentifier" : "s:22_SpatialPreview_USDKit17USDPreviewSessionC"
  },
  "title" : "USDPreviewSession"
}
-->

# USDPreviewSession

A session that enables you to present the contents of a Universal Scene Description (USD) stage.

```
final class USDPreviewSession
```

## Overview

To create a `USDPreviewSession`, initialize one with a <doc://com.apple.documentation/documentation/USDKit/USDStage> from <doc://com.apple.documentation/documentation/USDKit>:

```swift
let observer = ConnectedSpatialEndpointObserver()

let session = USDPreviewSession(stage: usdStage)

// Wait for a device to become available.
let endpoint = try await observer.endpoint

try await session.start(endpoint: endpoint)
```

After [`start(endpoint:parameters:viewerOptions:)`](/documentation/SpatialPreview/USDPreviewSession/start(endpoint:parameters:viewerOptions:)) returns, the session’s `state` transitions to [`SpatialPreviewSessionState.connected`](/documentation/SpatialPreview/SpatialPreviewSessionState/connected) and the device starts loading the USD content. Then use <doc://com.apple.documentation/documentation/USDKit> to make edits to the <doc://com.apple.documentation/documentation/USDKit/USDStage> to update the content. Changes on visionOS are automatically synchronized back to <doc://com.apple.documentation/documentation/USDKit> in your macOS app.

## Topics

### Protocols

[`protocol ChangeListDelegate`](/documentation/SpatialPreview/USDPreviewSession/ChangeListDelegate)

A protocol to provide shared undo/redo tracking in a USDPreviewSession.

### Structures

[`struct OptimizationSteps`](/documentation/SpatialPreview/USDPreviewSession/OptimizationSteps)

A set of optimization steps to apply to a USD stage before previewing on a device.

[`struct SpatialViewerOptions`](/documentation/SpatialPreview/USDPreviewSession/SpatialViewerOptions)

Configuration options that control interaction capabilities for a USD document session.

### Initializers

[`convenience init(stage: USDStage)`](/documentation/SpatialPreview/USDPreviewSession/init(stage:))

### Instance Properties

[`var delegate: (any USDPreviewSession.ChangeListDelegate)?`](/documentation/SpatialPreview/USDPreviewSession/delegate)

Optional synchronous undo/redo event delegate

[`let events: any AsyncSequence<USDPreviewSession.Event, Never>`](/documentation/SpatialPreview/USDPreviewSession/events)

Async sequence of session events

[`var isPlaying: Bool`](/documentation/SpatialPreview/USDPreviewSession/isPlaying)

[`var time: TimeInterval`](/documentation/SpatialPreview/USDPreviewSession/time)

### Instance Methods

[`func start(endpoint: SpatialPreviewEndpoint, parameters: USDPreviewSession.OptimizationParameters, viewerOptions: USDPreviewSession.SpatialViewerOptions) async throws`](/documentation/SpatialPreview/USDPreviewSession/start(endpoint:parameters:viewerOptions:))

Connects to the specified endpoint and begins streaming the USD stage for spatial preview.

[`func updateUndoRedoCounts(undo: UInt, redo: UInt) async throws`](/documentation/SpatialPreview/USDPreviewSession/updateUndoRedoCounts(undo:redo:))

Update the count of undoable and redoable actions in the USDPreviewSession which is reflected in the UI on visionOS.

### Enumerations

[`enum Error`](/documentation/SpatialPreview/USDPreviewSession/Error)

Errors that can occur during a USD preview session

[`enum Event`](/documentation/SpatialPreview/USDPreviewSession/Event)

Events emitted during a USD preview session

[`enum OptimizationParameters`](/documentation/SpatialPreview/USDPreviewSession/OptimizationParameters)

## Relationships

### Conforms To

[`Observable`](/documentation/Observation/Observable)

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

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

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

[`SpatialPreviewSession`](/documentation/SpatialPreview/SpatialPreviewSession)

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

---

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)