zoom?
This commit is contained in:
parent
d2d7395c1c
commit
6dde3660df
5 changed files with 20 additions and 6 deletions
6
crates/client/dist/index.html
vendored
6
crates/client/dist/index.html
vendored
|
@ -94,7 +94,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</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>
|
<body>
|
||||||
<!-- The WASM code will resize the canvas dynamically -->
|
<!-- The WASM code will resize the canvas dynamically -->
|
||||||
|
@ -111,8 +111,8 @@
|
||||||
|
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import init, * as bindings from '/wxbox-client-e251f7c00cc5a420.js';
|
import init, * as bindings from '/wxbox-client-432cad19da309f9d.js';
|
||||||
const wasm = await init({ module_or_path: '/wxbox-client-e251f7c00cc5a420_bg.wasm' });
|
const wasm = await init({ module_or_path: '/wxbox-client-432cad19da309f9d_bg.wasm' });
|
||||||
|
|
||||||
|
|
||||||
window.wasmBindings = bindings;
|
window.wasmBindings = bindings;
|
||||||
|
|
Binary file not shown.
|
@ -27,6 +27,7 @@ impl eframe::App for App {
|
||||||
.resizable(false)
|
.resizable(false)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
ui.heading("wxbox");
|
ui.heading("wxbox");
|
||||||
|
ui.checkbox(&mut self.map.allow_nonint_zoom, "Allow non-integer zoom (broken)?");
|
||||||
});
|
});
|
||||||
|
|
||||||
egui::CentralPanel::default()
|
egui::CentralPanel::default()
|
||||||
|
|
|
@ -19,7 +19,8 @@ pub struct Map {
|
||||||
pub long: f64,
|
pub long: f64,
|
||||||
pub zoom: f64,
|
pub zoom: f64,
|
||||||
pub render: Arc<Mutex<MapRender>>,
|
pub render: Arc<Mutex<MapRender>>,
|
||||||
pub options: ExtraRenderOptions
|
pub options: ExtraRenderOptions,
|
||||||
|
pub allow_nonint_zoom: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Map {
|
impl Map {
|
||||||
|
@ -32,7 +33,8 @@ impl Map {
|
||||||
zoom: 12.0,
|
zoom: 12.0,
|
||||||
render: Arc::new(Mutex::new(MapRender::new(gl)?)),
|
render: Arc::new(Mutex::new(MapRender::new(gl)?)),
|
||||||
options: ExtraRenderOptions {
|
options: ExtraRenderOptions {
|
||||||
}
|
},
|
||||||
|
allow_nonint_zoom: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn process_input(&mut self, ctx: &egui::Context, ui: &mut Ui, rect: Rect, response: egui::Response) {
|
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.lat += xy_delta.y as f64 * 0.0005;
|
||||||
self.long -= xy_delta.x 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;
|
self.zoom += z_delta as f64 * 0.01;
|
||||||
|
}
|
||||||
|
|
||||||
if self.zoom < 3.0 { self.zoom = 3.0 };
|
if self.zoom < 3.0 { self.zoom = 3.0 };
|
||||||
if self.zoom > 19.0 { self.zoom = 19.0 };
|
if self.zoom > 19.0 { self.zoom = 19.0 };
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue