2016-04-05 38 views
2

当我运行此SceneKit代码:SCNText渲染没有曲线,没有字体般的

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

我变得非常角文字:

Poorly rendered text

看来要做到这一点,无论字体和它在设备上的行为与模拟器中的行为相同。

这里的上下文中的代码:

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

回答

2

SCNText细分2D贝塞尔路径为您的文字,就像核芯显卡,如果你拉它会怎么做。您可以始终使用flatness属性使其更平滑,但不会获得“亚像素平滑度”。

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