Skip to content

Commit

Permalink
目立つ機能も追加
Browse files Browse the repository at this point in the history
  • Loading branch information
mitoma committed Oct 19, 2024
1 parent 9da3f17 commit a6f9179
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
15 changes: 15 additions & 0 deletions sample_codes/showcase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ pub fn change_theme_light() {
));
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen)]
pub fn zoom_in() {
send_action(Action::new_command("world", "forward"));
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen)]
pub fn zoom_out() {
send_action(Action::new_command("world", "back"));
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen)]
pub fn toggle_psychedelic() {
send_action(Action::new_command("world", "toggle-psychedelic"));
}

#[cfg_attr(target_arch = "wasm32", wasm_bindgen)]
pub fn send_log(message: &str) {
log::warn!("{}", message);
Expand Down
16 changes: 15 additions & 1 deletion site/src/showcase.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ Click area and edit it!
<input id="dark-mode-button" type="button" value="Dark mode"></input>
<input id="light-mode-button" type="button" value="Light mode"></input>

<input id="zoom-in-button" type="button" value="Zoom In"></input>
<input id="zoom-out-button" type="button" value="Zoom Out"></input>

<input id="psychedelic-mode-button" type="button" value="TOGGLE PSYCHEDELIC MODE"></input>

<script type="module">
import init, { send_log, toggle_direction, look_current_and_centering, change_theme_dark, change_theme_light } from "./wasm/showcase/showcase.js";
import init, { send_log, toggle_direction, look_current_and_centering, change_theme_dark, change_theme_light, zoom_in, zoom_out, toggle_psychedelic } from "./wasm/showcase/showcase.js";
init().then(() => {
console.log("WASM Loaded");
send_log("Hello from JS");
Expand All @@ -27,6 +32,15 @@ Click area and edit it!
document.getElementById("light-mode-button").addEventListener("click", () => {
change_theme_light();
});
document.getElementById("zoom-in-button").addEventListener("click", () => {
zoom_in();
});
document.getElementById("zoom-out-button").addEventListener("click", () => {
zoom_out();
});
document.getElementById("psychedelic-mode-button").addEventListener("click", () => {
toggle_psychedelic();
});
});
</script>

Expand Down

0 comments on commit a6f9179

Please sign in to comment.