I'm using RealityKit and Model I/O to scan a 3D model and then UV unwrap it. I have created an MDLMesh from ARMeshGeometry following https://stackoverflow.com/questions/61063571/arkit-3-5-how-to-export-obj-from-new-ipad-pro-with-lidar.
It seems that MDLMesh has a method addUnwrappedTextureCoordinates() which should be what I needed. My usage was mesh.addUnwrappedTextureCoordinates(forAttributeNamed: MDLVertexAttributeTextureCoordinate).
Most of the times it gave a runtime error saying
Since there is so little information about this method online, I'd appreciate it if anyone had similar issues or knows how to make this work. Thanks!
It seems that MDLMesh has a method addUnwrappedTextureCoordinates() which should be what I needed. My usage was mesh.addUnwrappedTextureCoordinates(forAttributeNamed: MDLVertexAttributeTextureCoordinate).
Most of the times it gave a runtime error saying
But it did work twice, although I didn't change anything in my code. The exported OBJ has correctly unwrapped UV texture coordinates.libc++abi.dylib: terminating with uncaught exception of type std::outofrange: unorderedmap::at: key not found
terminating with uncaught exception of type std::outofrange: unorderedmap::at: key not found
Since there is so little information about this method online, I'd appreciate it if anyone had similar issues or knows how to make this work. Thanks!