I have used the following code to
(1)
create an AnchorEntity and add to the ARView scene.(2)
asynchronously load a model and tethered it to the AnchorEntity from (1).
The 3D model is from here.
var cancellable: AnyCancellable?
let floorAnchorEntity = AnchorEntity(plane: [.horizontal],
classification: [.floor],
minimumBounds: [0.5, 0.5])
floorAnchorEntity.name = "floor anchor entity"
arView.scene.addAnchor(floorAnchorEntity)
cancellable = Entity.loadAsync(named: modelName)
.sink(receiveCompletion: { loadCompletion in
switch loadCompletion {
case .finished:
print("model loading finished successfully")
case let .failure(error):
print("model loading failed due to \(error)")
}
cancellable?.cancel()
}, receiveValue: { entity in
floorAnchorEntity.addChild(entity)
})
In the debugger, if I print out the entity hierarchy, I see a redundant entity named '/', which is not expected.
▿ 'floor anchor entity' : AnchorEntity, children: 1
⟐ SynchronizationComponent
⟐ AnchoringComponent
⟐ Transform
▿ '/' : Entity, children: 1
⟐ SynchronizationComponent
⟐ Transform
▿ 'flower_tulip' : Entity, children: 5
⟐ SynchronizationComponent
⟐ Transform
▿ 'TulipStalk' : ModelEntity
⟐ ModelComponent
⟐ SynchronizationComponent
⟐ Transform
▿ 'TulipPetals' : ModelEntity
⟐ ModelComponent
⟐ SynchronizationComponent
⟐ Transform
I was assuming that I'd have 'flower_tulip' directly under 'floor anchor entity'.
Am I missing something here or is this simply a bug?
P.S. a related question is here.