Код: Выделить всё
DispatchQueue.main.asyncВот мой код:
Код: Выделить всё
func helper_cloneGeo(geo: SCNGeometry) -> SCNGeometry {
let copiedGeo = geo.copy() as! SCNGeometry
copiedGeo.materials = geo.materials.map { $0.copy() as! SCNMaterial }
return copiedGeo
}
override init() {
super.init()
let geo = readGeo(fn: "alcohol.usdz", texture: "texture.png").geometry!
// HERE!!!
// SCNGeometry is only clone-able after async!!
// DispatchQueue.main.async {
let copiedGeo = self.helper_cloneGeo(geo: geo)
let newNode = SCNNode(geometry: copiedGeo)
self.rootNode.addChildNode(newNode)
// }
}
Вы можете скачать мой пример проекта здесь: https://drive.google.com/file/d/1kYyqCA ... sp=sharing
В этом проекте при запуске отображается модель. Затем, если вы закомментируете DispatchQueue.main.async (как в приведенном выше коде), модель не будет отображаться.

Подробнее здесь: https://stackoverflow.com/questions/793 ... nt-runloop
Мобильная версия