How to put text over node in scenekit?

萝らか妹 提交于 2019-12-07 07:03:05

问题


Really simple question which for some reason I cannot find anywhere. How can I write 2D text on a 3D face of a SCNNode? For example, on something like this:

let geo = SCNBox(width: 20, height: 20, length: 20, chamferRadius: 0.0);
//geo.writeFace(postion, text)
let box = SCNNode(geometry: geo);

Of course the comment is made up. Anything like it?


回答1:


You'll need to create a texture of the desired font and text, then apply that as a part of the material on the object. Though I've not seen anything like UVW mapping in Scene Kit to let you control the placement. It must be there. If you're only working with SCN geometry you might be OK, because SCNBox at least permits per side specification for material/texture.

You can dynamically create 2D type textures with either UIKit text drawing to a context, or rasterisation of Sprite Kit text with use of textureToNode: https://developer.apple.com/reference/spritekit/skview/1520114-texturefromnode?language=objc



来源:https://stackoverflow.com/questions/39643602/how-to-put-text-over-node-in-scenekit

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