Created
August 11, 2024 16:14
-
-
Save Matt54/204bcd2008a304e2eed166f269a4bc3b to your computer and use it in GitHub Desktop.
Demonstrating full immersive preview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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