8

この 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
4

2 に答える 2

7

SCNTextCore Graphics が描画する場合と同様に、テキストの 2D ベジエ パスを分割します。プロパティを使用していつでもflatness滑らかにすることができますが、「サブピクセルの滑らかさ」は得られません。

この問題を解決するには、より大きなフォント サイズを使用して、基になるベジエ パスを大きくし、離散化が発生したときにより多くの頂点が生成されるようにします。

于 2016-04-05T20:55:31.907 に答える