Spatial Scene API 应该如何使用?
Asked on 06/18/2025
1 search
To use the Spatial Scene API in RealityKit, you need to follow a series of steps to generate and present a spatial scene from a 2D image or a spatial photo. Here's a brief overview of the process:
-
Create a Spatial 3D Image: Start by creating a spatial 3D image from a URL. This is the first step before you can initialize the image presentation component.
-
Generate the Spatial Scene: Use the
Spatial 3D Images Generate
method to generate the spatial scene. This process takes a few seconds and is necessary before the image presentation component can present the scene. -
Set the Viewing Mode: After generating the spatial scene, update the image presentation component's available viewing modes to include Spatial 3D and Spatial 3D immersive modes. You can then set one of these modes as the desired viewing mode to opt into either a windowed or immersive presentation of the spatial scene.
-
Present the Scene: You can choose to generate the spatial scene in advance or wait until a user action, such as pressing a button, to generate and present the scene. This approach is similar to how the Photos app operates on VisionOS.
For more detailed information and code examples, you can refer to the session What’s new in RealityKit (16:35) from WWDC 2025.

What’s new in RealityKit
Unleash your creativity with new RealityKit features that can help you build rich 3D content for iOS, iPadOS, macOS, tvOS and visionOS. Learn how you can access ARKit data directly through RealityKit. Explore how you can interact with your 3D content more naturally using the object manipulation feature. Discover some new APIs for scene understanding, environment blending, instancing and much more, all using an interactive sample.

Build compelling spatial photo and video experiences
Learn how to adopt spatial photos and videos in your apps. Explore the different types of stereoscopic media and find out how to capture spatial videos in your iOS app on iPhone 15 Pro. Discover the various ways to detect and present spatial media, including the new QuickLook Preview Application API in visionOS. And take a deep dive into the metadata and stereo concepts that make a photo or video spatial.

Build immersive web experiences with WebXR
Discover how WebXR empowers you to add fully immersive experiences to your website in visionOS. Find out how to build WebXR experiences that take full advantage of the input capabilities of visionOS, and learn how you can use Simulator to test WebXR experiences on macOS.