I successfully changed a picture to the background in ImmersiveSpace in a full state with the following code.
import RealityKit
struct MainBackground: View {
var body: some View {
RealityView { content in
guard let resource = try? await TextureResource(named: "Image_Name") else {
fatalError("Error.")
}
var material = UnlitMaterial()
material.color = .init(texture: .init(resource))
let entity = Entity()
entity.components.set(ModelComponent(
mesh: .generateSphere(radius: 1000),
materials: [material]
))
entity.scale *= .init(x: -1, y: 1, z: 1)
content.add(entity)
}
}
}
However, when running, I found that when the user moves, the background is not fixed, but follows the user's movement, which I feel unrealistic. How to fix the background in the place where it first appears, and give the user a kind of movement that is really like walking in the real world, instead of letting the background follow the user.