用手势翻译后如何获得实体位置?

发布于 2025-02-13 17:26:11 字数 820 浏览 0 评论 0原文

在这样的翻译之后,我正在尝试获得实体的变换矩阵:

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

我将3D模型移动到场景中,然后再次调用此方法,并且矩阵仍然相同。因此,我无法获得3D模型的最新变换矩阵。

这是我创建一个实体的方式:

var anchorEntity = AnchorEntity()

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

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

实体的最新位置(X,Y,Z)

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

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

我可以通过EntityTranslationTranslationTranslation fasturerEcognizer获得 我的3D型号的位置?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文