-
Take SwiftUI to the next dimension
Get ready to add depth and dimension to your visionOS apps. Find out how to bring three-dimensional objects to your app using volumes, get to know the Model 3D API, and learn how to position and animate content. We'll also show you how to use UI attachments in RealityView and support gestures in your content.
Chapitres
- 0:00 - Introduction
- 1:49 - Volumes
- 2:57 - 3D views and layout
- 7:46 - RealityView
- 10:55 - 3D gestures
Ressources
Vidéos connexes
WWDC23
-
Rechercher dans cette vidéo…
-
-
3:35 - MoonView
struct MoonView { var body: some View { Model3D(named: "Moon") { phase in switch phase { case .empty: ProgressView() case let .failure(error): Text(error.localizedDescription) case let .success(model): model .resizable() .scaledToFit() } } } } -
17:26 - Manipulation Gesture
// Gesture combining dragging, magnification, and 3D rotation all at once. var manipulationGesture: some Gesture<AffineTransform3D> { DragGesture() .simultaneously(with: MagnifyGesture()) .simultaneously(with: RotateGesture3D()) .map { gesture in let (translation, scale, rotation) = gesture.components() return AffineTransform3D( scale: scale, rotation: rotation, translation: translation ) } } // Helper for extracting translation, magnification, and rotation. extension SimultaneousGesture< SimultaneousGesture<DragGesture, MagnifyGesture>, RotateGesture3D>.Value { func components() -> (Vector3D, Size3D, Rotation3D) { let translation = self.first?.first?.translation3D ?? .zero let magnification = self.first?.second?.magnification ?? 1 let size = Size3D(width: magnification, height: magnification, depth: magnification) let rotation = self.second?.rotation ?? .identity return (translation, size, rotation) } }
-