Skip to content

SPM USDZ Lidar Scanner/Capture for iOS based on Apple Object Capture Sample Code

License

Notifications You must be signed in to change notification settings

alfianlosari/USDZScanner

Repository files navigation

USDZScanner

A SwiftUI USDZ Object Scanner for Capturing Real Life Objects and transforming to USDZ file using Photogrametry.

This is just a SPM wrapper based on the original Apple Object Capture Sample Code

Requirements

  • iPhone or iPad with a LiDAR Scanner and an A14 Bionic chip or later
  • iOS or iPadOS 17 or later

Installation

Swift Package Manager

You must add Privacy - Camera Usage Description permission in your App Info.plist to use the scanner.

Usage

Initialize USDZScanner passing the completion callback. The completion contains a parameter for the URL where it stored the USDZ file.

import SwiftUI
import USDZScanner

@main
struct SampleApp: App {

    @State var isScanObjectPresenting = false
    @State var url: URL?
    
    var body: some Scene {
        WindowGroup {
            VStack {
                
                Button("Scan Object") {
                    isScanObjectPresenting = true
                }
                
                if let url {
                    Text(url.absoluteString)
                }
                
            }
            .sheet(isPresented: $isScanObjectPresenting, content: {
                USDZScanner { url in
                    self.url = url
                    isScanObjectPresenting = false
                }
            })
        }
    }
}