I have a 3D model that ALWAYS works fine on real device and simulator when compiled from Xcode even if setting as Release and with any optimization setting but when uploaded to TestFlight it's missing some materials.
After debugging (with TF builds because there's no way to reproduce locally) I found out that two of the nodes I'm using (the ones that look bad) have no geometry (they do have geometry locally).
Code I'm using:
self.scene = SCNScene(named: "model.scnassets/Body.dae")
self.scene?.rootNode.rotation = SCNVector4(1, 0, 0, 45.degreesToRadians)
let baseNode = self.scene?.rootNode.childNode(withName: "Body", recursively: true)
let bodyImageMaterial = SCNMaterial()
bodyImageMaterial.isDoubleSided = false
bodyImageMaterial.diffuse.contents = UIImage(named: "Body_Background")
baseNode?.geometry?.materials = [bodyImageMaterial]
baseNode?.geometry
return nil
on production, that's the part I can't figure out and thus the material is not applied. Also I wanna clarify that the geometry works as expected but it's using the default material since nothing is applied.
Try to access a node’s children in the scene graph hierarchy via:
In real code it looks like this:
Sometimes it might be deeper in hierarchy: