Macro aframe::component

source ·
macro_rules! component {
    ($($cmp:ident)::* $(, $field:ident: $val:expr)*) => { ... };
}
Expand description

A macro to instantiate a component. Mimics struct creation syntax, but allows any number of fields to be left out (in which case defaults will be used). Note that the ability to leave out fields does not extend to struct_like enum variants created in this macro. For example: component!{component::Camera} will create a camera component with all its fields set to default values, whereas component!{component::Camera, active = false} will create a camera component with all its fields set to default values except the active field.

// For example:
use aframe::component;
 
component!(component::Light,
    light_type: component::LightType::Point
    {
        decay: 1.0,
        distance: 50.0,
        shadow: component::OptionalLocalShadow::NoCast{},
    }, 
    intensity: 0.0
);