SceneKit: improve performance of SceneView's hitTest function?
<p>Our scene only has about 20 nodes. The code below lets the user pan, conducting a hit test on each pan -- the goal is to highlight blocks as the user pans around the screen.</p>

<p>However, it is noticeably sluggish on a iPhone 5S. It's not deterministic but happens often enough to be irritating (every 5-10 pans).</p>

<p>We considered using <code>hitTestWithSegment</code> since you could tightly bound the range for testing but believe that should be slower because you must first compute the two points required for the function.</p>

<p>Moreover, the <code>SCNHitTestClipToZRangeKey</code> option for <code>hitTest</code> should provide a comparable performance boost by tightening the hit range without requiring the computation of two additional points.</p>

<p>Any suggestions for speeding up the performance of <code>hitTest</code>?</p>

<pre><code>func sceneViewPannedOneFinger(sender: UIPanGestureRecognizer) {
    // Get pan distance &amp; convert to radians
    let translation = sender.translationInView(sender.view!)
    var xRadians = GLKMathDegreesToRadians(Float(translation.x))
    var yRadians = GLKMathDegreesToRadians(Float(translation.y))

    // Get x &amp; y radians
    xRadians = (xRadians / 4) + curXRadians
    yRadians = (yRadians / 4) + curYRadians

    // Limit yRadians to prevent rotating 360 degrees vertically
    yRadians = max(Float(-M_PI_2), min(Float(M_PI_2), yRadians))

    // Set rotation values to avoid Gimbal Lock
    cameraNode.rotation = SCNVector4(x: 1, y: 0, z: 0, w: yRadians)
    userNode.rotation = SCNVector4(x: 0, y: 1, z: 0, w: xRadians)

    // Save value for next rotation
    if sender.state == UIGestureRecognizerState.Ended {
        curXRadians = xRadians
        curYRadians = yRadians
    }

    // Set preview block
    setPreviewBlock(sender)
}


private func setPreviewBlock(recognizer: UIGestureRecognizer) {        
    let point = recognizer.locationInView(sceneView)
    let options = [SCNHitTestRootNodeKey: sceneView.scene!.rootNode, SCNHitTestClipToZRangeKey: 15, SCNHitTestSortResultsKey: true]
    let hits = sceneView.hitTest(point, options: options)
    print(hits.first?.worldCoordinates)
}
</code></pre>