簡體   English   中英

在球體表面SceneKit上寫文字?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM