2015-02-07 66 views
6

我想知道是否有方法在SceneKit中沿着球体对象的表面写文本。在球面上写文字SceneKit?

我知道如果我有图像,我会在表面上放置纹理并获得这种效果,但是我想知道是否可以在球体表面动态地添加文本。

任何想法?

enter image description here

编辑:

这工作:

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) 

回答

3

你可以使用任何CALayer为您SCNMaterialProperty :)

+0

内容我尝试添加的CALayer与TextLayer在它和盒子消失...所以,我做错了什么。不知道是什么。 – zumzum 2015-02-09 00:13:43

+0

好吧,现在添加背景颜色(橙色)图层被用作框中的纹理,但我还没有看到任何文字。 – zumzum 2015-02-09 00:28:59

+0

您也可以使用SpriteKit'SKScene'作为材质属性内容。无论采用哪种方式,您都可能需要混淆“contentsTransform”以使其与您想要的方向/位置一起显示。 – rickster 2015-02-09 19:05:45