ARKit: placing SCNText at a specific point in front of the camera

I managed to get a cube (SCNNode) located on the surface on which the camera is pointed, however it is very difficult for me to perform a simple (?) Task of placing text in the same position.

I created SCNText and the subsequent SCNNode, however, when I add it to rootNode, the text is always added above my head and from the camera to the right (which tells me that this is the global point of origin).

Even when I use the same position value that I used for the cube, the SCNText node is still placed above my head in the same place.

Sorry if this is the main question, I have never worked in SceneKit before.

+6
source share
1

SCNGeometry . SCNText, - :

Center point for the window

Center point for text

. , node, , , :

func center(node: SCNNode) {
    let (min, max) = node.boundingBox

    let dx = min.x + 0.5 * (max.x - min.x)
    let dy = min.y + 0.5 * (max.y - min.y)
    let dz = min.z + 0.5 * (max.z - min.z)
    node.pivot = SCNMatrix4MakeTranslation(dx, dy, dz)
}

Edit:

, : 16 pts 16 SceneKit. ARKit 1 SceneKit = 1 !

+12

All Articles