What's New / Spatial, 3D & RealityKit

What's new in _SpatialPreview_USDKit

+15 NewmacOS

_SpatialPreview_USDKit is a Swift cross-import overlay, not a standalone framework. It exposes API only when a target imports both SpatialPreview and USDKit. It covers previewing USD content through USDPreviewSession and its session options.

The 27 SDK adds 15 APIs and removes or deprecates none. New types are the enums Event, Error, and OptimizationParameters and the struct OptimizationSteps. The overlay also surfaces USDPreviewSession with its nested SpatialViewerOptions and Error, plus collection conformances on OptimizationSteps and SpatialViewerOptions (ArrayLiteralElement, Element, RawValue).

New

15
enum

Error

NewmacOS
public enum Error : Error

Errors that can occur during a USD preview session

Declaration
public enum Error : Error {

    /// The stage became too complex to sync.
    case assetUnshareable

    /// The stage was replaced during optimization and any changes made to the stage won't be synced.
    case readOnlyStage

    /// Returns a Boolean value indicating whether two values are equal.
    ///
    /// Equality is the inverse of inequality. For any values `a` and `b`,
    /// `a == b` implies that `a != b` is `false`.
    ///
    /// - Parameters:
    ///   - lhs: A value to compare.
    ///   - rhs: Another value to compare.
    public static func == (a: USDPreviewSession.Error, b: USDPreviewSession.Error) -> Bool

    /// Hashes the essential components of this value by feeding them into the
    /// given hasher.
    ///
    /// Implement this method to conform to the `Hashable` protocol. The
    /// components used for hashing must be the same as the components compared
    /// in your type's `==` operator implementation. Call `hasher.combine(_:)`
    /// with each of these components.
    ///
    /// - Important: In your implementation of `hash(into:)`,
    ///   don't call `finalize()` on the `hasher` instance provided,
    ///   or replace it with a different instance.
    ///   Doing so may become a compile-time error in the future.
    ///
    /// - Parameter hasher: The hasher to use when combining the components
    ///   of this instance.
    public func hash(into hasher: inout Hasher)

    /// The hash value.
    ///
    /// Hash values are not guaranteed to be equal across different executions of
    /// your program. Do not save hash values to use during a future execution.
    ///
    /// - Important: `hashValue` is deprecated as a `Hashable` requirement. To
    ///   conform to `Hashable`, implement the `hash(into:)` requirement instead.
    ///   The compiler provides an implementation for `hashValue` for you.
    public var hashValue: Int { get }
}
enum

Event

NewmacOS
public enum Event : Sendable

Events emitted during a USD preview session

Declaration
public enum Event : Sendable {

    /// The USD animation timecode has changed
    case timeChanged(TimeInterval)

    /// The USD's animation playback state has changed
    case playbackStateChanged(isPlaying: Bool)

    /// Session error (editing read-only stage, etc.)
    case error(USDPreviewSession.Error)
}
enum

OptimizationParameters

NewmacOS
public enum OptimizationParameters : Sendable, CustomStringConvertible
Declaration
public enum OptimizationParameters : Sendable, CustomStringConvertible {

    /// The USD stage is used as-is with no optimization.
    case unmodified

    /// Allows the stage to analyzed for the given `OptimizationSteps` preferences and have those prefences applied.
    case processed(USDPreviewSession.OptimizationSteps)

    /// A textual representation of this instance.
    ///
    /// Calling this property directly is discouraged. Instead, convert an
    /// instance of any type to a string by using the `String(describing:)`
    /// initializer. This initializer works with any type, and uses the custom
    /// `description` property for types that conform to
    /// `CustomStringConvertible`:
    ///
    ///     struct Point: CustomStringConvertible {
    ///         let x: Int, y: Int
    ///
    ///         var description: String {
    ///             return "(\(x), \(y))"
    ///         }
    ///     }
    ///
    ///     let p = Point(x: 21, y: 30)
    ///     let s = String(describing: p)
    ///     print(s)
    ///     // Prints "(21, 30)"
    ///
    /// The conversion of `p` to a string in the assignment to `s` uses the
    /// `Point` type's `description` property.
    public var description: String { get }
}
struct

OptimizationSteps

NewmacOS
public struct OptimizationSteps : OptionSet, Sendable

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

Declaration
public struct OptimizationSteps : OptionSet, Sendable {

    /// The corresponding value of the raw type.
    ///
    /// A new instance initialized with `rawValue` will be equivalent to this
    /// instance. For example:
    ///
    ///     enum PaperSize: String {
    ///         case A4, A5, Letter, Legal
    ///     }
    ///
    ///     let selectedSize = PaperSize.Letter
    ///     print(selectedSize.rawValue)
    ///     // Prints "Letter"
    ///
    ///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
    ///     // Prints "true"
    public let rawValue: Int

    /// Creates a new option set from the given raw value.
    ///
    /// This initializer always succeeds, even if the value passed as `rawValue`
    /// exceeds the static properties declared as part of the option set. This
    /// example creates an instance of `ShippingOptions` with a raw value beyond
    /// the highest element, with a bit mask that effectively contains all the
    /// declared static members.
    ///
    ///     let extraOptions = ShippingOptions(rawValue: 255)
    ///     print(extraOptions.isStrictSuperset(of: .all))
    ///     // Prints "true"
    ///
    /// - Parameter rawValue: The raw value of the option set to create. Each bit
    ///   of `rawValue` potentially represents an element of the option set,
    ///   though raw values may include bits that are not defined as distinct
    ///   values of the `OptionSet` type.
    public init(rawValue: Int)

    /// Allows the USD stage to be analyzed and potentially simplified or replaced with a proxy before previewing on a device.
    /// The USD analysis decides at runtime whether the stage can be passed as-is, simplified in place, or swapped for a lower-fidelity proxy based on scene complexity and session capabilities.
    public static let optimized: USDPreviewSession.OptimizationSteps

    /// Allows the USD stage's textures and meshes to be compressed before previewing on a device.
    /// Reduces the transmission file size of the USD stage by compressing textures and meshes to
    /// minimize the data sent, and is only applied when the stage exceeds the compression threshold.
    /// Can be combined with `.optimized` — compression runs after the `.optimized` optimization step
    /// on the resulting stage.
    public static let compressed: USDPreviewSession.OptimizationSteps

    /// The type of the elements of an array literal.
    @available(macOS 27.0, visionOS 27.0, *)
    public typealias ArrayLiteralElement = USDPreviewSession.OptimizationSteps

    /// The element type of the option set.
    ///
    /// To inherit all the default implementations from the `OptionSet` protocol,
    /// the `Element` type must be `Self`, the default.
    @available(macOS 27.0, visionOS 27.0, *)
    public typealias Element = USDPreviewSession.OptimizationSteps

    /// The raw type that can be used to represent all values of the conforming
    /// type.
    ///
    /// Every distinct value of the conforming type has a corresponding unique
    /// value of the `RawValue` type, but there may be values of the `RawValue`
    /// type that don't have a corresponding value of the conforming type.
    @available(macOS 27.0, visionOS 27.0, *)
    public typealias RawValue = Int
}
extension

USDPreviewSession

NewmacOS
extension USDPreviewSession : Observable
Declaration
extension USDPreviewSession : Observable {
}
extension

USDPreviewSession

NewmacOS
extension USDPreviewSession : @unchecked Sendable
Declaration
extension USDPreviewSession : @unchecked Sendable {
}
extension

USDPreviewSession

NewmacOS
extension USDPreviewSession
Declaration
extension USDPreviewSession {

    /// Configuration options that control interaction capabilities for a USD document session.
    ///
    /// Use these options to specify what features are available to users during a remote preview session.
    /// Options can be combined using standard `OptionSet` syntax to create custom configurations.
    ///
    public struct SpatialViewerOptions : OptionSet, Sendable, CustomStringConvertible {

        /// The corresponding value of the raw type.
        ///
        /// A new instance initialized with `rawValue` will be equivalent to this
        /// instance. For example:
        ///
        ///     enum PaperSize: String {
        ///         case A4, A5, Letter, Legal
        ///     }
        ///
        ///     let selectedSize = PaperSize.Letter
        ///     print(selectedSize.rawValue)
        ///     // Prints "Letter"
        ///
        ///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
        ///     // Prints "true"
        public let rawValue: Int

        /// Creates a new option set from the given raw value.
        ///
        /// This initializer always succeeds, even if the value passed as `rawValue`
        /// exceeds the static properties declared as part of the option set. This
        /// example creates an instance of `ShippingOptions` with a raw value beyond
        /// the highest element, with a bit mask that effectively contains all the
        /// declared static members.
        ///
        ///     let extraOptions = ShippingOptions(rawValue: 255)
        ///     print(extraOptions.isStrictSuperset(of: .all))
        ///     // Prints "true"
        ///
        /// - Parameter rawValue: The raw value of the option set to create. Each bit
        ///   of `rawValue` potentially represents an element of the option set,
        ///   though raw values may include bits that are not defined as distinct
        ///   values of the `OptionSet` type.
        public init(rawValue: Int)

        /// Enables annotation capabilities during the `USDPreviewSession`.
        public static let annotations: USDPreviewSession.SpatialViewerOptions

        /// Enables per-object manipulation capabilities during the `USDPreviewSession`.
        public static let perObjectManipulation: USDPreviewSession.SpatialViewerOptions

        /// Enables export capabilities during the `USDPreviewSession`
        public static let export: USDPreviewSession.SpatialViewerOptions

        /// A human-readable description of the enabled options.
        public var description: String { get }

        /// The default configuration enabling all available interaction capabilities.
        public static let `default`: USDPreviewSession.SpatialViewerOptions

        /// The type of the elements of an array literal.
        @available(macOS 27.0, visionOS 27.0, *)
        public typealias ArrayLiteralElement = USDPreviewSession.SpatialViewerOptions

        /// The element type of the option set.
        ///
        /// To inherit all the default implementations from the `OptionSet` protocol,
        /// the `Element` type must be `Self`, the default.
        @available(macOS 27.0, visionOS 27.0, *)
        public typealias Element = USDPreviewSession.SpatialViewerOptions

        /// The raw type that can be used to represent all values of the conforming
        /// type.
        ///
        /// Every distinct value of the conforming type has a corresponding unique
        /// value of the `RawValue` type, but there may be values of the `RawValue`
        /// type that don't have a corresponding value of the conforming type.
        @available(macOS 27.0, visionOS 27.0, *)
        public typealias RawValue = Int
    }
}
extension

USDPreviewSession.Error

NewmacOS
extension USDPreviewSession.Error : Equatable
Declaration
extension USDPreviewSession.Error : Equatable {
}
extension

USDPreviewSession.Error

NewmacOS
extension USDPreviewSession.Error : Hashable
Declaration
extension USDPreviewSession.Error : Hashable {
}
typealias

OptimizationSteps.ArrayLiteralElement

NewmacOS
public typealias ArrayLiteralElement = USDPreviewSession.OptimizationSteps

The type of the elements of an array literal.

typealias

OptimizationSteps.Element

NewmacOS
public typealias Element = USDPreviewSession.OptimizationSteps

The element type of the option set.

To inherit all the default implementations from the OptionSet protocol, the Element type must be Self, the default.

typealias

OptimizationSteps.RawValue

NewmacOS
public typealias RawValue = Int

The raw type that can be used to represent all values of the conforming type.

Every distinct value of the conforming type has a corresponding unique value of the RawValue type, but there may be values of the RawValue type that don't have a corresponding value of the conforming type.

typealias

USDPreviewSession.SpatialViewerOptions.ArrayLiteralElement

NewmacOS
public typealias ArrayLiteralElement = USDPreviewSession.SpatialViewerOptions

The type of the elements of an array literal.

typealias

USDPreviewSession.SpatialViewerOptions.Element

NewmacOS
public typealias Element = USDPreviewSession.SpatialViewerOptions

The element type of the option set.

To inherit all the default implementations from the OptionSet protocol, the Element type must be Self, the default.

typealias

USDPreviewSession.SpatialViewerOptions.RawValue

NewmacOS
public typealias RawValue = Int

The raw type that can be used to represent all values of the conforming type.

Every distinct value of the conforming type has a corresponding unique value of the RawValue type, but there may be values of the RawValue type that don't have a corresponding value of the conforming type.

No APIs match your filter.

← More in Spatial, 3D & RealityKit