1

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.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
D.Park
  • 53
  • 5

1 Answers1

0

It's not a bug, it's an ordinary .usdz/.reality formats' scene hierarchy – some of scene's entities are groups, some of entities are models. So, all you have to do is just to rename this entity. Also note that if you need to get the model then you need to use type casting.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220