I am wondering if there is a way to write text along a surface of a sphere object in SceneKit.
I know I put a texture on the surface and achieve this kind of effect if I have an image, but I want to know if I can just add text dynamically somehow over the surface of the sphere.
Any idea?
EDIT:
This works:
let layer = CALayer()
layer.frame = CGRectMake(0, 0, 100, 100)
layer.backgroundColor = UIColor.orangeColor().CGColor
var textLayer = CATextLayer()
textLayer.frame = layer.bounds
textLayer.fontSize = layer.bounds.size.height
textLayer.string = "Test"
textLayer.alignmentMode = kCAAlignmentLeft
textLayer.foregroundColor = UIColor.greenColor().CGColor
textLayer.display()
layer.addSublayer(textLayer)
let box = SCNBox(width: 10, height: 10, length: 10, chamferRadius: 0.5)
let boxNode = SCNNode(geometry: box)
box.firstMaterial?.locksAmbientWithDiffuse = true
boxNode.position = position
box.firstMaterial?.diffuse.contents = layer
scene.rootNode.addChildNode(boxNode)
you can use any CALayer
as the contents of your SCNMaterialProperty
:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With