重置 ARKit 坐标 [英] Resetting ARKit coordinates

查看:24
本文介绍了重置 ARKit 坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的问题.如果我想开始游戏并将棋盘放在我面前:

I have a simple question. If I wanted to start a game and place the board right in front of me:

gameBoard!.position = SCNVector3(0, 0, -0.6)

这一直有效,直到我离开游戏并再次回来.我可以在镜头前或 0.6m 前面完全相同的位置显示游戏板吗?我可能已经搬到了另一个位置.

This works until I leave the game and come back again. Can I show the game board in exact same position in front of camera or 0.6m in front of me? I might have physically moved to another position.

推荐答案

如果您想重置 ARSession,您必须暂停、删除所有节点并通过重置跟踪和删除锚点重新运行会话.

If you want to reset you ARSession, you have to pause, remove all nodes and rerun your session by resetting tracking and removing anchors.

我制作了一个重置​​按钮,只要我想重置就可以:

I made a reset button that does it whenever i want to reset:

@IBAction func reset(_ sender: Any) {

    sceneView.session.pause()
    sceneView.scene.rootNode.enumerateChildNodes { (node, stop) in
        node.removeFromParentNode()
    }
    sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}

或者把它放在你的会话被中断的函数中!

Or put it in your session was interrupted function!

这篇关于重置 ARKit 坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆