ARViewのSceneに追加するにはanchorが必要になるので適当なアンカーを付け足す。
public class USDZ: Entity, HasAnchoring {
public var anchoring: AnchoringComponent {
get {
return anchorEntity.anchoring
}
set {
anchorEntity.anchoring = newValue
}
}
private var anchorEntity = AnchorEntity(world: .zero)
}
extension USDZ {
public static func load(contentsOf url: URL) throws -> USDZ {
let root = try Entity.load(contentsOf: url)
let usdz = USDZ()
root.setParent(usdz, preservingWorldTransform: true)
return usdz
}
}