【发布时间】:2015-04-07 20:31:39
【问题描述】:
我想知道是否有一种方法可以在 SceneKit 中沿球体对象的表面写入文本。
我知道如果我有图像,我会在表面上放置纹理并实现这种效果,但我想知道是否可以在球体表面上以某种方式动态添加文本。
有什么想法吗?
编辑:
这行得通:
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)
【问题讨论】: