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

查看:22
本文介绍了如何在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.

您可以使用 UIKit 文本绘制到上下文,或使用 textureToNode 对 Sprite Kit 文本进行光栅化来动态创建 2D 类型纹理: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天全站免登陆