问题
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)
回答1:
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.
回答2:
I think there's a bug in how ARKit is transforming SCNText nodes. See these for reference:
- https://forums.developer.apple.com/message/235611#235611
- https://forums.developer.apple.com/thread/79715
回答3:
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)
来源:https://stackoverflow.com/questions/44510878/scntext-not-displaying