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

1

7

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
Salience answered 12/8, 2014 at 15:31 Comment(0)
D
11

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.

Dynamometry answered 12/8, 2014 at 15:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.