Change the color or texture of a SCNText node object (Swift - Scenekit)

守給你的承諾、 提交于 2019-11-27 07:01:20

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/25268386/change-the-color-or-texture-of-a-scntext-node-object-swift-scenekit

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