fx: json files

This commit is contained in:
2026-05-03 16:06:54 +02:00
parent 10f9c0984d
commit 549707fbb3
4 changed files with 29 additions and 56 deletions

View File

@@ -7,7 +7,7 @@ mod raytracer;
mod scenes;
mod vec3;
use std::fs;
use std::{env, fs};
use std::sync::Arc;
use crate::camera::Camera;
@@ -27,8 +27,13 @@ fn main() {
dotenv().ok();
pretty_env_logger::init();
// TODO: use cli arg for scenefile
let json_file = "./scenes/scene.json";
// TODO: better cli parsing
let mut json_file = "./scenes/scene.json";
let args: Vec<String> = env::args().collect();
if args.len() > 1 {
json_file = &args[1];
}
let json_str = fs::read_to_string(json_file).expect("Reading specified scene file failed!");
let mut scene: Scene = serde_json::from_str(&json_str).unwrap();
render(&mut scene);