swift - 如何在 ARKit 中使用垂直检测?

标签 swift augmented-reality arkit

如何在 ARKit 上插入一个垂直保持的 SCNScene?我无法进行拘留并将物体垂直插入。

override func viewDidLoad() {
    super.viewDidLoad()

    // Set the view's delegate
    sceneView?.delegate = self

    // Show statistics such as fps and timing information
    sceneView?.showsStatistics = true

    // Create a new scene
    let scene = SCNScene(named: "art.scnassets/tabellone.scn")

    sceneView?.debugOptions = [SCNDebugOptions.showFeaturePoints]

    // Set the scene to the view
    sceneView?.scene = scene!
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    // Create a session configuration
    let configuration = ARWorldTrackingConfiguration()

    configuration.planeDetection = .vertical
    configuration.isLightEstimationEnabled = true

    // Run the view's session
    sceneView?.session.run(configuration)
}

最佳答案

您需要一个合适的垂直表面来进行追踪。纯色墙(上面没有可区分的特征)是非常糟糕的例子(您可以在左图中看到这样的垂直表面)。跟踪垂直表面最稳健的方法是光线充足砖墙,或带有图片的墙,或带有可区分图案的墙等。

enter image description here

所以右图是跟踪和垂直平面检测的很好的例子。

如果您想探索如何将 3D 对象放置到检测到的平面上,请查看 Apple 的 Handling 3D Interaction and UI Controls in AR项目。

希望这对您有所帮助。

关于swift - 如何在 ARKit 中使用垂直检测?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53524822/

相关文章:

javascript - -[UIAlertController addTextFieldWithConfigurationHandler :] 中的断言失败

ios - 客户端凭据 AFNetworking

Android 增强现实方向

ios - 如何缩放 SCNNodes 以适应边界框

ios - 如果两个 View 相同,为什么 TabView 显示空白屏幕?

ios - “CompletionHandler”在此上下文中对于类型查找不明确

android - cvc-complex-type.2.4.a : Invalid content was found starting with element 'base-extension' . 预期为 '{layoutlib}' 之一

ios - 未经许可将 SCNNode 旋转到北以进行位置跟踪

swift - 使用 RealityKit 对对象施加向下的力

ios - 如何在 iOS swift 的 ARSCNView 中显示 uicollection View