pub mod ambient_light;
pub mod animation;
pub mod asset_payload;
pub mod audio_band_pass_filter;
pub mod audio_buffer_size;
pub mod audio_clip;
pub mod audio_gain;
pub mod audio_high_pass_filter;
pub mod audio_limiter;
pub mod audio_low_pass_filter;
pub mod audio_mix;
pub mod audio_oscillator;
pub mod audio_output;
pub mod avatar_body_yaw;
pub mod avatar_control;
pub mod background;
pub mod background_color;
pub mod bloom;
pub mod blur_pass;
pub mod bone_rest_pose;
pub mod bounds;
pub mod camera_2d;
pub mod camera_3d;
pub mod camera_xr;
pub mod clock;
pub mod collision;
pub mod collision_response;
pub mod collision_shape;
pub mod color;
pub mod component_ref;
pub mod controller_xr;
pub mod data;
pub mod directional_light;
pub mod draggable;
pub mod editor;
pub mod editor_ui;
pub mod emissive;
pub mod emissive_pass;
pub mod fit_bounds;
pub mod gesture_coord_type;
pub mod gizmo;
pub mod gltf;
pub mod grabbable;
pub mod gravity;
pub mod grid;
pub mod html_element;
pub mod http_client;
pub mod http_server;
pub mod ik_chain;
pub mod input;
pub mod input_transform_mode;
pub mod input_xr;
pub mod input_xr_gamepad;
pub mod inspect_layout;
pub mod keyframe;
pub mod layout;
pub mod layout_bounds;
pub mod light_quantization;
pub mod mesh;
pub mod mirror;
pub mod music_note;
pub mod normal_visualisation;
pub mod opacity;
pub mod option;
pub mod overlay;
pub mod pose_capture;
pub mod render_graph;
pub mod router;
pub mod scrolling;
pub mod secondary_motion;
pub mod selectable;
pub mod selection;
pub mod serialize;
pub mod signal_observer_router;
pub mod signal_route_upward;
pub mod skinned_mesh;
pub mod stencil_clip;
pub mod style;
pub mod transparent_cutout;
pub mod xr;
pub mod point_light;
pub mod pointer;
pub mod raycast;
pub mod raycastable;
pub mod raycastable_shape;
pub mod renderable;
pub mod renderer_settings;
pub mod renderer_stats;
pub mod spot_light;
pub mod text;
pub mod text_input;
pub mod text_shadow;
pub mod texture;
pub mod texture_filtering;
pub mod toggle;
pub mod transform;
pub mod transform_camera_specific;
pub mod transform_parent;
pub mod transform_pipeline;
pub mod transform_pipeline_map;
pub mod transform_temporal_filter;
pub mod transition;
pub mod uv;
pub use self::gltf::GLTFComponent;
pub use crate::engine::ecs::system::model::collision_types::{CollisionMode, CollisionShape};
pub use ambient_light::AmbientLightComponent;
pub use animation::AnimationComponent;
pub use animation::AnimationState;
pub use asset_payload::AssetPayloadComponent;
pub use audio_band_pass_filter::*;
pub use audio_buffer_size::AudioBufferSizeComponent;
pub use audio_clip::{AudioClipComponent, AudioClipLoadState, AudioTriggerMode};
pub use audio_gain::*;
pub use audio_high_pass_filter::*;
pub use audio_limiter::*;
pub use audio_low_pass_filter::*;
pub use audio_mix::AudioMixComponent;
pub use audio_oscillator::{AudioOscillator, AudioOscillatorComponent, OscillatorType};
pub use audio_output::AudioOutputComponent;
pub use avatar_body_yaw::AvatarBodyYawComponent;
pub use avatar_control::AvatarControlComponent;
pub use background::BackgroundComponent;
pub use background_color::BackgroundColorComponent;
pub use bloom::BloomComponent;
pub use blur_pass::BlurPassComponent;
pub use bone_rest_pose::BoneRestPoseComponent;
pub use bounds::BoundsComponent;
pub use camera_2d::Camera2DComponent;
pub use camera_3d::Camera3DComponent;
pub use camera_xr::CameraXRComponent;
pub use clock::ClockComponent;
pub use collision::CollisionComponent;
pub use collision_response::{CollisionResponseComponent, CollisionResponseMode};
pub use collision_shape::CollisionShapeComponent;
pub use color::ColorComponent;
pub use component_ref::{
ComponentRef, QueryRootMode, ScopedQuery, parse_scoped_query, resolve_component_ref,
resolve_scoped_query,
};
pub use controller_xr::{ControllerHand, ControllerPoseKind, ControllerXRComponent};
pub use data::{DataComponent, DataEntry, DataValue};
pub use directional_light::DirectionalLightComponent;
pub use draggable::{DraggableComponent, DraggablePlane};
pub use editor::EditorComponent;
pub use editor::EditorInteractionMode;
pub use editor::TransformGizmoCoordSpace;
pub use editor_ui::{
EditorPanel, EditorUIComponent, EditorUIPanelConfig, EditorUIPanelSpec, SettingsPanelConfig,
};
pub use emissive::EmissiveComponent;
pub use emissive_pass::EmissivePassComponent;
pub use fit_bounds::{FitBoundsComponent, FitBoundsMode, FitBoundsTarget};
pub use gesture_coord_type::{GestureCoordType, GestureCoordTypeComponent};
pub use gizmo::{
TransformGizmoAxis, TransformGizmoComponent, TransformGizmoRotateComponent,
TransformGizmoScaleComponent, TransformGizmoTranslateComponent,
};
pub use grabbable::GrabbableComponent;
pub use gravity::GravityComponent;
pub use grid::GridComponent;
pub use html_element::{ElementType, HtmlElementComponent};
pub use http_client::HttpClientComponent;
pub use http_server::HttpServerComponent;
pub use ik_chain::{IKChainComponent, IKSolver};
pub use input::InputComponent;
pub use input_transform_mode::{ForwardAxis, InputTransformModeComponent, RollAxis};
pub use input_xr::InputXRComponent;
pub use input_xr_gamepad::{
InputXRGamepadComponent, XrAxisControl, XrButtonControl, XrHandPreference,
};
pub use inspect_layout::InspectLayoutComponent;
pub use keyframe::KeyframeComponent;
pub use layout::LayoutComponent;
pub use layout_bounds::LayoutBoundsComponent;
pub use light_quantization::LightQuantizationComponent;
pub use mesh::MeshComponent;
pub use mirror::MirrorComponent;
pub(crate) use music_note::NotePitch;
pub use music_note::{MusicNote, MusicNoteComponent};
pub use normal_visualisation::NormalVisualisationComponent;
pub use opacity::OpacityComponent;
pub use option::OptionComponent;
pub use overlay::OverlayComponent;
pub use point_light::PointLightComponent;
pub use pointer::PointerComponent;
pub use pose_capture::*;
pub use raycast::{RayCastComponent, RayCastMode};
pub use raycastable::{PointerEvents, RaycastableComponent};
pub use raycastable_shape::{RaycastableShapeComponent, RaycastableShapeType};
pub use render_graph::RenderGraphComponent;
pub use renderable::RenderableComponent;
pub use renderer_settings::RendererSettingsComponent;
pub use renderer_stats::RendererStatsComponent;
pub use router::RouterComponent;
pub use scrolling::ScrollingComponent;
pub use secondary_motion::{
SecondaryMotionComponent, SpringBoneComponent, SpringColliderComponent,
SpringCollidersComponent, SpringJointComponent, export_secondary_motion_sidecar,
};
pub use selectable::SelectableComponent;
pub use selection::{SelectionComponent, SelectionEntry, SelectionMode};
pub use serialize::SerializeComponent;
pub use signal_observer_router::SignalObserverRouterComponent;
pub use signal_route_upward::SignalRouteUpwardComponent;
pub use skinned_mesh::SkinnedMeshComponent;
pub use spot_light::SpotLightComponent;
pub use stencil_clip::StencilClipComponent;
pub use style::{
AlignItems, BoxSizing, Display, EdgeInsets, FlexDirection, FlexWrap, JustifyContent, Overflow,
Position, SizeDimension, StyleComponent, StylePatch, TextAlign, WordWrapMode,
};
pub use text::TextComponent;
pub use text_input::{TextInputComponent, TextInputGlyphHitComponent};
pub use text_shadow::TextShadowComponent;
pub use texture::{CatEngineTextureFormat, TextureComponent};
pub use texture_filtering::TextureFilteringComponent;
pub use toggle::ToggleComponent;
pub use transform::TransformComponent;
pub use transform_camera_specific::{
TransformCameraSpecificComponent, TransformCameraSpecificMode,
};
pub use transform_parent::TransformParentComponent;
pub use transform_pipeline::{
TransformDropComponent, TransformForkTRSComponent, TransformMergeTRSComponent,
TransformSampleAncestorComponent,
};
pub use transform_pipeline_map::{
TransformMapRotationComponent, TransformMapScaleComponent, TransformMapTranslationComponent,
};
pub use transform_temporal_filter::{
QuatExtractYawComponent, QuatTemporalFilterComponent, QuatYawFollowComponent,
Vector3TemporalFilterComponent,
};
pub use transition::{TransitionComponent, TransitionEasing, TransitionReplacePolicy};
pub use transparent_cutout::TransparentCutoutComponent;
pub use uv::UVComponent;
pub use xr::XrComponent;
pub type XRHandComponent = ControllerXRComponent;
pub type LightComponent = point_light::PointLightComponent;
pub struct ComponentNode {
pub guid: uuid::Uuid,
pub component_type: String,
pub name: String,
pub classes: Vec<String>,
pub component: Box<dyn Component>,
pub parent: Option<crate::engine::ecs::ComponentId>,
pub children: Vec<crate::engine::ecs::ComponentId>,
pub initialized: bool,
}
impl ComponentNode {
pub fn new(component: Box<dyn Component>) -> Self {
let component_type = component.name().to_string();
Self {
guid: uuid::Uuid::new_v4(),
component_type,
name: String::new(),
classes: Vec::new(),
component,
parent: None,
children: Vec::new(),
initialized: false,
}
}
pub fn new_named(name: impl Into<String>, component: Box<dyn Component>) -> Self {
let component_type = component.name().to_string();
Self {
guid: uuid::Uuid::new_v4(),
component_type,
name: name.into(),
classes: Vec::new(),
component,
parent: None,
children: Vec::new(),
initialized: false,
}
}
pub fn new_with_guid_named(
guid: uuid::Uuid,
name: impl Into<String>,
component: Box<dyn Component>,
) -> Self {
let component_type = component.name().to_string();
Self {
guid,
component_type,
name: name.into(),
classes: Vec::new(),
component,
parent: None,
children: Vec::new(),
initialized: false,
}
}
}
pub trait Component: std::any::Any {
fn as_any(&self) -> &dyn std::any::Any;
fn as_any_mut(&mut self) -> &mut dyn std::any::Any;
fn name(&self) -> &'static str;
fn set_id(&mut self, _component: crate::engine::ecs::ComponentId) {}
fn init(
&mut self,
_emit: &mut dyn crate::engine::ecs::SignalEmitter,
_component: crate::engine::ecs::ComponentId,
) {
}
fn cleanup(
&mut self,
_emit: &mut dyn crate::engine::ecs::SignalEmitter,
_component: crate::engine::ecs::ComponentId,
) {
}
fn encode(&self) -> std::collections::HashMap<String, serde_json::Value> {
std::collections::HashMap::new()
}
fn decode(
&mut self,
_data: &std::collections::HashMap<String, serde_json::Value>,
) -> Result<(), String> {
Ok(())
}
fn to_mms_ast(
&self,
_world: &crate::engine::ecs::World,
) -> crate::scripting::ast::ComponentExpression {
crate::scripting::ast::ComponentExpression {
component_type: crate::scripting::ast::Ident(self.name().to_string()),
constructors: Vec::new(),
body: crate::scripting::ast::BlockStatement {
statements: Vec::new(),
},
}
}
}
pub mod ce_helpers {
use crate::scripting::ast::{
BlockStatement, ComponentExpression, ConstructorCall, Expression, Ident, UnaryOpKind,
};
pub fn ce(type_name: &str) -> ComponentExpression {
ComponentExpression {
component_type: Ident(type_name.to_string()),
constructors: Vec::new(),
body: BlockStatement {
statements: Vec::new(),
},
}
}
pub fn ce_call(type_name: &str, method: &str, args: Vec<Expression>) -> ComponentExpression {
ComponentExpression {
component_type: Ident(type_name.to_string()),
constructors: vec![ConstructorCall {
method: Ident(method.to_string()),
args,
}],
body: BlockStatement {
statements: Vec::new(),
},
}
}
pub trait CeBuilder {
fn with_call(self, method: &str, args: Vec<Expression>) -> Self;
}
impl CeBuilder for ComponentExpression {
fn with_call(mut self, method: &str, args: Vec<Expression>) -> Self {
self.constructors.push(ConstructorCall {
method: Ident(method.to_string()),
args,
});
self
}
}
pub fn num(n: f64) -> Expression {
if n < 0.0 {
Expression::UnaryOp {
op: UnaryOpKind::Neg,
operand: Box::new(Expression::Number(-n)),
}
} else {
Expression::Number(n)
}
}
pub fn nums<I: IntoIterator<Item = f64>>(values: I) -> Vec<Expression> {
values.into_iter().map(num).collect()
}
pub fn s(text: &str) -> Expression {
Expression::String(text.to_string())
}
pub fn b(value: bool) -> Expression {
Expression::Bool(value)
}
pub fn ident(name: &str) -> Expression {
Expression::Identifier(Ident(name.to_string()))
}
pub fn array(items: Vec<Expression>) -> Expression {
Expression::Array(items)
}
pub fn ls<I: IntoIterator<Item = S>, S: AsRef<str>>(values: I) -> Expression {
Expression::Array(values.into_iter().map(|v| s(v.as_ref())).collect())
}
}