Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在Swift ARKit中显示多行文本时导致先前/过度GPU错误的缓冲区_Ios_Swift_Scenekit_Arkit - Fatal编程技术网

Ios 在Swift ARKit中显示多行文本时导致先前/过度GPU错误的缓冲区

Ios 在Swift ARKit中显示多行文本时导致先前/过度GPU错误的缓冲区,ios,swift,scenekit,arkit,Ios,Swift,Scenekit,Arkit,我正在构建一个应用程序,我想在目标增强图像上显示多行文本。该程序在少于7行的文本中运行良好,但在超过7行时崩溃。我还注意到,如果一行太长,也会出现相同的错误“由于执行过程中出现错误,命令缓冲区的执行被中止。忽略(导致以前/过多的GPU错误)” let text = SCNText(string: "this is the first line \n hello this is the second line \n hello this is the third line \n hell

我正在构建一个应用程序,我想在目标增强图像上显示多行文本。该程序在少于7行的文本中运行良好,但在超过7行时崩溃。我还注意到,如果一行太长,也会出现相同的错误“由于执行过程中出现错误,命令缓冲区的执行被中止。忽略(导致以前/过多的GPU错误)”

    let text = SCNText(string: "this is the first line  \n hello this is the second line \n hello this is the third line \n hello this is the fourth line \n hello this is the fifth line \n hello this is the sixth line \n hello this is the seventh line \n hello this is the eigth lines\n " , extrusionDepth: 0.1)

    //setting the basic properties of text

    text.font = UIFont.systemFont(ofSize: 1)
    text.flatness = 0.005
    text.isWrapped = true
    let textNode = SCNNode(geometry: text)
    let fontScale: Float = 0.01
    textNode.scale = SCNVector3(fontScale, fontScale, fontScale)
//将文本设置为在图片上方居中并面向相机

    textNode.eulerAngles.x = -.pi/2
    centerNode(node: textNode)

    //self.sceneView.scene.rootNode.addChildNode(planeNode)
    // the text will be centered right above the image
    node.addChildNode(textNode)
    // create a plane node as the background of the text
    let textWidth = text.boundingBox.max.x - text.boundingBox.min.x
    let textHeight = text.boundingBox.max.y - text.boundingBox.min.y
    let plane = SCNPlane(width: CGFloat(textWidth), height: CGFloat(textHeight))
    plane.firstMaterial?.transparency = 0.5
    plane.firstMaterial?.diffuse.contents = UIColor.black
    let planeNode = SCNNode(geometry: plane)

    planeNode.position = SCNVector3(textWidth/2,1.5*textHeight,-0.0001)
    textNode.addChildNode(planeNode)

“由于执行过程中出现错误,命令缓冲区的执行被中止。已忽略(导致以前/过多的GPU错误)”

当我的文本造成太多复杂性时,我遇到了此问题。我通过增加我的
SCNText
flatness
减少了多边形的总数,并且能够渲染更多的文本

text.flatness = 0.6    // default value
text.flatness = 0.0005 // more polygons, higher complexity
text.flatness = 1.0   // lower polyon, lower complexity (uglier text)

尝试降低复杂性。照明、多边形总数、材质复杂度等。

我一直被困在这个错误中,但现在终于解决了。谢谢