微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ios – 在球体表面SceneKit上写文字?

我想知道是否有一种方法可以在SceneKit中沿着球体对象的表面写入文本.

我知道如果我有一个图像,我会在表面上放置纹理并实现这种效果,但我想知道我是否可以在球体表面上以某种方式动态添加文本.

任何的想法?

编辑:

这有效:

let layer = CALayer()
    layer.frame = CGRectMake(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的内容:)

原文地址:https://www.jb51.cc/iOS/331450.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐