pub mod engine;
pub mod xr_runtime;
pub mod ray_tracer;
pub mod multiuser_renderer;
pub mod spatial_audio;
use multiuser_renderer::{AvatarConfig, MultiuserRenderer, SyncMode as MultiuserSyncMode, UserAvatar};
use ray_tracer::{BounceLimit, RayTracer, RayTracerConfig};
use spatial_audio::{AudioConfig, AudioSource, HRTFProfile, SpatialAudioSystem};
use std::collections::{BTreeMap, HashMap};
use xr_runtime::{XRConfig, XRMode, XRRuntime};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum XRPlatform {
VisionPro,
MetaQuest,
HoloLens,
WebXR,
OpenXR,
Desktop,
}
impl Default for XRPlatform {
fn default() -> Self {
Self::WebXR
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RenderMode {
Rasterization,
RayTracing,
Hybrid,
PathTracing,
}
impl Default for RenderMode {
fn default() -> Self {
Self::Rasterization
}
}
#[derive(Debug, Clone, Copy, Default)]
pub struct Transform {
pub position: [f32; 3],
pub rotation: [f32; 4],
pub scale: [f32; 3],
}
impl Transform {
pub fn identity() -> Self {
Self {
position: [0.0, 0.0, 0.0],
rotation: [0.0, 0.0, 0.0, 1.0],
scale: [1.0, 1.0, 1.0],
}
}
}
#[derive(Debug, Clone)]
pub struct Material {
pub albedo: [f32; 4],
pub metallic: f32,
pub roughness: f32,
pub emission: [f32; 3],
}
impl Default for Material {
fn default() -> Self {
Self {
albedo: [0.8, 0.8, 0.8, 1.0],
metallic: 0.0,
roughness: 0.5,
emission: [0.0, 0.0, 0.0],
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LightType {
Directional,
Point,
Spot,
Area,
Ambient,
}
#[derive(Debug, Clone)]
pub struct Light {
pub light_type: LightType,
pub position: [f32; 3],
pub direction: [f32; 3],
pub color: [f32; 3],
pub intensity: f32,
pub range: f32,
pub spot_angle: f32,
}
impl Default for Light {
fn default() -> Self {
Self {
light_type: LightType::Directional,
position: [0.0, 10.0, 0.0],
direction: [0.0, -1.0, 0.0],
color: [1.0, 1.0, 1.0],
intensity: 1.0,
range: 100.0,
spot_angle: 45.0,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CameraMode {
Perspective,
Orthographic,
Stereo,
Panoramic,
}
impl Default for CameraMode {
fn default() -> Self {
Self::Perspective
}
}
#[derive(Debug, Clone)]
pub struct Camera {
pub mode: CameraMode,
pub position: [f32; 3],
pub target: [f32; 3],
pub up: [f32; 3],
pub fov: f32,
pub near: f32,
pub far: f32,
pub ipd: f32,
}
impl Default for Camera {
fn default() -> Self {
Self {
mode: CameraMode::Perspective,
position: [0.0, 1.7, 0.0],
target: [0.0, 1.7, -1.0],
up: [0.0, 1.0, 0.0],
fov: 90.0,
near: 0.1,
far: 1000.0,
ipd: 0.063, }
}
}
#[derive(Debug, Clone, Default)]
pub struct RenderStats {
pub frame_time_ms: f64,
pub fps: f64,
pub draw_calls: u64,
pub triangles: u64,
pub gpu_memory_mb: f64,
pub latency_ms: f64,
}
#[derive(Debug, Clone)]
pub struct SceneObject {
name: String,
transform: Transform,
material: Material,
visible: bool,
cast_shadow: bool,
receive_shadow: bool,
}
impl SceneObject {
pub fn new(name: &str, transform: Transform, material: Material) -> Self {
Self {
name: name.to_string(),
transform,
material,
visible: true,
cast_shadow: true,
receive_shadow: true,
}
}
pub fn name(&self) -> &str {
&self.name
}
pub fn transform(&self) -> &Transform {
&self.transform
}
pub fn material(&self) -> &Material {
&self.material
}
pub fn is_visible(&self) -> bool {
self.visible
}
pub fn set_visible(&mut self, visible: bool) {
self.visible = visible;
}
}