【问题标题】:SCNText rendering without curves, not font-likeSCNText 渲染没有曲线,不像字体
【发布时间】:2016-07-26 00:10:07
【问题描述】:

当我运行这个 SceneKit 代码时:

let txt = SCNText(string: "Hello", extrusionDepth: 0.2)
let textNode = SCNNode(geometry: txt)
scene.rootNode.addChildNode(textNode)

我得到非常有棱角的文字:

无论字体如何,它似乎都会这样做,并且它在设备上的行为方式与在模拟器中相同。

这是上下文中的代码:

    // create a new scene
    let scene = SCNScene()

    // create and add a camera to the scene
    let cameraNode = SCNNode()
    cameraNode.camera = SCNCamera()
    scene.rootNode.addChildNode(cameraNode)

    // place the camera
    cameraNode.position = SCNVector3(x: 10, y: 0, z: 75)

    // create and add a light to the scene
    let lightNode = SCNNode()
    lightNode.light = SCNLight()
    lightNode.light!.type = SCNLightTypeOmni
    lightNode.position = SCNVector3(x: 0, y: 10, z: 10)
    scene.rootNode.addChildNode(lightNode)

    // create and add an ambient light to the scene
    let ambientLightNode = SCNNode()
    ambientLightNode.light = SCNLight()
    ambientLightNode.light!.type = SCNLightTypeAmbient
    ambientLightNode.light!.color = UIColor.darkGrayColor()
    scene.rootNode.addChildNode(ambientLightNode)

    let txt = SCNText(string: "Hello", extrusionDepth: 0.2)

    let textNode = SCNNode(geometry: txt)
    scene.rootNode.addChildNode(textNode)



    // retrieve the SCNView
    let scnView = self.view as! SCNView

    // set the scene to the view
    scnView.scene = scene

【问题讨论】:

    标签: ios scenekit scntext


    【解决方案1】:

    SCNText 为您的文本细分 2D Bézier 路径,就像 Core Graphics 在您绘制它时所做的那样。您始终可以使用flatness 属性使其更平滑,但不会获得“亚像素平滑度”。

    要解决这个问题,您可以使用更大的字体,这样底层的 Bézier 路径会更大,并且在发生离散化时会生成更多的顶点。

    【讨论】:

      【解决方案2】:

      我的解决方案是使用大字体,因为建议使用@mnuages,然后在文本节点上使用缩放

           animatedTextNode.scale = SCNVector3(0.1, 0.1, 0.1)
      

      得到我想要的尺寸。

      在这种情况下,当您为文本设置动画并且靠近相机时,它看起来很平滑。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-01-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-20
        • 1970-01-01
        • 2014-09-02
        相关资源
        最近更新 更多