I created a RealityKit project which loads objects (usdz files). Using the LiDAR is really great for occlusion and be able to see the real world mesh. I would like to use something found in the Apple's documentation : Perspective Camera. If I well understood this could be compare as a third person camera.
I created a dedicated button in my arView which, when called, execute the code following :
let cameraEntity = PerspectiveCamera()
cameraEntity.camera.far = 10
cameraEntity.camera.fieldOfViewInDegrees = 60
cameraEntity.camera.near = 0.01
let cameraAnchor = AnchorEntity(world: .zero)
cameraAnchor.children.append(cameraEntity)
self.arView.scene.anchors.append(cameraAnchor)
When is code is called the the become black.... I do not understand how to place the camera to see the scanned mesh. If someone has an idea ? Thanks in advance!
It depends where the USDZ you're looking at is located. I think the default will mean the camera is located at the origin looking in the direction of [0, 0, -1].
You could change this using the Entity.look(at:from:upVector:relativeTo:)
method. Making sure that your from:
parameter is far enough from the centre of your USDZ object.