euv-core 0.52.1

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// In-memory URI resolver for `.gltf` buffers and images (ideal for WASM and deterministic tests).
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct MemoryGltfResolver {
    /// Map of relative buffer URI strings to raw binary bytes.
    pub(crate) buffers: HashMap<String, Vec<u8>>,
    /// Map of relative image URI strings to encoded PNG/JPEG/BMP bytes.
    pub(crate) images: HashMap<String, Vec<u8>>,
}

/// Filesystem directory URI resolver with canonical path-traversal guards for native `.gltf` loading.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct DirectoryGltfResolver {
    /// Base directory containing the `.gltf` document.
    pub(crate) base_dir: PathBuf,
}

/// Imported Blender Armature / glTF 2.0 skin binding joint node indices to inverse bind matrices.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct ImportedSkin3D {
    /// Human-readable armature or skin name.
    pub(crate) name: String,
    /// Ordered joint node indices into `ImportedScene3D::scene_graph`.
    pub(crate) joints: Vec<u32>,
    /// Optional skeleton root node index.
    #[get(type(copy))]
    pub(crate) skeleton_root: Option<u32>,
    /// Column-major inverse bind matrices aligned 1:1 with `joints`.
    pub(crate) inverse_bind_matrices: Vec<Mat4>,
}

/// Single keyframe timeline sampler belonging to an `ImportedAnimationClip3D`.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct ImportedAnimationSampler3D {
    /// Monotonic keyframe timestamps in seconds.
    pub(crate) timestamps: Vec<f32>,
    /// Flattened keyframe values (and cubic-spline in/out tangents when `CubicSpline`).
    pub(crate) values: Vec<f32>,
    /// Scalar floats per keyframe value (`3` for T/S, `4` for R, `morph_count` for Weights).
    #[get(type(copy))]
    pub(crate) value_stride: usize,
    /// Interpolation mode (`Step`, `Linear`, `CubicSpline`).
    #[get(type(copy))]
    pub(crate) interpolation: GltfInterpolationMode,
}

/// Channel binding an `ImportedAnimationSampler3D` to a scene node property.
#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
pub struct ImportedAnimationChannel3D {
    /// Target node index in `ImportedScene3D::scene_graph`.
    #[get(type(copy))]
    pub(crate) target_node: u32,
    /// Animated node property (`Translation`, `Rotation`, `Scale`, `MorphWeights`).
    #[get(type(copy))]
    pub(crate) path: GltfAnimationPath,
    /// Index into `ImportedAnimationClip3D::samplers`.
    #[get(type(copy))]
    pub(crate) sampler_index: usize,
}

/// Complete animation clip imported from a Blender Action / glTF 2.0 animation.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct ImportedAnimationClip3D {
    /// Action or clip name.
    pub(crate) name: String,
    /// Maximum timestamp across all samplers in seconds.
    #[get(type(copy))]
    pub(crate) duration_secs: f32,
    /// Timeline samplers referenced by `channels`.
    pub(crate) samplers: Vec<ImportedAnimationSampler3D>,
    /// Node-property animation channels.
    pub(crate) channels: Vec<ImportedAnimationChannel3D>,
}

/// Camera asset imported from a Blender Camera / glTF 2.0 camera entry.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct ImportedCamera3D {
    /// Camera label.
    pub(crate) name: String,
    /// Perspective or orthographic projection parameters.
    #[get(type(copy))]
    pub(crate) projection: GltfCameraProjection,
}

/// Light asset imported from `KHR_lights_punctual` or Blender area-light extras.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct ImportedLight3D {
    /// Light label.
    pub(crate) name: String,
    /// Linear RGB emission color.
    #[get(type(copy))]
    pub(crate) color: Vec3,
    /// Luminous intensity (candela for point/spot, lux for directional).
    #[get(type(copy))]
    pub(crate) intensity: f32,
    /// Emitter geometry and falloff parameters.
    #[get(type(copy))]
    pub(crate) kind: GltfLightKind,
}

/// Complete imported Blender/glTF 2.0 scene bundle with hierarchy, meshes, Principled BSDF materials, textures, rigs, animations, cameras, and lights.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct ImportedScene3D {
    /// Scene or model name.
    pub(crate) name: String,
    /// Exporting tool generator string (e.g., `"Khronos glTF Blender I/O"`).
    pub(crate) generator: String,
    /// Hierarchical scene graph with Collections and propagated world matrices.
    pub(crate) scene_graph: SceneGraph3D,
    /// Flat mesh primitive list referenced by `SceneNode3D::mesh_id`.
    pub(crate) meshes: Vec<Mesh3D>,
    /// Principled BSDF material table referenced by `Mesh3D::material_index`.
    pub(crate) materials: Vec<PrincipledMaterial3D>,
    /// Decoded mipmapped texture pool referenced by `TextureSlot3D::texture_index`.
    pub(crate) textures: Vec<Texture2D3D>,
    /// Imported armature skins referenced by `SceneNode3D::skin_id`.
    pub(crate) skins: Vec<ImportedSkin3D>,
    /// Imported Blender Actions / glTF animation clips.
    pub(crate) animations: Vec<ImportedAnimationClip3D>,
    /// Imported cameras referenced by `SceneNode3D::camera_id`.
    pub(crate) cameras: Vec<ImportedCamera3D>,
    /// Imported punctual and area lights referenced by `SceneNode3D::light_id`.
    pub(crate) lights: Vec<ImportedLight3D>,
}