[英]Write text on sphere surface SceneKit?
我想知道是否有一种方法可以在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)
你可以使用任何CALayer
作为你的SCNMaterialProperty
的内容:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.