Skip to content

Commit fee48d8

Browse files
author
Jakub Hlusička
committed
Handle events; add a global transform
1 parent 8610068 commit fee48d8

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/lib.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ const MODEL_MARKER_BYTES: &'static [u8] = include_bytes!("../resources/ui/sphere
119119
const DIR: FileSystem = include_dir!("resources/showcase");
120120

121121
lazy_static! {
122+
static ref GLOBAL_TRANSFORMATION: Mat4 = Mat4::rotation_yaw(0.0 * std::f32::consts::PI);
122123
static ref MODELS_MAIN_BYTES_SCALE: Vec<(&'static [u8], f32)> = {
123124
let files = DIR.find("**/*_(*).glb")
124125
.expect("Could not traverse the resource directory tree.")
@@ -185,7 +186,6 @@ pub struct Selection {
185186
#[mapp]
186187
pub struct ExampleMapp {
187188
elapsed: Duration,
188-
state: Vec<String>,
189189
command_id_next: usize,
190190
commands: VecDeque<Command>,
191191
view_orientations: Option<Vec<Option<Orientation>>>,
@@ -241,7 +241,6 @@ impl Mapp for ExampleMapp {
241241
fn new() -> Self {
242242
let mut result = Self {
243243
elapsed: Default::default(),
244-
state: Vec::new(),
245244
command_id_next: 0,
246245
commands: VecDeque::new(),
247246
view_orientations: None,
@@ -282,11 +281,6 @@ impl Mapp for ExampleMapp {
282281
result
283282
}
284283

285-
fn test(&mut self, arg: String) -> Vec<String> {
286-
self.state.push(arg);
287-
self.state.clone()
288-
}
289-
290284
fn update(&mut self, elapsed: Duration) {
291285
self.elapsed = elapsed;
292286

@@ -305,7 +299,7 @@ impl Mapp for ExampleMapp {
305299

306300
self.cmd(CommandKind::EntityTransformSet {
307301
entity: entity.unwrap(),
308-
transform: Some(transform),
302+
transform: Some(&*GLOBAL_TRANSFORMATION * transform),
309303
});
310304
}
311305
self.cmd(CommandKind::GetViewOrientation {});
@@ -371,7 +365,7 @@ impl Mapp for ExampleMapp {
371365
});
372366
self.cmd(CommandKind::EntityTransformSet {
373367
entity,
374-
transform: Some(transform),
368+
transform: Some(&*GLOBAL_TRANSFORMATION * transform),
375369
});
376370
},
377371
CommandResponseKind::GetViewOrientation { views_per_medium } => {
@@ -453,7 +447,7 @@ impl Mapp for ExampleMapp {
453447
});
454448
self.cmd(CommandKind::EntityTransformSet {
455449
entity: self.entity_marker.unwrap(),
456-
transform: Some(transform),
450+
transform: Some(&*GLOBAL_TRANSFORMATION * transform),
457451
});
458452

459453
self.ray_tracing_task = None;
@@ -494,6 +488,10 @@ impl Mapp for ExampleMapp {
494488
}
495489
}
496490

491+
fn receive_event(&mut self, event: Event) {
492+
dbg!(event);
493+
}
494+
497495
fn flush_io(&mut self) -> IO {
498496
GLOBAL_IO.flush()
499497
}

0 commit comments

Comments
 (0)