在球体表面SceneKit上写文字? [英] Write text on sphere surface SceneKit?

查看:477
本文介绍了在球体表面SceneKit上写文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法在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.

任何想法?

编辑:

这有效:

    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 的内容:)

you can use any CALayer as the contents of your SCNMaterialProperty :)

这篇关于在球体表面SceneKit上写文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆