Add SCNText to SCNScene using ARKit

I just started studying at ARKitexample and Scenekit. I read several Scenekit and found out that to add text I need to use SCNText.

I am trying to write like this, but this is not displayed.

    guard let pointOfView = sceneView.pointOfView else { return }

    let text = SCNText(string: "Hello", extrusionDepth: 4)
    let textNode = SCNNode(geometry: text)
    textNode.geometry = text
    textNode.position = SCNVector3Make(pointOfView.position.x, pointOfView.position.y, pointOfView.position.z)
    sceneView.scene.rootNode.addChildNode(textNode)

I just want to add text (for example, "hello world") to SCNScene when the user clicks a button.

Edit

I saw this text, but since I did not adjust the plane (or snapping), I cannot look at it as if I were in front of this text. How can i do

+5
source share
1 answer

You have at least two problems.


node , , , node. , . -z . , , ( , YMMV):

textNode.simdPosition = pointOfView.simdPosition + pointOfView.simdWorldFront * 0.5

(, - ​​ ). , simdWorldFront - (0,0, -1), node , .


SCNText - - 16. , - ARKit. , " " . , , , .

scale pivot node, .

+8

All Articles