代码之家  ›  专栏  ›  技术社区  ›  Will

使用ARKit获取到曲面的距离

  •  8
  • Will  · 技术社区  · 9 年前

    .scn 包含平面对象的文件。我知道如何将其放置在相机所在的位置,但如何获得到最近表面的距离。

    Such as in this image, where it detects how far away the table is.

    抱歉,如果这听起来像是一个代码请求,但我不知道从哪里开始,任何指导将不胜感激

    1 回复  |  直到 9 年前
        1
  •  14
  •   Guig    9 年前

    您可以使用 hitTest https://developer.apple.com/documentation/arkit/arhittestresult

    for result in sceneView.hitTest(CGPoint(x: 0.5, y: 0.5), types: [.existingPlaneUsingExtent, .featurePoint]) {
      print(result.distance, result.worldTransform)
    }
    
    推荐文章