如何快速在 visionOS 中给物体增加一个让用户抓取的功能?
Asked on 06/13/2025
1 search
要在 visionOS 中快速为物体增加用户抓取功能,可以使用新的 Object Manipulation API。这个 API 允许用户在应用中拾取虚拟物体。它支持通过 SwiftUI 和 RealityKit 实现物体的操控。
在 SwiftUI 中,你可以通过添加 manipulable
修饰符来启用物体操控功能。这个修饰符可以让用户用单手移动物体,用一只或两只手旋转物体,并通过双手捏合和拖动来缩放物体。
在 RealityKit 中,你可以使用新的操控组件(manipulation component)来实现这一功能。通过为实体设置操控组件,你可以启用物体操控功能,并且系统会自动处理与手势的交互。
你可以在 Better together: SwiftUI and RealityKit (11:52) 这个 session 中找到更多关于 Object Manipulation API 的信息。

Introducing enterprise APIs for visionOS
Find out how you can use new enterprise APIs for visionOS to create spatial experiences that enhance employee and customer productivity on Apple Vision Pro.

Better together: SwiftUI and RealityKit
Discover how to seamlessly blend SwiftUI and RealityKit in visionOS 26. We’ll explore enhancements to Model3D, including animation and ConfigurationCatalog support, and demonstrate smooth transitions to RealityView. You’ll learn how to leverage SwiftUI animations to drive RealityKit component changes, implement interactive manipulation, use new SwiftUI components for richer interactions, and observe RealityKit changes from your SwiftUI code. We’ll also cover how to use unified coordinate conversion for cross-framework coordinate transformations.

Explore object tracking for visionOS
Find out how you can use object tracking to turn real-world objects into virtual anchors in your visionOS app. Learn how you can build spatial experiences with object tracking from start to finish. Find out how to create a reference object using machine learning in Create ML and attach content relative to your target object in Reality Composer Pro, RealityKit or ARKit APIs.