Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 649
quemeful Avatar asked Aug 12 '14 15:08

quemeful


1 Answers

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.

like image 136
mnuages Avatar answered Nov 10 '22 01:11

mnuages