v26.5.2 | OpenUSDKit & HydraKit
SwiftUSD v26.5.2
OpenUSDKit & HydraKit
Changelog
Changes
- Introducing
OpenUSDKit, a unified cross-platform Swift API for OpenUSD. It is a direct replacement for thePixarUSDtarget. - Introducing
HydraKit, a composable Hydra viewport with SwiftCrossUI:import Foundation import OpenUSDKit import HydraKit import SwiftCrossUI @main struct MyApp: App { typealias Backend = PlatformBackend let stage: UsdStage let engine: Hydra.RenderEngine init() { Pixar.Bundler.shared.setup(.resources) stage = UsdStage.createInMemory() engine = Hydra.RenderEngine(stage: stage) } var body: some Scene { WindowGroup("MyApp") { Hydra.Viewport(engine: engine) } } }
import SwiftCrossUI // Platform backend selection is explicit for now, this will eventually just end up // in HydraKit to handle this by default, but figured it was worth showing what is // going on under the hood, if developers wish to make extensible backends for // their own apps. #if os(Android) import AndroidBackend public typealias PlatformBackend = AndroidBackend #elseif os(Linux) import GtkBackend public typealias PlatformBackend = GtkBackend #elseif os(Windows) import WinUIBackend public typealias PlatformBackend = WinUIBackend #elseif os(macOS) import AppKitBackend public typealias PlatformBackend = AppKitBackend #else import UIKitBackend public typealias PlatformBackend = UIKitBackend #endif
- Integrates apple/SwiftUsd within
OpenUSDKitand brings precompiled binaries for Darwin platforms by default, use the environment variableSWIFTUSD_BUILD_FROM_SOURCE=1if you prefer to build from source and match the behavior on all other platforms (Android, Linux, and Microsoft Windows). - Adds the availability of zero-copy VtArray reads, and single-copy VtArray writes from a contiguous buffer in Swift.
- Adds the availability of some OpenExec types to Swift:
import OpenUSDKit let stage = UsdStage.createInMemory() let system = ExecUsdSystem.create(stage: stage) UsdGeom.Xform.define(stage, path: "/hello") let prim = UsdGeom.Sphere.define(stage, path: "/hello/world") let key = Pixar.ExecUsdValueKey(prim, .init("computeLocalToWorldTransform")) let request = system.BuildRequest(consuming: [key]) let view = system.Compute(request) var val = view.Get(0) if val.IsHolding(T: pxr.GfMatrix4d.self) { let matrix: pxr.GfMatrix4d = val.UncheckedGet() }
- Adds the latest changes from upstream PixarAnimationStudios/OpenUSD's
devbranch, up to commit3e38900(the latest revision at the time of writing).
🎧 now playing
listen to la baleine et le musicien by rone.
Thank you
- @meshula
- @dgovil
- @brechtvl
- @stackotter
- @gracien-app
- @scott-wilson
- @obvgab
- @felfoldy
- Pixar's OpenUSD contributors
Usage
To use this release of USD in your swift project, add the following to the dependencies section in your Package.swift file:
// swift-tools-version: 6.1
dependencies: [
.package(url: "https://github.com/wabiverse/swift-usd.git", from: "26.5.2")
]Linux
For Linux, these are the only dependencies required, as MetaverseKit provides everything else.
Tip
If you are on a distro like Ubuntu there is a good chance you already have most of these installed.
| Dependency | CentOS | Ubuntu |
|---|---|---|
| BZ2 | bzip2-devel | libbz2-dev |
| ZLib | zlib-devel | zlib1g-dev |
| FreeGLUT | freeglut-devel | freeglut3-dev |
| DEFLATE | libdeflate-devel | libdeflate-dev |
| Expat | libexpat-devel | libexpat1-dev |
| Xcursor | libXcursor-devel | libxcursor-dev |
| Xt | libXt-devel | libxt-dev |
| Xi | libXi-devel | libxi-dev |
| Xinerama | libXinerama-devel | libxinerama-dev |
| Xrandr | libXrandr-devel | libxrandr-dev |
