### Complete Rendering Loop Example Source: https://context7.com/schell/renderling/llms.txt A full example demonstrating a typical rendering setup with models, lighting, and skybox. Initializes context, camera, loads GLTF, sets up skybox and IBL, adds lighting, renders, and saves the output. ```rust use renderling::{ camera::Camera, context::Context, glam::{Mat4, Vec3, Vec4}, gltf::GltfDocument, light::Candela, pbr::ibl::Ibl, stage::Stage, types::GpuOnlyArray, }; #[tokio::main] async fn main() { // Initialize context and stage let ctx = Context::headless(512, 512).await; let stage: Stage = ctx .new_stage() .with_background_color(Vec4::new(0.1, 0.1, 0.1, 1.0)); // Set up camera let _camera: Camera = stage .new_camera() .with_projection_and_view( Mat4::perspective_rh(std::f32::consts::PI / 4.0, 1.0, 0.1, 100.0), Mat4::look_at_rh( Vec3::new(2.0, 2.0, 2.0), Vec3::ZERO, Vec3::Y ) ); // Load GLTF model let _model: GltfDocument = stage .load_gltf_document_from_path("model.glb") .unwrap() .into_gpu_only(); // Add skybox and IBL let skybox = stage.new_skybox_from_path("environment.hdr").unwrap(); stage.use_skybox(&skybox); let ibl = stage.new_ibl(&skybox); stage.use_ibl(&ibl); // Add accent lighting let _light = stage .new_point_light() .with_position(Vec3::new(1.0, 2.0, 1.0)) .with_color(Vec4::ONE) .with_intensity(Candela(50.0)); // Render and save let frame = ctx.get_next_frame().unwrap(); stage.render(&frame.view()); let img = frame.read_image().await.unwrap(); img.save("rendered_scene.png").unwrap(); frame.present(); } ``` -------------------------------- ### Setup for Skybox Example Source: https://github.com/schell/renderling/blob/main/manual/src/skybox.md This code sets up the initial scene, likely loading a GLTF model, which serves as the base for adding a skybox. Ensure you have the necessary dependencies for GLTF loading. ```rust use renderling::prelude::*; fn main() { let mut app = App::new(); app.add_plugins(DefaultPlugins) .add_systems(Startup, setup_scene) .add_systems(Update, rotate_camera); app.run(); } fn setup_scene(mut commands: Commands, asset_server: Res) { // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(0.0, 0.0, 5.0), ..default() }); // light commands.spawn(PointLightBundle { point_light: PointLight { intensity: 1500.0, shadows_enabled: true, ..default() }, transform: Transform::from_xyz(4.0, 8.0, 4.0), ..default() }); // load the scene commands.spawn(SceneBundle { scene: asset_server.load("models/scene.gltf#Scene0"), ..default() }); } fn rotate_camera(mut query: Query<&mut Transform, With>, time: Res