so this is my first project app that i was wanting to build just for learning purposes: I was wondering when i start new project and pick ios->augmented reality app. I get some auto generated code that lets me load an experience from the "Experience.rcproject" file. My question: How can i create a button that would load random object from reality composer? I would appreciate any help, Ive looked online reddit and youtube and some apple docs but was not able to find something that was helpful yet but im still searching. Thank you
NOOB needs help Augmented Reality
One thing you might want to do is print a summary of the contents of a model you just loaded. You can explore the Entity API to see more fields you can print. I like to look at scaling, translation, and rotation values for each entity.
For example, from the sample code, add a function after loading the Experience.loadBox()
let boxAnchor = try! Experience.loadBox()
displayEntityTree(entity: boxAnchor)
and then define the function to traverse the tree:
func displayEntityTree(entity: Entity, prefix: String = "")
{
print("\(prefix)type: \(type(of: entity)) name: \(entity.name)")
for child in entity.children {
displayEntityTree(entity: child, prefix: "\(prefix)*")
}
}
Somewhere in your console output you will probably see something like
type: Box name:
*type: AnchorEntity name:
**type: Entity name:
***type: Entity name: Steel Box
****type: ModelEntity name: simpBld_root
**type: Entity name: Ground Plane
Later, you could add code to, say, clone the entity names "Steel Box". You might want to look for sample code for raycasting to find a place to put the object.
Here is some good documentation to start browsing:
https://developer.apple.com/documentation/realitykit/entity
https://developer.apple.com/documentation/realitykit
If you are really new, I suggest you start with some tutorials on using Xcode, putting buttons on screen, and responding to actions (e.g., someone touching the button). Later you can move into AR. I wouldn't jump into AR cold.
Thank you for the response Todd2, yes I am concurrently working on xcode course to help me understand the basics like you mentioned. I will read and try some of the code you provided above, I appreciate your response.