Skip to content

Instantly share code, notes, and snippets.

@eospi
Last active August 12, 2019 20:16
Show Gist options
  • Save eospi/55082a7a9f3a458501b3dbc8d83e1316 to your computer and use it in GitHub Desktop.
Save eospi/55082a7a9f3a458501b3dbc8d83e1316 to your computer and use it in GitHub Desktop.
RealityKit Synchronous Loading
func loadEntitySync() {
// Create an world anchor at the origin and add it to the scene
let anchor = AnchorEntity(world: [0,0,0])
arView.scene.addAnchor(anchor)
// Handle errors in case the file doesn't exist
do {
let usdzPath = "path/to/usdz/asset"
let modelEntity = try ModelEntity.loadModel(named: usdzPath)
anchor.addChild(modelEntity)
} catch {
print("file not found")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment