简体   繁体   中英

Write text on sphere surface 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?

在此输入图像描述

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)

你可以使用任何CALayer作为你的SCNMaterialProperty的内容:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM