So far I managed to open an ImmersiveSpace
from my main Window
, which renders an image as a plane's texture like this.-
var body: some View {
ZStack {
RealityView { content in
var material = UnlitMaterial()
material.color = try! .init(tint: .white,
texture: .init(.load(named: "image",
in: nil)))
let entity = Entity()
let component = ModelComponent(
mesh: .generatePlane(width: 1, height: 1),
materials: [material]
)
entity.components.set(component)
entity.scale *= .init(x: 1, y: 1, z: 1)
let currentTransform = entity.transform
var newTransform = Transform(scale: currentTransform.scale,
rotation: currentTransform.rotation,
translation: SIMD3(0, 0, -0.3))
entity.move(to: newTransform, relativeTo: nil)
/*
let scalingPivot = Entity()
scalingPivot.position.y = entity.visualBounds(relativeTo: nil).center.y
scalingPivot.addChild(entity)
content.add(scalingPivot)
scalingPivot.scale *= .init(x: 1, y: 1, z: 1)
*/
}
}
}
but I'm unable to move it deeper in the z-axis
to show it behind the window (if I set something less than -0.4, it just disappears).
Also, I tried scaling in several ways so that the background image shows bigger than the window, but any scale operation seems to affect only the texture coordinates, instead of the plane mesh itself.
And finally, I'd like ideally to render this image in a curved surface (pretty much like a 180% panorama image). As a first approach, I found this tutorial to create a curved wall, but seems arrow objects are not available anymore on Reality Composer Pro
.
Any suggestion / tip for different approaches to render a background image behind the main window are welcomed too :)
If you are in
ImmersiveSpace
you can useaddSkybox
from Apple's "DestinationVideo"In your
App
fileThen in another file
https://developer.apple.com/documentation/visionos/destination-video