如何在scenekit中将文本放在节点上? [英] How to put text over node in scenekit?

查看:108
本文介绍了如何在scenekit中将文本放在节点上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

真正简单的问题,由于某种原因我找不到任何地方。如何在 SCNNode 的3D面上书写2D文本?
例如,在这样的事情上:

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?

推荐答案

您需要创建所需字体和文本的纹理,然后将其作为一部分应用物体上的物质。虽然我没有在Scene Kit中看到像UVW映射这样的东西来控制位置。一定是在那里。如果你只使用SCN几何,你可能没问题,因为SCNBox至少允许材料/纹理的每一面规格。

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.

你可以动态创建2D类型纹理UIKit文本绘制到上下文,或者使用textureToNode对Sprite Kit文本进行光栅化:
https://developer.apple.com/reference/spritekit/skview/1520114-texturefromnode?language=objc

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

这篇关于如何在scenekit中将文本放在节点上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆