Create .USDZ files from iOS itself in Swift.
Since WWDC19, it's now possible to write usdz files natively using SceneKit. (thanks @cpheinrich)
This repo shared an older technique prior to it's the current recommended method:
import SceneKit
import ModelIO
let asset = MDLAsset(url: objPath)
let scene = SCNScene(mdlAsset: asset)
scene.write(to: <your-usdz-file-path>, delegate: nil)
With the introduction of the USDZ format and iOS 12, Apple provided guidance only for creating .usdz
files using their macOS commandline tool:
xcrun usdz_converter Tyrannosaurus.obj Tyrannosaurus.usdz
-g TyrannosaurusMesh
-color_map Tyrannosaurus_Color.png
-metallic_map Tyrannosaurus_Metallic.png
-roughness_map Tyrannosaurus_Roughness.png
-normal_map . Tyrannosaurus_Normal.png
-emissive_map Tyrannosaurus_Emissive.png
Copy the MDLAsset+usdz.swift
file into your Xcode project and create .USDZ in the following way:
let objAsset = MDLAsset(url: objUrl)
let destinationFileUrl = URL(fileURLWithPath: "path/Scene.usdz")
objAsset.exportToUSDZ(destinationFileUrl: destinationFileUrl)
- USDZ Specification
- Pixar’s USD project
- scandy blog
- BlenderUSDZ
- USDPython, Python based tools for generating, validating, and creating USD files.
obj2usdz
is available under the MIT license, see the LICENSE file for more information.