gpt4 book ai didi

swift - "Scene is modified within a rendering callback of another scene."如何解决这个错误?

转载 作者:搜寻专家 更新时间:2023-10-31 22:54:28 28 4
gpt4 key购买 nike

我正在使用 ARKit 图像跟踪配置,一旦检测到图像,图像上就会弹出 3D 场景。

但是当我设置两个不同的图像触发两个不同的场景文件时,一张图像总是在同一张图像上弹出两个不同的场景文件。我敢肯定图像不同,名称不同,场景文件不同,场景的内容也不同。

检测到图像后,控制台中也会弹出以下错误:

[SceneKit] Error: Scene <SCNScene: 0x284ebcfa0> is modified within a rendering callback of another scene (<SCNScene: 0x28099c820>). This is not allowed and may lead to crash

这个错误有什么原因和解决办法吗?

最佳答案

我在 ARKit 2 的图像跟踪中遇到了同样的错误。经过数小时的尝试,我找到了解决方案。显然你需要在后台线程中创建你的节点才能玩场景。这是我的代码:

DispatchQueue.main.async {
if let imageAnchor = anchor as? ARImageAnchor {

let plane = SCNPlane(width: imageAnchor.referenceImage.physicalSize.width, height: imageAnchor.referenceImage.physicalSize.height)
plane.firstMaterial?.diffuse.contents = UIColor(white: 1.0, alpha: 0.5)

let planeNode = SCNNode(geometry: plane)
planeNode.eulerAngles.x = -.pi
node.addChildNode(planeNode)

...
}
}

关于swift - "Scene is modified within a rendering callback of another scene."如何解决这个错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51624346/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com