Skip to content

Instantly share code, notes, and snippets.

@Matt54
Created August 11, 2024 16:14
Show Gist options
  • Save Matt54/204bcd2008a304e2eed166f269a4bc3b to your computer and use it in GitHub Desktop.
Save Matt54/204bcd2008a304e2eed166f269a4bc3b to your computer and use it in GitHub Desktop.
Demonstrating full immersive preview
import RealityKit
import SwiftUI
struct ImmersivePreviewExample: View {
var body: some View {
RealityView { content in
let meshResource = MeshResource.generatePlane(width: 2.0, height: 2.0)
let entity = Entity()
let modelComponent = ModelComponent(mesh: meshResource, materials: [SimpleMaterial(color: .yellow, roughness: 1.0, isMetallic: false)])
entity.components.set(modelComponent)
entity.transform.translation.y = 2.0
entity.transform.translation.z = -5.0
content.add(entity)
}
}
}
#Preview(immersionStyle: .full) {
ImmersivePreviewExample()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment