nightshade 0.14.1

A cross-platform data-oriented game engine.
Documentation
//! ECS world definition and component/resource re-exports.
//!
//! The [`World`] struct is the central data store for all game state, generated by
//! the `freecs::ecs!` macro. It contains:
//!
//! - **Entities**: Created with `world.spawn_entities(flags, count)`, identified by [`Entity`] (u64)
//! - **Components**: Bitflag-selected data (e.g., `LOCAL_TRANSFORM | RENDER_MESH`)
//! - **Resources**: Global singletons accessed via `world.resources`
//!
//! Key resource paths:
//!
//! - `world.resources.window.timing` — frame timing ([`WindowTiming`](resources::WindowTiming))
//! - `world.resources.input` — keyboard/mouse/touch state ([`Input`](resources::Input))
//! - `world.resources.graphics` — rendering settings ([`Graphics`](resources::Graphics))
//! - `world.resources.active_camera` — current camera entity
//! - `world.resources.entities.names` — name-to-entity mapping

pub mod components {
    pub use crate::ecs::animation::components::{
        AnimationChannel, AnimationClip, AnimationInterpolation, AnimationPlayer,
        AnimationProperty, AnimationSampler, AnimationSamplerOutput, AnimationValue,
    };
    pub use crate::ecs::audio::components::{AudioBus, AudioListener, AudioSource};
    pub use crate::ecs::bounding_volume::components::{BoundingVolume, OrientedBoundingBox};
    pub use crate::ecs::camera::components::{
        Camera, CameraEnvironment, CameraPostProcess, ConstrainedAspect, FogOverride,
        OrthographicCamera, PanOrbitCamera, PerspectiveCamera, Projection, ShadingMode, Smoothing,
        ViewportShading, ViewportUpdateMode,
    };

    pub use crate::ecs::decal::components::Decal;
    #[cfg(feature = "grass")]
    pub use crate::ecs::grass::components::{
        GrassConfig, GrassInteractor, GrassRegion, GrassSpecies,
    };
    pub use crate::ecs::input::components::Hovered;
    pub use crate::ecs::light::components::{Light, LightType};
    pub use crate::ecs::lines::components::{Line, Lines, MAX_LINES};
    pub use crate::ecs::material::components::{
        AlphaMode, Material, MaterialRef, MaterialVariantMapping, MaterialVariants,
    };
    pub use crate::ecs::mesh::components::{InstanceTransform, InstancedMesh, RenderMesh};
    pub use crate::ecs::morph::components::MorphWeights;
    pub use crate::ecs::particles::components::{
        ColorGradient, EmitterShape, EmitterType, ParticleEmitter, ParticleSystemStats,
        ParticleTextureUpload,
    };
    pub use crate::ecs::physics::components::{
        CharacterControllerComponent, ColliderComponent, ColliderShape, CollisionListener,
        PhysicsInterpolation, RigidBodyComponent,
    };
    pub use crate::ecs::primitives::CastsShadow;
    pub use crate::ecs::primitives::EasingFunction;
    pub use crate::ecs::primitives::Guid;
    pub use crate::ecs::primitives::Name;
    pub use crate::ecs::primitives::Visibility;
    pub use crate::ecs::primitives::{CameraCullingMask, CullingMask, RenderLayer};
    pub use crate::ecs::skin::components::{Joint, Skin};
    pub use crate::ecs::text::components::{
        Text, TextAlignment, TextCharacterBackgroundColors, TextCharacterColors, TextProperties,
        VerticalAlignment,
    };
    pub use crate::ecs::transform::components::{
        GlobalTransform, LocalTransform, LocalTransformDirty, Parent, Rotation,
    };
    pub use crate::ecs::ui::components::{
        StateTransition, UiButtonData, UiDepthMode, UiLayoutNode, UiLayoutRoot, UiNodeColor,
        UiNodeContent, UiNodeInteraction, UiStateWeights, UiThemeBinding,
    };
}

pub mod resources {
    pub use crate::ecs::asset_state::AssetState;
    #[cfg(feature = "audio")]
    pub use crate::ecs::audio::resources::AudioEngine;
    pub use crate::ecs::entity_registry::EntityRegistry;
    pub use crate::ecs::event_bus::resources::{EventBus, Message};
    pub use crate::ecs::graphics::resources::{
        Atmosphere, ColorGrading, ColorGradingPreset, Fog, Graphics, IblViews, MeshLodChain,
        MeshLodLevel, TonemapAlgorithm, VertexSnap,
    };
    pub use crate::ecs::input::resources::{Input, MouseState};
    pub use crate::ecs::loading::LoadingState;
    pub use crate::ecs::material::resources::MaterialRegistry;
    #[cfg(feature = "physics")]
    pub use crate::ecs::physics::resources::PhysicsWorld;
    #[cfg(feature = "assets")]
    pub use crate::ecs::prefab::resources::CachedPrefab;
    pub use crate::ecs::prefab::resources::{AnimationCache, MeshCache, PrefabCache};
    pub use crate::ecs::text::resources::{TextCache, TextState};
    pub use crate::ecs::transform::resources::TransformState;
    pub use crate::ecs::ui::UserInterface;
    pub use crate::ecs::window::resources::{ViewportRect, Window, WindowTiming};
    pub use crate::ecs::world::cleanup::CleanupState;
    pub use crate::render::wgpu::texture_cache::TextureCache;
}

pub mod events {
    pub use crate::ecs::event_bus::resources::{InputEvent, KeyState, Message};
    pub use crate::ecs::input::events::AppEvent;
}

pub use crate::ecs::input::events::AppEvent;

pub mod cleanup;
pub mod commands;
pub mod scratch;
pub use commands::{
    CommandQueues, EcsCommand, RenderCommand, capture_procedural_atmosphere_ibl,
    cleanup_unused_resources_system, despawn_entities_with_cache_cleanup, load_hdr_skybox,
    load_procedural_textures, process_commands_system, set_material_with_textures,
    spawn_3d_billboard_text_with_properties, spawn_3d_text_with_properties, spawn_cone_at,
    spawn_cube_at, spawn_cylinder_at, spawn_instanced_mesh, spawn_instanced_mesh_with_material,
    spawn_mesh_at, spawn_plane_at, spawn_sphere_at, spawn_sun, spawn_torus_at,
};
#[cfg(not(target_arch = "wasm32"))]
pub use commands::{capture_screenshot, capture_screenshot_to_path};
pub use scratch::Scratch;

pub mod animation_systems {
    pub use crate::ecs::animation::systems::{apply_animations, update_animation_players};
}

pub use freecs::Entity;
pub use nalgebra_glm::{Mat4, Quat, Vec2, Vec3, Vec4};

freecs::ecs! {
    World {
        Core {
            animation_player: crate::ecs::animation::components::AnimationPlayer => ANIMATION_PLAYER,
            audio_listener: crate::ecs::audio::components::AudioListener => AUDIO_LISTENER,
            audio_source: crate::ecs::audio::components::AudioSource => AUDIO_SOURCE,
            bounding_volume: crate::ecs::bounding_volume::components::BoundingVolume => BOUNDING_VOLUME,
            camera_culling_mask: crate::ecs::primitives::CameraCullingMask => CAMERA_CULLING_MASK,
            camera_environment: crate::ecs::camera::components::CameraEnvironment => CAMERA_ENVIRONMENT,
            camera_post_process: crate::ecs::camera::components::CameraPostProcess => CAMERA_POST_PROCESS,
            camera: crate::ecs::camera::components::Camera => CAMERA,
            casts_shadow: crate::ecs::primitives::CastsShadow => CASTS_SHADOW,
            character_controller: crate::ecs::physics::components::CharacterControllerComponent => CHARACTER_CONTROLLER,
            collider: crate::ecs::physics::components::ColliderComponent => COLLIDER,
            collision_listener: crate::ecs::physics::components::CollisionListener => COLLISION_LISTENER,
            constrained_aspect: crate::ecs::camera::components::ConstrainedAspect => CONSTRAINED_ASPECT,
            culling_mask: crate::ecs::primitives::CullingMask => CULLING_MASK,
            decal: crate::ecs::decal::components::Decal => DECAL,
            global_transform: crate::ecs::transform::components::GlobalTransform => GLOBAL_TRANSFORM,
            grass_interactor: crate::ecs::grass::components::GrassInteractor => GRASS_INTERACTOR,
            grass_region: crate::ecs::grass::components::GrassRegion => GRASS_REGION,
            guid: crate::ecs::primitives::Guid => GUID,
            hovered: crate::ecs::input::components::Hovered => HOVERED,
            ignore_parent_scale: crate::ecs::transform::components::IgnoreParentScale => IGNORE_PARENT_SCALE,
            instanced_mesh: crate::ecs::mesh::components::InstancedMesh => INSTANCED_MESH,
            joint: crate::ecs::skin::components::Joint => JOINT,
            light: crate::ecs::light::components::Light => LIGHT,
            lines: crate::ecs::lines::components::Lines => LINES,
            local_transform_dirty: crate::ecs::transform::components::LocalTransformDirty => LOCAL_TRANSFORM_DIRTY,
            local_transform: crate::ecs::transform::components::LocalTransform => LOCAL_TRANSFORM,
            material_ref: crate::ecs::material::components::MaterialRef => MATERIAL_REF,
            material_variants: crate::ecs::material::components::MaterialVariants => MATERIAL_VARIANTS,
            morph_weights: crate::ecs::morph::components::MorphWeights => MORPH_WEIGHTS,
            name: crate::ecs::primitives::Name => NAME,
            navmesh_agent: crate::ecs::navmesh::components::NavMeshAgent => NAVMESH_AGENT,
            pan_orbit_camera: crate::ecs::camera::components::PanOrbitCamera => PAN_ORBIT_CAMERA,
            parent: crate::ecs::transform::components::Parent => PARENT,
            particle_emitter: crate::ecs::particles::components::ParticleEmitter => PARTICLE_EMITTER,
            physics_interpolation: crate::ecs::physics::components::PhysicsInterpolation => PHYSICS_INTERPOLATION,
            prefab_instance: crate::ecs::prefab::components::PrefabInstance => PREFAB_INSTANCE,
            prefab_source: crate::ecs::prefab::components::PrefabSource => PREFAB_SOURCE,
            render_layer: crate::ecs::primitives::RenderLayer => RENDER_LAYER,
            render_mesh: crate::ecs::mesh::components::RenderMesh => RENDER_MESH,
            rigid_body: crate::ecs::physics::components::RigidBodyComponent => RIGID_BODY,
            rotation: crate::ecs::transform::components::Rotation => ROTATION,
            skin: crate::ecs::skin::components::Skin => SKIN,
            text_character_background_colors: crate::ecs::text::components::TextCharacterBackgroundColors => TEXT_CHARACTER_BACKGROUND_COLORS,
            text_character_colors: crate::ecs::text::components::TextCharacterColors => TEXT_CHARACTER_COLORS,
            text: crate::ecs::text::components::Text => TEXT,
            third_person_camera: crate::ecs::camera::components::ThirdPersonCamera => THIRD_PERSON_CAMERA,
            viewport_shading: crate::ecs::camera::components::ViewportShading => VIEWPORT_SHADING,
            viewport_update_mode: crate::ecs::camera::components::ViewportUpdateMode => VIEWPORT_UPDATE_MODE,
            visibility: crate::ecs::primitives::Visibility => VISIBILITY,
        }
        Ui {
            ui_breadcrumb: crate::ecs::ui::components::UiBreadcrumbData => UI_BREADCRUMB,
            ui_button: crate::ecs::ui::components::UiButtonData => UI_BUTTON,
            ui_canvas: crate::ecs::ui::components::UiCanvasData => UI_CANVAS,
            ui_checkbox: crate::ecs::ui::components::UiCheckboxData => UI_CHECKBOX,
            ui_collapsing_header: crate::ecs::ui::components::UiCollapsingHeaderData => UI_COLLAPSING_HEADER,
            ui_color_picker: crate::ecs::ui::components::UiColorPickerData => UI_COLOR_PICKER,
            ui_color_wheel: crate::ecs::ui::components::UiColorWheelData => UI_COLOR_WHEEL,
            ui_command_palette: crate::ecs::ui::components::UiCommandPaletteData => UI_COMMAND_PALETTE,
            ui_context_menu: crate::ecs::ui::components::UiContextMenuData => UI_CONTEXT_MENU,
            ui_data_grid: crate::ecs::ui::components::UiDataGridData => UI_DATA_GRID,
            ui_date_picker: crate::ecs::ui::components::UiDatePickerData => UI_DATE_PICKER,
            ui_drag_source: crate::ecs::ui::components::UiDragSource => UI_DRAG_SOURCE,
            ui_drag_value: crate::ecs::ui::components::UiDragValueData => UI_DRAG_VALUE,
            ui_drop_target: crate::ecs::ui::components::UiDropTarget => UI_DROP_TARGET,
            ui_dropdown: crate::ecs::ui::components::UiDropdownData => UI_DROPDOWN,
            ui_layout_node: crate::ecs::ui::components::UiLayoutNode => UI_LAYOUT_NODE,
            ui_layout_root: crate::ecs::ui::components::UiLayoutRoot => UI_LAYOUT_ROOT,
            ui_menu: crate::ecs::ui::components::UiMenuData => UI_MENU,
            ui_modal_dialog: crate::ecs::ui::components::UiModalDialogData => UI_MODAL_DIALOG,
            ui_multi_select: crate::ecs::ui::components::UiMultiSelectData => UI_MULTI_SELECT,
            ui_node_blended_transform: crate::ecs::ui::components::UiNodeBlendedTransform => UI_NODE_BLENDED_TRANSFORM,
            ui_node_color: crate::ecs::ui::components::UiNodeColor => UI_NODE_COLOR,
            ui_node_content: crate::ecs::ui::components::UiNodeContent => UI_NODE_CONTENT,
            ui_node_effect: crate::ecs::ui::components::UiNodeEffect => UI_NODE_EFFECT,
            ui_node_interaction: crate::ecs::ui::components::UiNodeInteraction => UI_NODE_INTERACTION,
            ui_node_shadow_states: crate::ecs::ui::components::UiNodeShadowStates => UI_NODE_SHADOW_STATES,
            ui_node_shadow: crate::ecs::ui::components::UiNodeShadow => UI_NODE_SHADOW,
            ui_node_transform_states: crate::ecs::ui::components::UiNodeTransformStates => UI_NODE_TRANSFORM_STATES,
            ui_panel: crate::ecs::ui::components::UiPanelData => UI_PANEL,
            ui_progress_bar: crate::ecs::ui::components::UiProgressBarData => UI_PROGRESS_BAR,
            ui_property_grid: crate::ecs::ui::components::UiPropertyGridData => UI_PROPERTY_GRID,
            ui_radio: crate::ecs::ui::components::UiRadioData => UI_RADIO,
            ui_range_slider: crate::ecs::ui::components::UiRangeSliderData => UI_RANGE_SLIDER,
            ui_rich_text_editor: crate::ecs::ui::components::UiRichTextEditorData => UI_RICH_TEXT_EDITOR,
            ui_rich_text: crate::ecs::ui::components::UiRichTextData => UI_RICH_TEXT,
            ui_scroll_area: crate::ecs::ui::components::UiScrollAreaData => UI_SCROLL_AREA,
            ui_selectable_label: crate::ecs::ui::components::UiSelectableLabelData => UI_SELECTABLE_LABEL,
            ui_slider: crate::ecs::ui::components::UiSliderData => UI_SLIDER,
            ui_spinner: crate::ecs::ui::components::UiSpinnerData => UI_SPINNER,
            ui_splitter: crate::ecs::ui::components::UiSplitterData => UI_SPLITTER,
            ui_state_weights: crate::ecs::ui::components::UiStateWeights => UI_STATE_WEIGHTS,
            ui_tab_bar: crate::ecs::ui::components::UiTabBarData => UI_TAB_BAR,
            ui_text_area: crate::ecs::ui::components::UiTextAreaData => UI_TEXT_AREA,
            ui_text_input: crate::ecs::ui::components::UiTextInputData => UI_TEXT_INPUT,
            ui_theme_binding: crate::ecs::ui::components::UiThemeBinding => UI_THEME_BINDING,
            ui_tile_container: crate::ecs::ui::components::UiTileContainerData => UI_TILE_CONTAINER,
            ui_toggle: crate::ecs::ui::components::UiToggleData => UI_TOGGLE,
            ui_tree_node: crate::ecs::ui::components::UiTreeNodeData => UI_TREE_NODE,
            ui_tree_view: crate::ecs::ui::components::UiTreeViewData => UI_TREE_VIEW,
            ui_virtual_list: crate::ecs::ui::components::UiVirtualListData => UI_VIRTUAL_LIST,
        }
    }
    Resources {
        active_camera: Option<freecs::Entity>,
       #[cfg(all(feature = "assets", feature = "file_watcher", not(target_arch = "wasm32")))]
        asset_watcher: crate::ecs::asset_watcher::AssetWatcher,
        assets: crate::ecs::asset_state::AssetState,
        #[cfg(feature = "audio")]
        audio: crate::ecs::audio::resources::AudioEngine,
        cleanup: crate::ecs::world::cleanup::CleanupState,
        commands: crate::ecs::world::commands::CommandQueues,
        component_types: crate::ecs::scene::typed::ComponentTypeRegistry,
        entities: crate::ecs::entity_registry::EntityRegistry,
        event_bus: crate::ecs::event_bus::resources::EventBus,
        #[cfg(all(feature = "file_watcher", not(target_arch = "wasm32")))]
        file_watcher: crate::ecs::file_watcher::FileWatcher,
        gpu_picking: crate::ecs::gpu_picking::GpuPicking,
        graphics: crate::ecs::graphics::resources::Graphics,
        ibl_views: crate::ecs::graphics::resources::IblViews,
        input: crate::ecs::input::resources::Input,
        is_runtime: bool,
        loading: crate::ecs::loading::LoadingState,
        mesh_render_state: crate::render::wgpu::passes::geometry::MeshRenderState,
        monitors: crate::ecs::window::resources::Monitors,
        #[cfg(feature = "navmesh")]
        navmesh: crate::ecs::navmesh::resources::NavMeshWorld,
        #[cfg(feature = "physics")]
        physics: crate::ecs::physics::resources::PhysicsWorld,
        #[cfg(feature = "physics")]
        picking_world: crate::ecs::picking::resources::PickingWorld,
        retained_ui: crate::ecs::ui::resources::RetainedUiState,
        schedules: crate::schedule::Schedules,
        scratch: crate::ecs::world::scratch::Scratch,
        #[cfg(all(feature = "steam", not(target_arch = "wasm32")))]
        steam: crate::steam::SteamResources,
        text: crate::ecs::text::resources::TextState,
        texture_cache: crate::render::wgpu::texture_cache::TextureCache,
        transform_state: crate::ecs::transform::resources::TransformState,
        ui_image_allocator: crate::ecs::ui::resources::UiImageLayerAllocator,
        user_interface: crate::ecs::ui::UserInterface,
        window: crate::ecs::window::resources::Window,
        world_id: u64,
    }
}

pub use crate::ecs::input::resources::DroppedFile;