我try 将纹理应用到MeshResource,使用以下代码:
let largeSphere = MeshResource.generateSphere(radius: 2)
var myMaterial = UnlitMaterial()
do {
let texture = try TextureResource.load(named: "studio-mod")
myMaterial.color = .init(texture: .init(texture))
} catch {
print("Failed to create myMaterial with texture: \(error)")
return nil
}
此操作失败,并抛出以下错误:
Error Domain=MTKTextureLoaderErrorDomain Code=0 "Image decoding failed"
UserInfo={NSLocalizedDescription=Image decoding failed, MTKTextureLoaderErrorKey=Image decoding failed}
资源"studio—mod"是一个jpg图像,包含在应用程序包的资源中.
我try 应用的纹理是360度全景图像. 我已经能够用iPhone上的图像拼接起来,但是当我试图使用用Insta360x3创建的图像时,我得到了这个错误.
Insta360的图像似乎是全景和期待使用其他360 º全景图像查看器我已经try . 我已经成功地用其他全景jpg图像和其他常规jpg图像做到了这一点.
Insta360的jpg图像在我看来是一样的(判断元数据并在其他应用程序中打开它们,等等).
有谁能想到一个原因这些特定的jpg文件可能无法正确解码在这个操作?