SCNText渲染没有曲线,不像字体 [英] SCNText rendering without curves, not font-like

查看:238
本文介绍了SCNText渲染没有曲线,不像字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行这个SceneKit代码时:

When I run this SceneKit code:

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

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

I get very angular text:

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

It seems to do this regardless of font and it behaves the same way on a device as in the simulator.

这是上下文中的代码:

    // 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


推荐答案

SCNText 为您的文本细分2DBézier路径,就像Core Graphics绘制它时一样。您始终可以使用 flatness 属性使其更平滑,但不会获得子像素平滑度。

SCNText subdivides the 2D Bézier path for your text just like Core Graphics would do if you were drawing it. You can always use the flatness property to make it smoother, but you won't get "sub-pixel smoothness".

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

To solve this issue you can use a bigger font size, so that the underlying Bézier path is bigger and more vertices are generated when discretization occurs.

这篇关于SCNText渲染没有曲线,不像字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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