LoginSignup
2
1

More than 3 years have passed since last update.

RealityKitでusdzを読み込む

Posted at

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
  }
}
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1