How to get Entity position after translation with Gestures?

Viewed 52

I am trying to get the transform matrix of an Entity after a translation like this:

uiView.scene.findEntity(named: "Model_Name")?.transform.matrix

I move the 3D model around the scene and i call this method again and the matrix is still the same. So i can't get the latest transform matrix of my 3D model.

This is the way I create an Entity:

var anchorEntity = AnchorEntity()

anchorEntity = AnchorEntity(.plane(.any,
                            classification: .any,
                            minimumBounds: [0.1, 0.1]))

anchorEntity.addChild(MyEntity, preservingWorldTransform: true)
             
uiView.scene.addAnchor(anchorEntity)

I can get the latest position (X,Y,Z) of the Entity via EntityTranslationGestureRecognizer

guard let translateGesture = recognizer as? EntityTranslationGestureRecognizer 
else { return }

let position = translateGesture.location(in: translateGesture.entity)

Is there any way to get the latest transform matrix of an Entity because I want to create an ArAnchor in the latest position of my 3D model?

0 Answers
Related