john doe
john doe

Reputation: 9660

SCNText Not Displaying

I have the following code in my SceneKit application but for some reason the text never shows up on the screen.

 let text = SCNText(string: item.label, extrusionDepth: 4.0)
            text.firstMaterial?.diffuse.contents = UIColor.white
            text.font = UIFont(name: "Arial", size: 35)

            let textNode = SCNNode(geometry: text)
            textNode.position = SCNVector3(-0.2 + x, -0.9 + delta, -1)

            self.node.addChildNode(textNode)

Upvotes: 2

Views: 2206

Answers (3)

KilroyWasHere
KilroyWasHere

Reputation: 61

Instead of using .font, try using .scale. Even a 1 for font is still a meter tall, so scaling it down might be needed. This worked for me: textNode.scale = SCNVector3(0.01,0.01,0.01)

Upvotes: 3

nitindhar7
nitindhar7

Reputation: 113

I think there's a bug in how ARKit is transforming SCNText nodes. See these for reference:

Upvotes: 1

Hal Mueller
Hal Mueller

Reputation: 7646

With a size of 35, that text will be huge. It's not 35 points tall, but 35 SceneKit units tall. It's quite possible that the text is visible, but your camera is peering through a hole in a letter, or the Z limit on your camera is stopping it from rendering.

Upvotes: 2

Related Questions