I want to do the followings automatically:
(1)
asynchronously load a 3D model, for example a vase 50 cm tall(2)
detect the point P on the floor that is vertically down from the world origin (initial location of the device) and set P as the new world origin(3)
place the 3D model from (1) at P acquired in (2).
So, in effect, I'd see a vase standing at where I was if I were to step aside.
The fact that I need to wait on both (1) and (2) before I can perform (3), and that I want to perform all of them automatically got me really lost.
How should I approach this problem?
I tried to generate an AnchorEntity with the following:
let floorAnchorEntity = AnchorEntity(plane: [.horizontal],
classification: [.floor],
minimumBounds: [0.5, 0.5])
floorAnchorEntity.name = "floor anchor entity"
arView.scene.addAnchor(floorAnchorEntity)
And load a model 'synchronously' and tether to the anchor entity:
do {
let modelEntity = try Entity.load(named: modelName)
floorAnchorEntity.addChild(modelEntity)
} catch {
assertionFailure("could not load assets.")
}
I was expecting to see the model on the floor but I do not see any thing on the screen. Additionally, 'isActive' flag of the anchor entity is 'false'.