Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write text on sphere surface SceneKit?

Tags:

ios

scenekit

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?

enter image description here

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)
like image 427
zumzum Avatar asked Feb 07 '15 20:02

zumzum


1 Answers

you can use any CALayer as the contents of your SCNMaterialProperty :)

like image 111
mnuages Avatar answered Oct 04 '22 16:10

mnuages