1

How can I insert a SCNScene with a vertical hold on ARKit? I can not do the detention and insert the object in a vertical position.

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)
}
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220

1 Answers1

0

You need an appropriate vertical surface for tracking. Wall with a solid color (with no distinguishable features on it) is very bad instance (you can see such a vertical surface on the left image). The most robust approach for tracking of a vertical surface is a well-lit brick wall, or a wall with pictures on it, or a wall with a distinguishable pattern, etc.

enter image description here

So the right image is quite good example for tracking and vertical plane detection.

If you want to explore how to place 3D object onto detected plane, look at Apple's Handling 3D Interaction and UI Controls in AR project.

Hope this helps.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220