ImagePresentationComponent
A component that supports general image presentation.
Declaration
struct ImagePresentationComponentOverview
ImagePresentationComponent supports the presentation of three different kinds of images in RealityKit:
A traditional 2D image.
A spatial photo, which is a stereoscopic photo with additional spatial metadata, as captured on iPhone 15 Pro or later and Apple Vision Pro.
A spatial scene, which is a 3D image generated from an existing 2D image or photo.
To present a 2D image or a spatial photo, create a new ImagePresentationComponent from a local file URL for the existing image, or from an existing CGImageSource.
To generate and present a spatial scene from an existing image, create a ImagePresentationComponent.Spatial3DImage from the image; call the generate() method on your new spatial 3D image; then create a new ImagePresentationComponent with init(spatial3DImage:).
Viewing modes
By default, an ImagePresentationComponent presents its image in a mono viewing mode, regardless of what kind of image you create it with.
To request a different viewing mode, set the component’s desiredViewingMode property, and add the component to an entity with the updated value.
To discover which viewing modes a component’s image supports, query the component’s availableViewingModes property. The availableViewingModes set always contains mono as an option.
When you create this component with a valid spatial photo, the set of available viewing modes also contains spatialStereo and spatialStereoImmersive.
If you created the component with a ImagePresentationComponent.Spatial3DImage, and have called the generate() method to generate it, the set of available viewing modes will also contain spatial3D and spatial3DImmersive.
Topics
Creating a component from a 2D image or spatial photo
Creating a component from a spatial scene
Setting and discovering viewing modes
ImagePresentationComponent.ViewingModeviewingModedesiredViewingModeavailableViewingModessupportedViewingModes(for:)supportedViewingModes(for:)