pub struct InputComponent {
pub speed: f32,
}Expand description
Input component that responds to keyboard input (WASD).
Fields§
§speed: f32Implementations§
Source§impl InputComponent
impl InputComponent
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/example_util/mod.rs (line 37)
15pub fn spawn_mms_demo_rig(
16 universe: &mut engine::Universe,
17 cam_pos: [f32; 3],
18) -> engine::ecs::ComponentId {
19 use engine::ecs::component::{
20 BackgroundColorComponent, Camera3DComponent, InputComponent, InputTransformModeComponent,
21 TransformComponent,
22 };
23
24 // Dark blue clear colour.
25 let bg_color = universe
26 .world
27 .add_component(BackgroundColorComponent::new());
28 let bg_color_c = universe
29 .world
30 .add_component(ColorComponent::rgba(0.02, 0.03, 0.10, 1.0));
31 let _ = universe.world.add_child(bg_color, bg_color_c);
32 universe.add(bg_color);
33
34 // Camera rig: Input → Transform → Camera3D.
35 let input = universe
36 .world
37 .add_component(InputComponent::new().with_speed(3.0));
38 let input_mode = universe
39 .world
40 .add_component(InputTransformModeComponent::forward_z().with_roll_axis_y());
41 let _ = universe.attach(input, input_mode);
42
43 let cam_transform = universe
44 .world
45 .add_component(TransformComponent::new().with_position(cam_pos[0], cam_pos[1], cam_pos[2]));
46 let _ = universe.attach(input, cam_transform);
47
48 let camera = universe.world.add_component(Camera3DComponent::new());
49 let _ = universe.attach(cam_transform, camera);
50
51 universe.add(input);
52
53 spawn_desktop_camera_controls_hint(universe, cam_transform);
54
55 cam_transform
56}More examples
examples/simple-demo.rs (line 56)
6fn build_demo_scene_7_shapes(universe: &mut engine::Universe) {
7 use engine::ecs::component::{
8 Camera3DComponent, ColorComponent, EmissiveComponent, GLTFComponent, InputComponent,
9 InputTransformModeComponent, PointLightComponent, RenderableComponent, TextureComponent,
10 TransformComponent,
11 };
12 use engine::graphics::BuiltinMeshType;
13 use engine::graphics::primitives::MaterialHandle;
14
15 // Built-in CPU meshes are pre-registered; just fetch stable handles.
16 let tri_mesh = universe.render_assets.get_mesh(BuiltinMeshType::Triangle2D);
17 let square_mesh = universe.render_assets.get_mesh(BuiltinMeshType::Quad2D);
18 let tetra_mesh = universe
19 .render_assets
20 .get_mesh(BuiltinMeshType::Tetrahedron);
21
22 fn spawn(
23 universe: &mut engine::Universe,
24 mesh: engine::graphics::primitives::CpuMeshHandle,
25 x: f32,
26 y: f32,
27 s: f32,
28 r: f32,
29 color: [f32; 4],
30 input_driven: bool,
31 emissive: bool,
32 ) -> engine::ecs::ComponentId {
33 let transform = universe.world.add_component(
34 TransformComponent::new()
35 .with_position(x, y, 0.0)
36 .with_scale(s, s, 1.0)
37 .with_rotation_euler(0.0, 0.0, r),
38 );
39 let renderable = universe.world.add_component(RenderableComponent::new(
40 engine::graphics::primitives::Renderable::new(mesh, MaterialHandle::TOON_MESH),
41 ));
42 let color_c = universe.world.add_component(ColorComponent { rgba: color });
43
44 if emissive {
45 let emissive_c = universe.world.add_component(EmissiveComponent::on());
46 let _ = universe.attach(renderable, emissive_c);
47 }
48
49 // Topology: (optional Input) -> Transform -> Renderable
50 let _ = universe.attach(transform, renderable);
51 let _ = universe.attach(renderable, color_c);
52
53 if input_driven {
54 let input = universe
55 .world
56 .add_component(InputComponent::new().with_speed(0.5));
57 let _ = universe.attach(input, transform);
58 universe.add(input);
59 } else {
60 universe.add(transform);
61 }
62
63 transform
64 }
65
66 fn spawn_3d(
67 universe: &mut engine::Universe,
68 mesh: engine::graphics::primitives::CpuMeshHandle,
69 x: f32,
70 y: f32,
71 z: f32,
72 s: f32,
73 rx: f32,
74 ry: f32,
75 rz: f32,
76 color: [f32; 4],
77 ) -> engine::ecs::ComponentId {
78 let transform = universe.world.add_component(
79 TransformComponent::new()
80 .with_position(x, y, z)
81 .with_scale(s, s, s)
82 .with_rotation_euler(rx, ry, rz),
83 );
84 let renderable = universe.world.add_component(RenderableComponent::new(
85 engine::graphics::primitives::Renderable::new(mesh, MaterialHandle::TOON_MESH),
86 ));
87 let color_c = universe.world.add_component(ColorComponent { rgba: color });
88
89 let _ = universe.attach(transform, renderable);
90 let _ = universe.attach(renderable, color_c);
91 universe.add(transform);
92
93 transform
94 }
95
96 // Spawn shapes.
97 // One triangle is input-driven (WASD/QE). Build a small "rig" so both the triangle
98 // and the camera can be driven by the same InputComponent.
99
100 // Topology: Input -> (InputTransformMode) -> RigTransform -> (CameraTransform -> Camera3D), (TriRootTransform -> ...)
101 let tri_input = universe
102 .world
103 .add_component(InputComponent::new().with_speed(0.5));
104 let input_mode = universe
105 .world
106 .add_component(InputTransformModeComponent::forward_z().with_roll_axis_y());
107 let _ = universe.attach(tri_input, input_mode);
108
109 // Start pulled back so the demo meshes at z=0 are in view.
110 // The camera will be attached directly under this transform, so there is no local
111 // camera offset that would cause orbiting when yawing.
112 let rig_transform = universe
113 .world
114 .add_component(TransformComponent::new().with_position(0.0, 0.0, 2.5));
115 let _ = universe.attach(tri_input, rig_transform);
116
117 // Camera: attached directly to the rig transform.
118 let camera3d = universe.world.add_component(Camera3DComponent::new());
119 let _ = universe.attach(rig_transform, camera3d);
120
121 // Topology: I { T { C3D } } — add a small camera-attached controls hint.
122 example_util::spawn_desktop_camera_controls_hint(universe, rig_transform);
123
124 let tri_root_transform = universe
125 .world
126 .add_component(TransformComponent::new().with_position(0.5, 0.50, 0.0));
127
128 // Visual transform under the root; this is where we apply rotation/scale.
129 let tri_visual_transform = universe.world.add_component(
130 TransformComponent::new()
131 .with_scale(0.30, 0.30, 1.0)
132 .with_rotation_euler(0.0, 0.0, (2.0 * 3.14159 / 3.0) + 3.14159),
133 );
134 let tri_renderable = universe.world.add_component(RenderableComponent::new(
135 engine::graphics::primitives::Renderable::new(tri_mesh, MaterialHandle::TOON_MESH),
136 ));
137 let tri_color = universe
138 .world
139 .add_component(ColorComponent::rgba(0.2, 1.0, 0.2, 1.0));
140
141 let _ = universe.attach(rig_transform, tri_root_transform);
142 let _ = universe.attach(tri_root_transform, tri_visual_transform);
143 let _ = universe.attach(tri_visual_transform, tri_renderable);
144 let _ = universe.attach(tri_renderable, tri_color);
145
146 let tri_light = universe.world.add_component(
147 PointLightComponent::new()
148 .with_distance(10.0)
149 .with_color(1.0, 1.0, 1.0),
150 );
151
152 let light_transform = universe.world.add_component(
153 TransformComponent::new()
154 .with_position(0.5, 0.50, 1.0)
155 .with_scale(0.1, 0.1, 0.1),
156 );
157
158 let _ = universe.attach(light_transform, tri_light);
159
160 universe.add(tri_input);
161 universe.add(light_transform);
162
163 spawn(
164 universe,
165 square_mesh,
166 -0.80,
167 -0.30,
168 0.25,
169 0.0,
170 [1.0, 0.2, 0.2, 1.0],
171 false,
172 true,
173 );
174 spawn(
175 universe,
176 square_mesh,
177 -0.40,
178 -0.30,
179 0.25,
180 0.0,
181 [1.0, 0.6, 0.2, 1.0],
182 false,
183 true,
184 );
185
186 // 3D primitive: tetrahedron.
187 spawn_3d(
188 universe,
189 tetra_mesh,
190 0.55,
191 -0.15,
192 0.0,
193 0.35,
194 0.75,
195 0.55,
196 0.0,
197 [0.2, 0.7, 1.0, 1.0],
198 );
199 spawn(
200 universe,
201 square_mesh,
202 0.00,
203 -0.30,
204 0.25,
205 0.0,
206 [1.0, 1.0, 0.2, 1.0],
207 false,
208 true,
209 );
210 spawn(
211 universe,
212 square_mesh,
213 0.40,
214 -0.30,
215 0.25,
216 0.0,
217 [0.2, 0.6, 1.0, 1.0],
218 false,
219 true,
220 );
221 spawn(
222 universe,
223 square_mesh,
224 0.80,
225 -0.30,
226 0.25,
227 0.0,
228 [0.8, 0.2, 1.0, 1.0],
229 false,
230 true,
231 );
232 spawn(
233 universe,
234 tri_mesh,
235 0.30,
236 0.35,
237 0.30,
238 -3.14159,
239 [1.0, 1.0, 1.0, 1.0],
240 false,
241 false,
242 );
243
244 // Textured square.
245 let tex_transform = universe.world.add_component(
246 TransformComponent::new()
247 .with_position(0.0, 0.1, 0.0)
248 .with_scale(0.45, 0.45, 1.0),
249 );
250 let tex_renderable = universe.world.add_component(RenderableComponent::new(
251 engine::graphics::primitives::Renderable::new(square_mesh, MaterialHandle::TOON_MESH),
252 ));
253 let tex_color = universe
254 .world
255 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
256 let tex = universe.world.add_component(TextureComponent::from_dds(
257 "assets/textures/cat-face-amused.dds",
258 ));
259
260 let _ = universe.attach(tex_transform, tex_renderable);
261 let _ = universe.attach(tex_renderable, tex_color);
262 let _ = universe.attach(tex_renderable, tex);
263 universe.add(tex_transform);
264
265 // glTF: color-cat
266 // Attach GLTFComponent under a Transform so GLTFSystem can use it as an anchor.
267 let cat_anchor = universe.world.add_component(
268 TransformComponent::new()
269 .with_position(0.0, -0.10, -4.0)
270 .with_scale(0.50, 0.50, 0.50)
271 .with_rotation_euler(0.0, 0.0, 0.0),
272 );
273 let cat_gltf = universe
274 .world
275 .add_component(GLTFComponent::new("assets/models/color-cat.2.glb"));
276 let _ = universe.attach(cat_anchor, cat_gltf);
277 universe.add(cat_anchor);
278}examples/audio-clip-instance-demo.rs (line 25)
13fn main() {
14 mittens_engine::example_support::ensure_model_assets();
15 utils::logger::init();
16
17 println!("[audio-clip-instance-demo] start");
18
19 let world = engine::ecs::World::default();
20 let mut universe = engine::Universe::new(world);
21
22 // Minimal camera so the window opens.
23 let input = universe
24 .world
25 .add_component(engine::ecs::component::InputComponent::new().with_speed(2.0));
26 let rig = universe.world.add_component(
27 engine::ecs::component::TransformComponent::new().with_position(0.0, 0.0, 3.0),
28 );
29 let input_mode = universe.world.add_component(
30 engine::ecs::component::InputTransformModeComponent::forward_z().with_roll_axis_y(),
31 );
32 let cam = universe
33 .world
34 .add_component(engine::ecs::component::Camera3DComponent::new().with_fov(60.0));
35 let _ = universe.attach(input, input_mode);
36 let _ = universe.attach(input, rig);
37 let _ = universe.attach(rig, cam);
38 universe.add(input);
39
40 let clear = universe
41 .world
42 .add_component(engine::ecs::component::BackgroundColorComponent::new());
43 let clear_c = universe
44 .world
45 .add_component(engine::ecs::component::ColorComponent::rgba(
46 0.06, 0.07, 0.10, 1.0,
47 ));
48 let _ = universe.world.add_child(clear, clear_c);
49 universe.add(clear);
50
51 let source = include_str!("audio-clip-instance-demo.mms");
52 let output = scripting::MeowMeowRunner::eval_with_world_at_path(
53 source,
54 Some("examples/audio-clip-instance-demo.mms"),
55 &mut universe.world,
56 &mut universe.systems.rx,
57 &mut universe.command_queue,
58 );
59
60 for error in &output.errors {
61 eprintln!("[mms] {error}");
62 }
63 println!(
64 "[audio-clip-instance-demo] mms ok: {} intent(s)",
65 output.intents.len()
66 );
67
68 for intent in output.intents {
69 universe
70 .command_queue
71 .push_intent_now(engine::ecs::ComponentId::default(), intent);
72 }
73
74 universe.systems.process_commands(
75 &mut universe.world,
76 &mut universe.visuals,
77 &mut universe.render_assets,
78 &mut universe.command_queue,
79 );
80
81 universe.enable_repl();
82 engine::Windowing::run_app(universe).expect("Windowing failed");
83}examples/audio-music-demo.rs (line 23)
11fn main() {
12 mittens_engine::example_support::ensure_model_assets();
13 utils::logger::init();
14
15 println!("[audio-music-demo] start");
16
17 let world = engine::ecs::World::default();
18 let mut universe = engine::Universe::new(world);
19
20 // Minimal camera so the window opens.
21 let input = universe
22 .world
23 .add_component(engine::ecs::component::InputComponent::new().with_speed(2.0));
24 let rig = universe.world.add_component(
25 engine::ecs::component::TransformComponent::new().with_position(0.0, 0.0, 3.0),
26 );
27 let input_mode = universe.world.add_component(
28 engine::ecs::component::InputTransformModeComponent::forward_z().with_roll_axis_y(),
29 );
30 let cam = universe
31 .world
32 .add_component(engine::ecs::component::Camera3DComponent::new().with_fov(60.0));
33 let _ = universe.attach(input, input_mode);
34 let _ = universe.attach(input, rig);
35 let _ = universe.attach(rig, cam);
36 universe.add(input);
37
38 // Dim clear color so console output stays readable in case of errors.
39 let clear = universe
40 .world
41 .add_component(engine::ecs::component::BackgroundColorComponent::new());
42 let clear_c = universe
43 .world
44 .add_component(engine::ecs::component::ColorComponent::rgba(
45 0.06, 0.07, 0.10, 1.0,
46 ));
47 let _ = universe.world.add_child(clear, clear_c);
48 universe.add(clear);
49
50 let source = include_str!("audio-music-demo.mms");
51 let output = scripting::MeowMeowRunner::eval_with_world_at_path(
52 source,
53 Some("examples/audio-music-demo.mms"),
54 &mut universe.world,
55 &mut universe.systems.rx,
56 &mut universe.command_queue,
57 );
58
59 for error in &output.errors {
60 eprintln!("[mms] {error}");
61 }
62 println!(
63 "[audio-music-demo] mms ok: {} intent(s)",
64 output.intents.len()
65 );
66
67 for intent in output.intents {
68 universe
69 .command_queue
70 .push_intent_now(engine::ecs::ComponentId::default(), intent);
71 }
72
73 universe.systems.process_commands(
74 &mut universe.world,
75 &mut universe.visuals,
76 &mut universe.render_assets,
77 &mut universe.command_queue,
78 );
79
80 universe.enable_repl();
81 engine::Windowing::run_app(universe).expect("Windowing failed");
82}examples/opacity-example.rs (line 401)
359fn main() {
360 mittens_engine::example_support::ensure_model_assets();
361 utils::logger::init();
362
363 let world = engine::ecs::World::default();
364 let mut universe = engine::Universe::new(world);
365
366 // Dark brown / pink background.
367 let bg = universe
368 .world
369 .add_component(BackgroundColorComponent::new());
370 let bg_c = universe
371 .world
372 .add_component(ColorComponent::rgba(0.22, 0.08, 0.10, 1.0));
373 let _ = universe.world.add_child(bg, bg_c);
374 universe.add(bg);
375
376 // Ambient so unlit areas aren't black.
377 let ambient = universe
378 .world
379 .add_component(AmbientLightComponent::rgb(0.35, 0.35, 0.40));
380 universe.add(ambient);
381
382 // A bright overhead light.
383 let light_t = universe.world.add_component(
384 TransformComponent::new()
385 .with_position(0.0, 18.0, 10.0)
386 .with_scale(0.2, 0.2, 0.2),
387 );
388 let light = universe.world.add_component(
389 PointLightComponent::new()
390 .with_color(1.0, 1.0, 1.0)
391 .with_intensity(1.6)
392 .with_distance(80.0),
393 );
394 let _ = universe.attach(light_t, light);
395 universe.add(light_t);
396
397 // --- Camera rig ---
398 // I { T { C3D { with_fps_rotation with_roll_axis_y } } }
399 let input = universe
400 .world
401 .add_component(InputComponent::new().with_speed(3.0));
402 let input_mode = universe.world.add_component(
403 InputTransformModeComponent::forward_z()
404 .with_roll_axis_y()
405 .with_fps_rotation(),
406 );
407 let _ = universe.attach(input, input_mode);
408
409 let rig_transform = universe
410 .world
411 .add_component(TransformComponent::new().with_position(0.0, 6.0, 20.0));
412 let _ = universe.attach(input, rig_transform);
413
414 let camera = universe.world.add_component(Camera3DComponent::new());
415 let _ = universe.attach(rig_transform, camera);
416
417 // Topology: I { T { C3D } } — add a small camera-attached controls hint.
418 example_util::spawn_desktop_camera_controls_hint(&mut universe, rig_transform);
419
420 universe.add(input);
421
422 // --- Ground ---
423 let ground = universe.world.add_component(
424 TransformComponent::new()
425 .with_position(0.0, -0.6, 0.0)
426 .with_scale(60.0, 1.0, 60.0),
427 );
428 let ground_r = universe.world.add_component(RenderableComponent::cube());
429 let ground_c = universe
430 .world
431 .add_component(ColorComponent::rgba(0.95, 0.95, 0.95, 1.0));
432 let _ = universe.attach(ground, ground_r);
433 let _ = universe.attach(ground_r, ground_c);
434 universe.add(ground);
435
436 // --- Opaque yellow cubes behind (contrast reference) ---
437 for i in 0..6 {
438 let x = -10.0 + i as f32 * 4.0;
439 spawn_cube(
440 &mut universe,
441 ground,
442 (x, 1.2, -18.0),
443 (2.0, 2.0, 2.0),
444 Some((1.0, 0.92, 0.15, 1.0)),
445 None,
446 );
447 }
448
449 // --- Demo spots ---
450 // Left of the left big spot: a single-layer transparent XY plane (16x16).
451 spawn_demo_xy_plane(&mut universe, (-14.0, 0.0, 0.0), 0.50, 16, 16, 0.0);
452
453 // Big spots: 8x8x8
454 // Left: single-layer transparent (instanced)
455 spawn_demo_spot(&mut universe, (-4.0, 0.0, 0.0), 0.50, false, 8);
456
457 // Right: multi-layer transparent (sorted)
458 spawn_demo_spot(&mut universe, (4.0, 0.0, 0.0), 0.50, true, 8);
459
460 // Small spots: opaque 1x4 strip + transparent 1x4 strip (along Z).
461 spawn_demo_strip_pair(&mut universe, (-4.0, 0.0, 10.0), false);
462 spawn_demo_strip_pair(&mut universe, (4.0, 0.0, 10.0), true);
463
464 // Process init-time registrations.
465 universe.systems.process_commands(
466 &mut universe.world,
467 &mut universe.visuals,
468 &mut universe.render_assets,
469 &mut universe.command_queue,
470 );
471
472 universe.enable_repl();
473
474 engine::Windowing::run_app(universe).expect("Windowing failed");
475}examples/pointer-events.rs (line 390)
349fn main() {
350 mittens_engine::example_support::ensure_model_assets();
351 utils::logger::init();
352
353 let world = engine::ecs::World::default();
354 let mut universe = engine::Universe::new(world);
355
356 use engine::ecs::component::{
357 AmbientLightComponent, BackgroundColorComponent, Camera3DComponent, ColorComponent,
358 DirectionalLightComponent, InputComponent, InputTransformModeComponent, PointerComponent,
359 TransformComponent,
360 };
361
362 // Background.
363 let bg = universe
364 .world
365 .add_component(BackgroundColorComponent::new());
366 let bg_c = universe
367 .world
368 .add_component(ColorComponent::rgba(0.12, 0.12, 0.16, 1.0));
369 let _ = universe.world.add_child(bg, bg_c);
370 universe.add(bg);
371
372 // Lighting.
373 let ambient = universe
374 .world
375 .add_component(AmbientLightComponent::rgb(0.30, 0.30, 0.32));
376 universe.add(ambient);
377
378 let sun_t = universe
379 .world
380 .add_component(TransformComponent::new().with_position(2.0, 4.0, 3.0));
381 let sun = universe
382 .world
383 .add_component(DirectionalLightComponent::new());
384 let _ = universe.attach(sun_t, sun);
385 universe.add(sun_t);
386
387 // Camera + pointer rig.
388 let input = universe
389 .world
390 .add_component(InputComponent::new().with_speed(3.0));
391 let input_mode = universe.world.add_component(
392 InputTransformModeComponent::forward_z()
393 .with_fps_rotation()
394 .with_roll_axis_y(),
395 );
396 let _ = universe.attach(input, input_mode);
397
398 let cam_t = universe
399 .world
400 .add_component(TransformComponent::new().with_position(0.0, 0.5, 4.5));
401 let cam = universe
402 .world
403 .add_component(Camera3DComponent::new().with_fov(70.0));
404 let pointer = universe.world.add_component(PointerComponent::new());
405
406 let _ = universe.attach(input, cam_t);
407 let _ = universe.attach(cam_t, cam);
408 let _ = universe.attach(cam, pointer);
409
410 example_util::spawn_desktop_camera_controls_hint(&mut universe, cam_t);
411 universe.add(input);
412
413 // Scene root for all interactive objects.
414 let scene = universe.world.add_component(TransformComponent::new());
415 universe.add(scene);
416
417 // --- LEFT: click-only cubes ---
418 let click_group = universe
419 .world
420 .add_component(TransformComponent::new().with_position(-2.2, 0.0, 0.0));
421 let _ = universe.attach(scene, click_group);
422
423 for (i, dy) in [-0.55_f32, 0.0, 0.55].iter().enumerate() {
424 spawn_click_cube(&mut universe, click_group, [0.0, *dy, 0.0]);
425 let _ = i;
426 }
427 spawn_label(
428 &mut universe,
429 click_group,
430 [-0.25, -1.05, 0.0],
431 "click\ncycles color",
432 );
433
434 // --- MID: drag-only cube ---
435 let drag_cube_root = universe
436 .world
437 .add_component(TransformComponent::new().with_position(0.0, 0.0, 0.0));
438 let _ = universe.attach(scene, drag_cube_root);
439
440 spawn_drag_cube(
441 &mut universe,
442 drag_cube_root,
443 [0.0, 0.0, 0.0],
444 [0.35, 0.85, 0.55, 1.0],
445 );
446 spawn_label(
447 &mut universe,
448 drag_cube_root,
449 [-0.25, -0.80, 0.0],
450 "drag\nto move",
451 );
452
453 // --- RIGHT: drag + click cube ---
454 let both_root = universe
455 .world
456 .add_component(TransformComponent::new().with_position(2.2, 0.0, 0.0));
457 let _ = universe.attach(scene, both_root);
458
459 spawn_both_cube(&mut universe, both_root, [0.0, 0.0, 0.0]);
460 spawn_label(
461 &mut universe,
462 both_root,
463 [-0.30, -0.80, 0.0],
464 "drag to move\nclick for color",
465 );
466
467 universe.systems.process_commands(
468 &mut universe.world,
469 &mut universe.visuals,
470 &mut universe.render_assets,
471 &mut universe.command_queue,
472 );
473
474 universe.enable_repl();
475 engine::Windowing::run_app(universe).expect("Windowing failed");
476}Additional examples can be found in:
- examples/text-animation.rs
- examples/button-press.rs
- examples/vtuber-example.rs
- examples/openxr.rs
- examples/transparent-cutout-example.rs
- examples/text-example.rs
- examples/gestures-and-gizmos.rs
- examples/background-example.rs
- examples/mesh-factory-example.rs
- examples/background-occlusion-example.rs
- examples/raycast-topology-animation.rs
- examples/animation-for-topology.rs
- examples/vr-input.rs
- examples/font-example.rs
- examples/vtuber-joints-example.rs
- examples/animation-example.rs
- examples/folder-text.rs
- examples/collision-perimeter.rs
- examples/audio-graph-example.rs
- examples/gravity-fields.rs
Sourcepub fn with_speed(self, speed: f32) -> Self
pub fn with_speed(self, speed: f32) -> Self
Examples found in repository?
examples/example_util/mod.rs (line 37)
15pub fn spawn_mms_demo_rig(
16 universe: &mut engine::Universe,
17 cam_pos: [f32; 3],
18) -> engine::ecs::ComponentId {
19 use engine::ecs::component::{
20 BackgroundColorComponent, Camera3DComponent, InputComponent, InputTransformModeComponent,
21 TransformComponent,
22 };
23
24 // Dark blue clear colour.
25 let bg_color = universe
26 .world
27 .add_component(BackgroundColorComponent::new());
28 let bg_color_c = universe
29 .world
30 .add_component(ColorComponent::rgba(0.02, 0.03, 0.10, 1.0));
31 let _ = universe.world.add_child(bg_color, bg_color_c);
32 universe.add(bg_color);
33
34 // Camera rig: Input → Transform → Camera3D.
35 let input = universe
36 .world
37 .add_component(InputComponent::new().with_speed(3.0));
38 let input_mode = universe
39 .world
40 .add_component(InputTransformModeComponent::forward_z().with_roll_axis_y());
41 let _ = universe.attach(input, input_mode);
42
43 let cam_transform = universe
44 .world
45 .add_component(TransformComponent::new().with_position(cam_pos[0], cam_pos[1], cam_pos[2]));
46 let _ = universe.attach(input, cam_transform);
47
48 let camera = universe.world.add_component(Camera3DComponent::new());
49 let _ = universe.attach(cam_transform, camera);
50
51 universe.add(input);
52
53 spawn_desktop_camera_controls_hint(universe, cam_transform);
54
55 cam_transform
56}More examples
examples/simple-demo.rs (line 56)
6fn build_demo_scene_7_shapes(universe: &mut engine::Universe) {
7 use engine::ecs::component::{
8 Camera3DComponent, ColorComponent, EmissiveComponent, GLTFComponent, InputComponent,
9 InputTransformModeComponent, PointLightComponent, RenderableComponent, TextureComponent,
10 TransformComponent,
11 };
12 use engine::graphics::BuiltinMeshType;
13 use engine::graphics::primitives::MaterialHandle;
14
15 // Built-in CPU meshes are pre-registered; just fetch stable handles.
16 let tri_mesh = universe.render_assets.get_mesh(BuiltinMeshType::Triangle2D);
17 let square_mesh = universe.render_assets.get_mesh(BuiltinMeshType::Quad2D);
18 let tetra_mesh = universe
19 .render_assets
20 .get_mesh(BuiltinMeshType::Tetrahedron);
21
22 fn spawn(
23 universe: &mut engine::Universe,
24 mesh: engine::graphics::primitives::CpuMeshHandle,
25 x: f32,
26 y: f32,
27 s: f32,
28 r: f32,
29 color: [f32; 4],
30 input_driven: bool,
31 emissive: bool,
32 ) -> engine::ecs::ComponentId {
33 let transform = universe.world.add_component(
34 TransformComponent::new()
35 .with_position(x, y, 0.0)
36 .with_scale(s, s, 1.0)
37 .with_rotation_euler(0.0, 0.0, r),
38 );
39 let renderable = universe.world.add_component(RenderableComponent::new(
40 engine::graphics::primitives::Renderable::new(mesh, MaterialHandle::TOON_MESH),
41 ));
42 let color_c = universe.world.add_component(ColorComponent { rgba: color });
43
44 if emissive {
45 let emissive_c = universe.world.add_component(EmissiveComponent::on());
46 let _ = universe.attach(renderable, emissive_c);
47 }
48
49 // Topology: (optional Input) -> Transform -> Renderable
50 let _ = universe.attach(transform, renderable);
51 let _ = universe.attach(renderable, color_c);
52
53 if input_driven {
54 let input = universe
55 .world
56 .add_component(InputComponent::new().with_speed(0.5));
57 let _ = universe.attach(input, transform);
58 universe.add(input);
59 } else {
60 universe.add(transform);
61 }
62
63 transform
64 }
65
66 fn spawn_3d(
67 universe: &mut engine::Universe,
68 mesh: engine::graphics::primitives::CpuMeshHandle,
69 x: f32,
70 y: f32,
71 z: f32,
72 s: f32,
73 rx: f32,
74 ry: f32,
75 rz: f32,
76 color: [f32; 4],
77 ) -> engine::ecs::ComponentId {
78 let transform = universe.world.add_component(
79 TransformComponent::new()
80 .with_position(x, y, z)
81 .with_scale(s, s, s)
82 .with_rotation_euler(rx, ry, rz),
83 );
84 let renderable = universe.world.add_component(RenderableComponent::new(
85 engine::graphics::primitives::Renderable::new(mesh, MaterialHandle::TOON_MESH),
86 ));
87 let color_c = universe.world.add_component(ColorComponent { rgba: color });
88
89 let _ = universe.attach(transform, renderable);
90 let _ = universe.attach(renderable, color_c);
91 universe.add(transform);
92
93 transform
94 }
95
96 // Spawn shapes.
97 // One triangle is input-driven (WASD/QE). Build a small "rig" so both the triangle
98 // and the camera can be driven by the same InputComponent.
99
100 // Topology: Input -> (InputTransformMode) -> RigTransform -> (CameraTransform -> Camera3D), (TriRootTransform -> ...)
101 let tri_input = universe
102 .world
103 .add_component(InputComponent::new().with_speed(0.5));
104 let input_mode = universe
105 .world
106 .add_component(InputTransformModeComponent::forward_z().with_roll_axis_y());
107 let _ = universe.attach(tri_input, input_mode);
108
109 // Start pulled back so the demo meshes at z=0 are in view.
110 // The camera will be attached directly under this transform, so there is no local
111 // camera offset that would cause orbiting when yawing.
112 let rig_transform = universe
113 .world
114 .add_component(TransformComponent::new().with_position(0.0, 0.0, 2.5));
115 let _ = universe.attach(tri_input, rig_transform);
116
117 // Camera: attached directly to the rig transform.
118 let camera3d = universe.world.add_component(Camera3DComponent::new());
119 let _ = universe.attach(rig_transform, camera3d);
120
121 // Topology: I { T { C3D } } — add a small camera-attached controls hint.
122 example_util::spawn_desktop_camera_controls_hint(universe, rig_transform);
123
124 let tri_root_transform = universe
125 .world
126 .add_component(TransformComponent::new().with_position(0.5, 0.50, 0.0));
127
128 // Visual transform under the root; this is where we apply rotation/scale.
129 let tri_visual_transform = universe.world.add_component(
130 TransformComponent::new()
131 .with_scale(0.30, 0.30, 1.0)
132 .with_rotation_euler(0.0, 0.0, (2.0 * 3.14159 / 3.0) + 3.14159),
133 );
134 let tri_renderable = universe.world.add_component(RenderableComponent::new(
135 engine::graphics::primitives::Renderable::new(tri_mesh, MaterialHandle::TOON_MESH),
136 ));
137 let tri_color = universe
138 .world
139 .add_component(ColorComponent::rgba(0.2, 1.0, 0.2, 1.0));
140
141 let _ = universe.attach(rig_transform, tri_root_transform);
142 let _ = universe.attach(tri_root_transform, tri_visual_transform);
143 let _ = universe.attach(tri_visual_transform, tri_renderable);
144 let _ = universe.attach(tri_renderable, tri_color);
145
146 let tri_light = universe.world.add_component(
147 PointLightComponent::new()
148 .with_distance(10.0)
149 .with_color(1.0, 1.0, 1.0),
150 );
151
152 let light_transform = universe.world.add_component(
153 TransformComponent::new()
154 .with_position(0.5, 0.50, 1.0)
155 .with_scale(0.1, 0.1, 0.1),
156 );
157
158 let _ = universe.attach(light_transform, tri_light);
159
160 universe.add(tri_input);
161 universe.add(light_transform);
162
163 spawn(
164 universe,
165 square_mesh,
166 -0.80,
167 -0.30,
168 0.25,
169 0.0,
170 [1.0, 0.2, 0.2, 1.0],
171 false,
172 true,
173 );
174 spawn(
175 universe,
176 square_mesh,
177 -0.40,
178 -0.30,
179 0.25,
180 0.0,
181 [1.0, 0.6, 0.2, 1.0],
182 false,
183 true,
184 );
185
186 // 3D primitive: tetrahedron.
187 spawn_3d(
188 universe,
189 tetra_mesh,
190 0.55,
191 -0.15,
192 0.0,
193 0.35,
194 0.75,
195 0.55,
196 0.0,
197 [0.2, 0.7, 1.0, 1.0],
198 );
199 spawn(
200 universe,
201 square_mesh,
202 0.00,
203 -0.30,
204 0.25,
205 0.0,
206 [1.0, 1.0, 0.2, 1.0],
207 false,
208 true,
209 );
210 spawn(
211 universe,
212 square_mesh,
213 0.40,
214 -0.30,
215 0.25,
216 0.0,
217 [0.2, 0.6, 1.0, 1.0],
218 false,
219 true,
220 );
221 spawn(
222 universe,
223 square_mesh,
224 0.80,
225 -0.30,
226 0.25,
227 0.0,
228 [0.8, 0.2, 1.0, 1.0],
229 false,
230 true,
231 );
232 spawn(
233 universe,
234 tri_mesh,
235 0.30,
236 0.35,
237 0.30,
238 -3.14159,
239 [1.0, 1.0, 1.0, 1.0],
240 false,
241 false,
242 );
243
244 // Textured square.
245 let tex_transform = universe.world.add_component(
246 TransformComponent::new()
247 .with_position(0.0, 0.1, 0.0)
248 .with_scale(0.45, 0.45, 1.0),
249 );
250 let tex_renderable = universe.world.add_component(RenderableComponent::new(
251 engine::graphics::primitives::Renderable::new(square_mesh, MaterialHandle::TOON_MESH),
252 ));
253 let tex_color = universe
254 .world
255 .add_component(ColorComponent::rgba(1.0, 1.0, 1.0, 1.0));
256 let tex = universe.world.add_component(TextureComponent::from_dds(
257 "assets/textures/cat-face-amused.dds",
258 ));
259
260 let _ = universe.attach(tex_transform, tex_renderable);
261 let _ = universe.attach(tex_renderable, tex_color);
262 let _ = universe.attach(tex_renderable, tex);
263 universe.add(tex_transform);
264
265 // glTF: color-cat
266 // Attach GLTFComponent under a Transform so GLTFSystem can use it as an anchor.
267 let cat_anchor = universe.world.add_component(
268 TransformComponent::new()
269 .with_position(0.0, -0.10, -4.0)
270 .with_scale(0.50, 0.50, 0.50)
271 .with_rotation_euler(0.0, 0.0, 0.0),
272 );
273 let cat_gltf = universe
274 .world
275 .add_component(GLTFComponent::new("assets/models/color-cat.2.glb"));
276 let _ = universe.attach(cat_anchor, cat_gltf);
277 universe.add(cat_anchor);
278}examples/audio-clip-instance-demo.rs (line 25)
13fn main() {
14 mittens_engine::example_support::ensure_model_assets();
15 utils::logger::init();
16
17 println!("[audio-clip-instance-demo] start");
18
19 let world = engine::ecs::World::default();
20 let mut universe = engine::Universe::new(world);
21
22 // Minimal camera so the window opens.
23 let input = universe
24 .world
25 .add_component(engine::ecs::component::InputComponent::new().with_speed(2.0));
26 let rig = universe.world.add_component(
27 engine::ecs::component::TransformComponent::new().with_position(0.0, 0.0, 3.0),
28 );
29 let input_mode = universe.world.add_component(
30 engine::ecs::component::InputTransformModeComponent::forward_z().with_roll_axis_y(),
31 );
32 let cam = universe
33 .world
34 .add_component(engine::ecs::component::Camera3DComponent::new().with_fov(60.0));
35 let _ = universe.attach(input, input_mode);
36 let _ = universe.attach(input, rig);
37 let _ = universe.attach(rig, cam);
38 universe.add(input);
39
40 let clear = universe
41 .world
42 .add_component(engine::ecs::component::BackgroundColorComponent::new());
43 let clear_c = universe
44 .world
45 .add_component(engine::ecs::component::ColorComponent::rgba(
46 0.06, 0.07, 0.10, 1.0,
47 ));
48 let _ = universe.world.add_child(clear, clear_c);
49 universe.add(clear);
50
51 let source = include_str!("audio-clip-instance-demo.mms");
52 let output = scripting::MeowMeowRunner::eval_with_world_at_path(
53 source,
54 Some("examples/audio-clip-instance-demo.mms"),
55 &mut universe.world,
56 &mut universe.systems.rx,
57 &mut universe.command_queue,
58 );
59
60 for error in &output.errors {
61 eprintln!("[mms] {error}");
62 }
63 println!(
64 "[audio-clip-instance-demo] mms ok: {} intent(s)",
65 output.intents.len()
66 );
67
68 for intent in output.intents {
69 universe
70 .command_queue
71 .push_intent_now(engine::ecs::ComponentId::default(), intent);
72 }
73
74 universe.systems.process_commands(
75 &mut universe.world,
76 &mut universe.visuals,
77 &mut universe.render_assets,
78 &mut universe.command_queue,
79 );
80
81 universe.enable_repl();
82 engine::Windowing::run_app(universe).expect("Windowing failed");
83}examples/audio-music-demo.rs (line 23)
11fn main() {
12 mittens_engine::example_support::ensure_model_assets();
13 utils::logger::init();
14
15 println!("[audio-music-demo] start");
16
17 let world = engine::ecs::World::default();
18 let mut universe = engine::Universe::new(world);
19
20 // Minimal camera so the window opens.
21 let input = universe
22 .world
23 .add_component(engine::ecs::component::InputComponent::new().with_speed(2.0));
24 let rig = universe.world.add_component(
25 engine::ecs::component::TransformComponent::new().with_position(0.0, 0.0, 3.0),
26 );
27 let input_mode = universe.world.add_component(
28 engine::ecs::component::InputTransformModeComponent::forward_z().with_roll_axis_y(),
29 );
30 let cam = universe
31 .world
32 .add_component(engine::ecs::component::Camera3DComponent::new().with_fov(60.0));
33 let _ = universe.attach(input, input_mode);
34 let _ = universe.attach(input, rig);
35 let _ = universe.attach(rig, cam);
36 universe.add(input);
37
38 // Dim clear color so console output stays readable in case of errors.
39 let clear = universe
40 .world
41 .add_component(engine::ecs::component::BackgroundColorComponent::new());
42 let clear_c = universe
43 .world
44 .add_component(engine::ecs::component::ColorComponent::rgba(
45 0.06, 0.07, 0.10, 1.0,
46 ));
47 let _ = universe.world.add_child(clear, clear_c);
48 universe.add(clear);
49
50 let source = include_str!("audio-music-demo.mms");
51 let output = scripting::MeowMeowRunner::eval_with_world_at_path(
52 source,
53 Some("examples/audio-music-demo.mms"),
54 &mut universe.world,
55 &mut universe.systems.rx,
56 &mut universe.command_queue,
57 );
58
59 for error in &output.errors {
60 eprintln!("[mms] {error}");
61 }
62 println!(
63 "[audio-music-demo] mms ok: {} intent(s)",
64 output.intents.len()
65 );
66
67 for intent in output.intents {
68 universe
69 .command_queue
70 .push_intent_now(engine::ecs::ComponentId::default(), intent);
71 }
72
73 universe.systems.process_commands(
74 &mut universe.world,
75 &mut universe.visuals,
76 &mut universe.render_assets,
77 &mut universe.command_queue,
78 );
79
80 universe.enable_repl();
81 engine::Windowing::run_app(universe).expect("Windowing failed");
82}examples/opacity-example.rs (line 401)
359fn main() {
360 mittens_engine::example_support::ensure_model_assets();
361 utils::logger::init();
362
363 let world = engine::ecs::World::default();
364 let mut universe = engine::Universe::new(world);
365
366 // Dark brown / pink background.
367 let bg = universe
368 .world
369 .add_component(BackgroundColorComponent::new());
370 let bg_c = universe
371 .world
372 .add_component(ColorComponent::rgba(0.22, 0.08, 0.10, 1.0));
373 let _ = universe.world.add_child(bg, bg_c);
374 universe.add(bg);
375
376 // Ambient so unlit areas aren't black.
377 let ambient = universe
378 .world
379 .add_component(AmbientLightComponent::rgb(0.35, 0.35, 0.40));
380 universe.add(ambient);
381
382 // A bright overhead light.
383 let light_t = universe.world.add_component(
384 TransformComponent::new()
385 .with_position(0.0, 18.0, 10.0)
386 .with_scale(0.2, 0.2, 0.2),
387 );
388 let light = universe.world.add_component(
389 PointLightComponent::new()
390 .with_color(1.0, 1.0, 1.0)
391 .with_intensity(1.6)
392 .with_distance(80.0),
393 );
394 let _ = universe.attach(light_t, light);
395 universe.add(light_t);
396
397 // --- Camera rig ---
398 // I { T { C3D { with_fps_rotation with_roll_axis_y } } }
399 let input = universe
400 .world
401 .add_component(InputComponent::new().with_speed(3.0));
402 let input_mode = universe.world.add_component(
403 InputTransformModeComponent::forward_z()
404 .with_roll_axis_y()
405 .with_fps_rotation(),
406 );
407 let _ = universe.attach(input, input_mode);
408
409 let rig_transform = universe
410 .world
411 .add_component(TransformComponent::new().with_position(0.0, 6.0, 20.0));
412 let _ = universe.attach(input, rig_transform);
413
414 let camera = universe.world.add_component(Camera3DComponent::new());
415 let _ = universe.attach(rig_transform, camera);
416
417 // Topology: I { T { C3D } } — add a small camera-attached controls hint.
418 example_util::spawn_desktop_camera_controls_hint(&mut universe, rig_transform);
419
420 universe.add(input);
421
422 // --- Ground ---
423 let ground = universe.world.add_component(
424 TransformComponent::new()
425 .with_position(0.0, -0.6, 0.0)
426 .with_scale(60.0, 1.0, 60.0),
427 );
428 let ground_r = universe.world.add_component(RenderableComponent::cube());
429 let ground_c = universe
430 .world
431 .add_component(ColorComponent::rgba(0.95, 0.95, 0.95, 1.0));
432 let _ = universe.attach(ground, ground_r);
433 let _ = universe.attach(ground_r, ground_c);
434 universe.add(ground);
435
436 // --- Opaque yellow cubes behind (contrast reference) ---
437 for i in 0..6 {
438 let x = -10.0 + i as f32 * 4.0;
439 spawn_cube(
440 &mut universe,
441 ground,
442 (x, 1.2, -18.0),
443 (2.0, 2.0, 2.0),
444 Some((1.0, 0.92, 0.15, 1.0)),
445 None,
446 );
447 }
448
449 // --- Demo spots ---
450 // Left of the left big spot: a single-layer transparent XY plane (16x16).
451 spawn_demo_xy_plane(&mut universe, (-14.0, 0.0, 0.0), 0.50, 16, 16, 0.0);
452
453 // Big spots: 8x8x8
454 // Left: single-layer transparent (instanced)
455 spawn_demo_spot(&mut universe, (-4.0, 0.0, 0.0), 0.50, false, 8);
456
457 // Right: multi-layer transparent (sorted)
458 spawn_demo_spot(&mut universe, (4.0, 0.0, 0.0), 0.50, true, 8);
459
460 // Small spots: opaque 1x4 strip + transparent 1x4 strip (along Z).
461 spawn_demo_strip_pair(&mut universe, (-4.0, 0.0, 10.0), false);
462 spawn_demo_strip_pair(&mut universe, (4.0, 0.0, 10.0), true);
463
464 // Process init-time registrations.
465 universe.systems.process_commands(
466 &mut universe.world,
467 &mut universe.visuals,
468 &mut universe.render_assets,
469 &mut universe.command_queue,
470 );
471
472 universe.enable_repl();
473
474 engine::Windowing::run_app(universe).expect("Windowing failed");
475}examples/pointer-events.rs (line 390)
349fn main() {
350 mittens_engine::example_support::ensure_model_assets();
351 utils::logger::init();
352
353 let world = engine::ecs::World::default();
354 let mut universe = engine::Universe::new(world);
355
356 use engine::ecs::component::{
357 AmbientLightComponent, BackgroundColorComponent, Camera3DComponent, ColorComponent,
358 DirectionalLightComponent, InputComponent, InputTransformModeComponent, PointerComponent,
359 TransformComponent,
360 };
361
362 // Background.
363 let bg = universe
364 .world
365 .add_component(BackgroundColorComponent::new());
366 let bg_c = universe
367 .world
368 .add_component(ColorComponent::rgba(0.12, 0.12, 0.16, 1.0));
369 let _ = universe.world.add_child(bg, bg_c);
370 universe.add(bg);
371
372 // Lighting.
373 let ambient = universe
374 .world
375 .add_component(AmbientLightComponent::rgb(0.30, 0.30, 0.32));
376 universe.add(ambient);
377
378 let sun_t = universe
379 .world
380 .add_component(TransformComponent::new().with_position(2.0, 4.0, 3.0));
381 let sun = universe
382 .world
383 .add_component(DirectionalLightComponent::new());
384 let _ = universe.attach(sun_t, sun);
385 universe.add(sun_t);
386
387 // Camera + pointer rig.
388 let input = universe
389 .world
390 .add_component(InputComponent::new().with_speed(3.0));
391 let input_mode = universe.world.add_component(
392 InputTransformModeComponent::forward_z()
393 .with_fps_rotation()
394 .with_roll_axis_y(),
395 );
396 let _ = universe.attach(input, input_mode);
397
398 let cam_t = universe
399 .world
400 .add_component(TransformComponent::new().with_position(0.0, 0.5, 4.5));
401 let cam = universe
402 .world
403 .add_component(Camera3DComponent::new().with_fov(70.0));
404 let pointer = universe.world.add_component(PointerComponent::new());
405
406 let _ = universe.attach(input, cam_t);
407 let _ = universe.attach(cam_t, cam);
408 let _ = universe.attach(cam, pointer);
409
410 example_util::spawn_desktop_camera_controls_hint(&mut universe, cam_t);
411 universe.add(input);
412
413 // Scene root for all interactive objects.
414 let scene = universe.world.add_component(TransformComponent::new());
415 universe.add(scene);
416
417 // --- LEFT: click-only cubes ---
418 let click_group = universe
419 .world
420 .add_component(TransformComponent::new().with_position(-2.2, 0.0, 0.0));
421 let _ = universe.attach(scene, click_group);
422
423 for (i, dy) in [-0.55_f32, 0.0, 0.55].iter().enumerate() {
424 spawn_click_cube(&mut universe, click_group, [0.0, *dy, 0.0]);
425 let _ = i;
426 }
427 spawn_label(
428 &mut universe,
429 click_group,
430 [-0.25, -1.05, 0.0],
431 "click\ncycles color",
432 );
433
434 // --- MID: drag-only cube ---
435 let drag_cube_root = universe
436 .world
437 .add_component(TransformComponent::new().with_position(0.0, 0.0, 0.0));
438 let _ = universe.attach(scene, drag_cube_root);
439
440 spawn_drag_cube(
441 &mut universe,
442 drag_cube_root,
443 [0.0, 0.0, 0.0],
444 [0.35, 0.85, 0.55, 1.0],
445 );
446 spawn_label(
447 &mut universe,
448 drag_cube_root,
449 [-0.25, -0.80, 0.0],
450 "drag\nto move",
451 );
452
453 // --- RIGHT: drag + click cube ---
454 let both_root = universe
455 .world
456 .add_component(TransformComponent::new().with_position(2.2, 0.0, 0.0));
457 let _ = universe.attach(scene, both_root);
458
459 spawn_both_cube(&mut universe, both_root, [0.0, 0.0, 0.0]);
460 spawn_label(
461 &mut universe,
462 both_root,
463 [-0.30, -0.80, 0.0],
464 "drag to move\nclick for color",
465 );
466
467 universe.systems.process_commands(
468 &mut universe.world,
469 &mut universe.visuals,
470 &mut universe.render_assets,
471 &mut universe.command_queue,
472 );
473
474 universe.enable_repl();
475 engine::Windowing::run_app(universe).expect("Windowing failed");
476}Additional examples can be found in:
- examples/text-animation.rs
- examples/button-press.rs
- examples/vtuber-example.rs
- examples/openxr.rs
- examples/transparent-cutout-example.rs
- examples/text-example.rs
- examples/gestures-and-gizmos.rs
- examples/background-example.rs
- examples/mesh-factory-example.rs
- examples/background-occlusion-example.rs
- examples/raycast-topology-animation.rs
- examples/animation-for-topology.rs
- examples/vr-input.rs
- examples/font-example.rs
- examples/vtuber-joints-example.rs
- examples/animation-example.rs
- examples/folder-text.rs
- examples/collision-perimeter.rs
- examples/audio-graph-example.rs
- examples/gravity-fields.rs
Trait Implementations§
Source§impl Clone for InputComponent
impl Clone for InputComponent
Source§fn clone(&self) -> InputComponent
fn clone(&self) -> InputComponent
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Component for InputComponent
impl Component for InputComponent
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
Short debug/type name for this component kind (e.g. “transform”, “camera”).
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Source§fn init(&mut self, emit: &mut dyn SignalEmitter, component: ComponentId)
fn init(&mut self, emit: &mut dyn SignalEmitter, component: ComponentId)
Called when component is added to the World
Source§fn to_mms_ast(&self, _world: &World) -> ComponentExpression
fn to_mms_ast(&self, _world: &World) -> ComponentExpression
Encode this component as an MMS Component Expression AST node. Read more
fn set_id(&mut self, _component: ComponentId)
Source§fn cleanup(&mut self, _emit: &mut dyn SignalEmitter, _component: ComponentId)
fn cleanup(&mut self, _emit: &mut dyn SignalEmitter, _component: ComponentId)
Called when component is removed from the World.
Source§impl Debug for InputComponent
impl Debug for InputComponent
Source§impl Default for InputComponent
impl Default for InputComponent
Source§fn default() -> InputComponent
fn default() -> InputComponent
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for InputComponent
impl RefUnwindSafe for InputComponent
impl Send for InputComponent
impl Sync for InputComponent
impl Unpin for InputComponent
impl UnsafeUnpin for InputComponent
impl UnwindSafe for InputComponent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.