2016-04-05 35 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路徑更大並生成更多頂點。