I am at a loss. I have looked at examples, and I have used chat/cursor. I cannot figure out how to target the transform/position of a Reality Composer Pro project when adding it to an ARView in iOS.
I have a test red sphere working perfectly for raycast positioning. When I pass the same variables (tested with print out) to the Entity or Anchor position/transform nothing changes.
It seems that, no matter what, the content of the Reality Composer Pro project is placed where the camera view initialized.
How do I actually interact with its position? I just want to be able to tap the screen and place the RCP wherever I want.
I am no longer at a loss! haha
Entity() is different than ModelEntity()
Entity() keeps the hierarchy (independent model transforms).
ModelEntity() flattens it (single model transforms).
You have to make sure you're interacting with your root element in the RCP scene. If you're not, the anchor or model transforms will have no effect.
//import your bundle
import yourproject
//Load async
let scene = try await Entity(named: "Scene", in: yourprojectBundle)
//Target root object
let rootEntity = scene.children.first?.children.first(where: { $0.name == "rootObject" }
Bonus: you can print out your hierarchy with this...
// Helper function to print entity hierarchy
func printEntityHierarchy(_ entity: Entity, level: Int) {
let indent = String(repeating: " ", count: level)
print("\(indent)Entity: \(entity.name) Transform: \(entity.transform)")
for child in entity.children {
printEntityHierarchy(child, level: level + 1)
}
}
Note: the same thing applies for gesture control. You have to make sure you're targeting the root object or the specific object you want.