Lar*_*ien 5 ios scenekit scntext
当我运行此SceneKit代码时:
let txt = SCNText(string: "Hello", extrusionDepth: 0.2)
let textNode = SCNNode(geometry: txt)
scene.rootNode.addChildNode(textNode)
Run Code Online (Sandbox Code Playgroud)
我得到非常有棱角的文字:
似乎不管字体如何都可以这样做,并且它在设备上的行为与在模拟器中的行为相同。
这是上下文中的代码:
// 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
Run Code Online (Sandbox Code Playgroud)
SCNText细分文本的2DBézier路径,就像绘制核心图形一样。您始终可以使用该flatness属性使其更平滑,但不会获得“亚像素平滑度”。
要解决此问题,可以使用更大的字体,以使基础的Bézier路径更大,并且在进行离散化时会生成更多的顶点。
| 归档时间: |
|
| 查看次数: |
1103 次 |
| 最近记录: |