zoom?
Some checks failed
build and test / wxbox - latest (push) Failing after 39m44s
Verify Latest Dependencies / Verify Latest Dependencies (push) Successful in 40m3s

This commit is contained in:
core 2025-03-08 23:51:48 -05:00
parent d2d7395c1c
commit 6dde3660df
Signed by: core
GPG key ID: FDBF740DADDCEECF
5 changed files with 20 additions and 6 deletions

View file

@ -94,7 +94,7 @@
}
}
</style>
<link rel="modulepreload" href="/wxbox-client-e251f7c00cc5a420.js" crossorigin="anonymous" integrity="sha384-nrW4CTzLGI43dYXx4bsCC1MufwwJsv215lOCUjGPlKxUXnaSIj4SO1d9LLavD/iZ"><link rel="preload" href="/wxbox-client-e251f7c00cc5a420_bg.wasm" crossorigin="anonymous" integrity="sha384-71H/wvdZdNWY2giYtEj8Ta0UEF+lv7IaWQGqX39QiAVC/rp5W+XlYsdS4cKT6Byz" as="fetch" type="application/wasm"></head>
<link rel="modulepreload" href="/wxbox-client-432cad19da309f9d.js" crossorigin="anonymous" integrity="sha384-nrW4CTzLGI43dYXx4bsCC1MufwwJsv215lOCUjGPlKxUXnaSIj4SO1d9LLavD/iZ"><link rel="preload" href="/wxbox-client-432cad19da309f9d_bg.wasm" crossorigin="anonymous" integrity="sha384-OaZoP3+dHb0yt+DUsiqidExoGgtMXKSCAZgJw6EqccvkadD8EPCeb0Yct6+3tVBi" as="fetch" type="application/wasm"></head>
<body>
<!-- The WASM code will resize the canvas dynamically -->
@ -111,8 +111,8 @@
<script type="module">
import init, * as bindings from '/wxbox-client-e251f7c00cc5a420.js';
const wasm = await init({ module_or_path: '/wxbox-client-e251f7c00cc5a420_bg.wasm' });
import init, * as bindings from '/wxbox-client-432cad19da309f9d.js';
const wasm = await init({ module_or_path: '/wxbox-client-432cad19da309f9d_bg.wasm' });
window.wasmBindings = bindings;

View file

@ -27,6 +27,7 @@ impl eframe::App for App {
.resizable(false)
.show(ctx, |ui| {
ui.heading("wxbox");
ui.checkbox(&mut self.map.allow_nonint_zoom, "Allow non-integer zoom (broken)?");
});
egui::CentralPanel::default()

View file

@ -19,7 +19,8 @@ pub struct Map {
pub long: f64,
pub zoom: f64,
pub render: Arc<Mutex<MapRender>>,
pub options: ExtraRenderOptions
pub options: ExtraRenderOptions,
pub allow_nonint_zoom: bool
}
impl Map {
@ -32,7 +33,8 @@ impl Map {
zoom: 12.0,
render: Arc::new(Mutex::new(MapRender::new(gl)?)),
options: ExtraRenderOptions {
}
},
allow_nonint_zoom: false
})
}
pub fn process_input(&mut self, ctx: &egui::Context, ui: &mut Ui, rect: Rect, response: egui::Response) {
@ -59,7 +61,18 @@ impl Map {
self.lat += xy_delta.y as f64 * 0.0005;
self.long -= xy_delta.x as f64 * 0.0005;
if !self.allow_nonint_zoom {
if z_delta < 0.0 {
self.zoom -= 1.0;
} else if z_delta > 0.0 {
self.zoom += 1.0;
}
self.zoom = self.zoom.floor();
} else {
self.zoom += z_delta as f64 * 0.01;
}
if self.zoom < 3.0 { self.zoom = 3.0 };
if self.zoom > 19.0 { self.zoom = 19.0 };