更改SCNText节点对象(Swift - Scenekit)的颜色或纹理 [英] Change the color or texture of a SCNText node object (Swift - Scenekit)
问题描述
如何设置SCNText对象的纹理?这是我有,外观没有什么变化:
// myNode是一个工作的SCNText元素
let mat = SCNMaterial()
met.diffuse.contents = UIImage(contentsOfFile:texture.png)
myNode.geometry.firstMaterial = mat
解决方案
文本几何可以包含一个,三个或五个几何元素: / p>
如果它的extrusionDepth属性为0.0,则文本几何具有对应于其一个可见侧的一个元素。
如果其挤出深度大于零,并且其chamferRadius属性为0.0,则文本几何具有三个元素,对应于其正面,背面和拉伸边。
如果挤压深度和倒角半径都大于零,则文本几何体有五个元素,对应于其前,后,挤压侧,前倒角和后倒角。
Scene Kit可以使用不同的材质渲染每个元素。有关详细信息,请参阅SCNGeometry类参考中材料属性的描述。
就像任何其他几何图形一样,只需设置其
materials
属性。How do I set the texture of a SCNText object? This is what I have and nothing changes in the appearance:
// myNode is a working SCNText element let mat = SCNMaterial() met.diffuse.contents = UIImage(contentsOfFile: "texture.png") myNode.geometry.firstMaterial = mat
解决方案A text geometry may contain one, three, or five geometry elements:
If its extrusionDepth property is 0.0, the text geometry has one element corresponding to its one visible side. If its extrusion depth is greater than zero and its chamferRadius property is 0.0, the text geometry has three elements, corresponding to its front, back, and extruded sides. If both extrusion depth and chamfer radius are greater than zero, the text geometry has five elements, corresponding to its front, back, extruded sides, front chamfer, and back chamfer. Scene Kit can render each element using a different material. For details, see the description of the materials property in SCNGeometry Class Reference.
just like for any other geometry, simply set its
materials
property.这篇关于更改SCNText节点对象(Swift - Scenekit)的颜色或纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!