SCNText Not Displaying

对着背影说爱祢 提交于 2019-12-08 04:03:41

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!