Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Create Spatial Photo with ImagePresentationComp...

Avatar for tatsubee tatsubee
September 24, 2025
49

Create Spatial Photo with ImagePresentationComponent

https://visionos-engineer.connpass.com/event/368679/ で発表した`ImagePresentationComponent`に関する資料です

サンプルコード: https://github.com/Shoryu-Y/ImagePresentationComponentExample
資料中の動画(そのうち消します): https://drive.google.com/file/d/14dLwAA3rkDw-TMsETTQWZOSvC9OKDWex/view?usp=drive_link

Avatar for tatsubee

tatsubee

September 24, 2025
Tweet

More Decks by tatsubee

Transcript

  1. 自己紹介 • 23新卒 • 福岡生まれ 福岡育ち 東京在住 • 最近やっていること ◦

    お絵描き ◦ テニス ◦ iOS 辰べえ iOSエンジニア 辰べえ iOSエンジニア 2
  2. 空間写真 アプリ内で画像を表示する方法 • 今まで ◦ Image (SwiftUI) ◦ Entity +

    Texture (RealityKit) ◦ etc.. • visionOS 26+ ◦ Entity + ImagePresentationComponent (RealityKit) 4
  3. ImagePresentationComponent 画像を表示するRealityKitのComponent 表示できる画像 • 従来の 2D 画像 • iPhone 15

    Pro 以降および Apple Vision Pro で撮影された、空間メタデータ が追加された立体写真 • 6
  4. ImagePresentationComponent 画像を表示するRealityKitのComponent 表示できる画像 • 従来の 2D 画像 • iPhone 15

    Pro 以降および Apple Vision Pro で撮影された、空間メタデータ が追加された立体写真 • 既存の 2D 画像または写真から生成された 3D 画像 7
  5. ImagePresentationComponent 画像を表示するRealityKitのComponent 表示できる画像 • 従来の 2D 画像 • iPhone 15

    Pro 以降および Apple Vision Pro で撮影された、空間メタデータ が追加された立体写真 • 既存の 2D 画像または写真から生成された 3D 画像 8 ↑これを今回メインで話します
  6. 9

  7. 10

  8. ImagePresentationComponent visionOS 2までは • 開発者のアプリで空間写真を表示することはできなかった(たぶん) • 写真アプリで ◦ 空間写真を表示できる ◦

    2D画像を空間写真に変換できる visionOS 26では • 開発者のアプリの中で空間写真の表示・空間写真への変換ができる! 11
  9. 空間写真表示を実装 13 RealityView { content in // ... } update:

    { content in content.add( Entity(components: [imagePresentationComponent]) ) } 使い方は他のRealityViewと一緒!
  10. 空間写真表示を実装 15 ImagePresentationComponentには3つのイニシャライザがある • ImagePresentationComponent(contentsOf: URL) • ImagePresentationComponent(imageSource: CGImageSource) •

    ImagePresentationComponent( spatial3DImage: ImagePresentationComponent.Spatial3DImage ) 従来の2D画像を3Dにしたい場合には ImagePresentationComponent(spatial3DImage:)
  11. 空間写真表示を実装 16 func makeImagePresentationComponent() async throws-> ImagePresentationComponent { // 画像ファイルが存在するローカルの

    URLを指定 let imageFileURL: URL = // ... let spatial3DImage = try await ImagePresentationComponent.Spatial3DImage(contentsOf: imageFileURL) try await spatial3DImage.generate() return ImagePresentationComponent(spatial3DImage: spatial3DImage) }
  12. 空間写真表示を実装 17 func makeImagePresentationComponent() async throws-> ImagePresentationComponent { let imageFileURL:

    URL = // … // URLを指定して、ImagePresentationComponentに表示する画像のオブジェクトを作成 let spatial3DImage = try await ImagePresentationComponent.Spatial3DImage(contentsOf: imageFileURL) try await spatial3DImage.generate() return ImagePresentationComponent(spatial3DImage: spatial3DImage) }
  13. 空間写真表示を実装 18 func makeImagePresentationComponent() async throws-> ImagePresentationComponent { let imageFileURL:

    URL = // … let spatial3DImage = try await ImagePresentationComponent.Spatial3DImage(contentsOf: imageFileURL) // 2Dから3Dへと変換! try await spatial3DImage.generate() return ImagePresentationComponent(spatial3DImage: spatial3DImage) }
  14. 空間写真表示を実装 19 func makeImagePresentationComponent() async throws-> ImagePresentationComponent { let imageFileURL:

    URL = // … let spatial3DImage = try await ImagePresentationComponent.Spatial3DImage(contentsOf: imageFileURL) try await spatial3DImage.generate() var component = ImagePresentationComponent(spatial3DImage: spatial3DImage) // 表示したいモードを設定(デフォルト値は.mono) component.desiredViewingMode = .spatial3D return component }
  15. 空間写真表示を実装 20 RealityView { content in // ... } update:

    { content in content.add( Entity(components: [imagePresentationComponent]) ) }
  16. 21