nightshade 0.57.0

A cross-platform data-oriented game engine.
Documentation
use crate::ecs::primitives::Name;
use crate::ecs::transform::components::LocalTransform;
use crate::ecs::transform::systems::setup_entity_transforms;
use crate::ecs::world::commands::spawn_entities;
use crate::ecs::world::{Entity, GLOBAL_TRANSFORM, LIGHT, LOCAL_TRANSFORM, NAME, World};

/// Spawn a named, positioned light entity with default transforms. Set a
/// [`Light`](crate::ecs::light::components::Light) on the returned entity to
/// configure its type, color, and intensity.
pub fn spawn_light_entity(world: &mut World, position: nalgebra_glm::Vec3, name: &str) -> Entity {
    let entity = spawn_entities(world, NAME | LOCAL_TRANSFORM | GLOBAL_TRANSFORM | LIGHT, 1)[0];
    world.set(entity, Name(name.to_string()));
    setup_entity_transforms(
        world,
        entity,
        LocalTransform {
            translation: position,
            rotation: nalgebra_glm::quat_identity(),
            scale: nalgebra_glm::Vec3::new(1.0, 1.0, 1.0),
        },
    );
    entity
}