zoom?
Some checks failed
Verify Latest Dependencies / Verify Latest Dependencies (push) Has been cancelled
build and test / wxbox - latest (push) Has been cancelled

This commit is contained in:
core 2025-03-08 23:44:02 -05:00
parent 01637895b6
commit d2d7395c1c
Signed by: core
GPG key ID: FDBF740DADDCEECF
5 changed files with 25 additions and 19 deletions

View file

@ -94,7 +94,7 @@
} }
} }
</style> </style>
<link rel="modulepreload" href="/wxbox-client-43bdf179bb0c5f46.js" crossorigin="anonymous" integrity="sha384-KUIh+urSU4nqO6N7Q5y59ClO7Q1fHdV7qTTYeGc7hENeGUzLNg/BG6IhFceGJrcf"><link rel="preload" href="/wxbox-client-43bdf179bb0c5f46_bg.wasm" crossorigin="anonymous" integrity="sha384-PYPIkq+UvlzCRWv/x6MZTiOvEh2cKbAhjpWDATZYqYOGNJHW1iQon/NX52UpKDJ3" as="fetch" type="application/wasm"></head> <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>
<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-43bdf179bb0c5f46.js'; import init, * as bindings from '/wxbox-client-e251f7c00cc5a420.js';
const wasm = await init({ module_or_path: '/wxbox-client-43bdf179bb0c5f46_bg.wasm' }); const wasm = await init({ module_or_path: '/wxbox-client-e251f7c00cc5a420_bg.wasm' });
window.wasmBindings = bindings; window.wasmBindings = bindings;

View file

@ -212,7 +212,7 @@ function debugString(val) {
return className; return className;
} }
function __wbg_adapter_32(arg0, arg1, arg2) { function __wbg_adapter_32(arg0, arg1, arg2) {
wasm.closure1011_externref_shim(arg0, arg1, arg2); wasm.closure1007_externref_shim(arg0, arg1, arg2);
} }
function takeFromExternrefTable0(idx) { function takeFromExternrefTable0(idx) {
@ -228,7 +228,7 @@ function __wbg_adapter_35(arg0, arg1) {
} }
function __wbg_adapter_40(arg0, arg1, arg2) { function __wbg_adapter_40(arg0, arg1, arg2) {
wasm.closure1697_externref_shim(arg0, arg1, arg2); wasm.closure1693_externref_shim(arg0, arg1, arg2);
} }
/** /**
@ -1633,20 +1633,20 @@ function __wbg_get_imports() {
const ret = false; const ret = false;
return ret; return ret;
}; };
imports.wbg.__wbindgen_closure_wrapper3648 = function(arg0, arg1, arg2) { imports.wbg.__wbindgen_closure_wrapper3643 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 1012, __wbg_adapter_32); const ret = makeMutClosure(arg0, arg1, 1008, __wbg_adapter_32);
return ret; return ret;
}; };
imports.wbg.__wbindgen_closure_wrapper3650 = function(arg0, arg1, arg2) { imports.wbg.__wbindgen_closure_wrapper3645 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 1012, __wbg_adapter_35); const ret = makeMutClosure(arg0, arg1, 1008, __wbg_adapter_35);
return ret; return ret;
}; };
imports.wbg.__wbindgen_closure_wrapper3652 = function(arg0, arg1, arg2) { imports.wbg.__wbindgen_closure_wrapper3647 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 1012, __wbg_adapter_32); const ret = makeMutClosure(arg0, arg1, 1008, __wbg_adapter_32);
return ret; return ret;
}; };
imports.wbg.__wbindgen_closure_wrapper6229 = function(arg0, arg1, arg2) { imports.wbg.__wbindgen_closure_wrapper6224 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 1698, __wbg_adapter_40); const ret = makeMutClosure(arg0, arg1, 1694, __wbg_adapter_40);
return ret; return ret;
}; };
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) { imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {

View file

@ -163,11 +163,9 @@ impl Map {
} }
} }
debug!("{:?}", tiles.iter().map(|u| (u.x, u.y, u.tileid)).collect::<Vec<_>>());
Tileset { Tileset {
tiles: Arc::new(Mutex::new(tiles)), tiles: Arc::new(Mutex::new(tiles)),
zoom: (1.0+self.zoom.fract()) as f32
} }
} }
@ -195,13 +193,15 @@ impl Map {
#[derive(Clone)] #[derive(Clone)]
struct Tileset { struct Tileset {
tiles: Arc<Mutex<Vec<TilesetTile>>> tiles: Arc<Mutex<Vec<TilesetTile>>>,
zoom: f32
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
struct TilesetTile { struct TilesetTile {
tileid: (ZoomLevel, XCoord, YCoord, LayerId), tileid: (ZoomLevel, XCoord, YCoord, LayerId),
x: f32, x: f32,
y: f32, y: f32,
tile: Option<DynamicImage> tile: Option<DynamicImage>,
} }

View file

@ -191,9 +191,15 @@ impl MapRender {
let x = 2.0*tile.x / width; let x = 2.0*tile.x / width;
let y = 2.0*tile.y / height; let y = 2.0*tile.y / height;
let transform = nalgebra_glm::translate(&nalgebra_glm::Mat4::identity(), &nalgebra_glm::vec3(x, y, 0.0)); let transform = &nalgebra_glm::Mat4::identity();
let transform = nalgebra_glm::translate(&transform, &nalgebra_glm::vec3(x, y, 0.0));
let transform = nalgebra_glm::scale(&transform, &nalgebra_glm::vec3(w, h, 1.0)); let transform = nalgebra_glm::scale(&transform, &nalgebra_glm::vec3(w, h, 1.0));
let transform = nalgebra_glm::scale(&transform, &nalgebra_glm::vec3(1.0/width, 1.0/height, 1.0)); let transform = nalgebra_glm::scale(&transform, &nalgebra_glm::vec3(1.0/width, 1.0/height, 1.0));
let transform = nalgebra_glm::scale(&transform, &nalgebra_glm::vec3(tileset.zoom, tileset.zoom, 1.0));
debug!("zoom factor: {}", tileset.zoom);
// screenspace-ify: // screenspace-ify:
// map to 0 to 1 space // map to 0 to 1 space