the problem child continues
This commit is contained in:
parent
ca89a8d15d
commit
17a1d95e7c
5 changed files with 12 additions and 13 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-28b62034c6896d47.js" crossorigin="anonymous" integrity="sha384-wkhAe67T8C73+DmlG8JEq34RPAIiO8Jf+d3BH/nrBQ1b1NjMqo8csITaVtpbPBwV"><link rel="preload" href="/wxbox-client-28b62034c6896d47_bg.wasm" crossorigin="anonymous" integrity="sha384-ow0yiVvZiDW6OWF6cYTSzuFo0LI6DMGTWCGFs9WoiJRhnge0QYDzOmr02jBTPGqk" as="fetch" type="application/wasm"></head>
|
<link rel="modulepreload" href="/wxbox-client-2aa7e8d0a7ce87a0.js" crossorigin="anonymous" integrity="sha384-wkhAe67T8C73+DmlG8JEq34RPAIiO8Jf+d3BH/nrBQ1b1NjMqo8csITaVtpbPBwV"><link rel="preload" href="/wxbox-client-2aa7e8d0a7ce87a0_bg.wasm" crossorigin="anonymous" integrity="sha384-ktNNMM2Y7MpHin8ahouTcp3Hi86z/aHl3k0MF4B0UPIib8zY3d+HWLstQnSOh8yT" 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-28b62034c6896d47.js';
|
import init, * as bindings from '/wxbox-client-2aa7e8d0a7ce87a0.js';
|
||||||
const wasm = await init({ module_or_path: '/wxbox-client-28b62034c6896d47_bg.wasm' });
|
const wasm = await init({ module_or_path: '/wxbox-client-2aa7e8d0a7ce87a0_bg.wasm' });
|
||||||
|
|
||||||
|
|
||||||
window.wasmBindings = bindings;
|
window.wasmBindings = bindings;
|
||||||
|
|
Binary file not shown.
|
@ -73,6 +73,7 @@ impl Map {
|
||||||
fn load_tiles(&mut self, ctx: &egui::Context, viewport_width: usize, viewport_height: usize) -> Tileset {
|
fn load_tiles(&mut self, ctx: &egui::Context, viewport_width: usize, viewport_height: usize) -> Tileset {
|
||||||
// lat, long is top left
|
// lat, long is top left
|
||||||
// tiles are rendered at 256x256. how many can we fit?
|
// tiles are rendered at 256x256. how many can we fit?
|
||||||
|
debug!("viewport is {}px, we can render {}", viewport_width, viewport_width / 256);
|
||||||
let tiles_x = viewport_width / 256;
|
let tiles_x = viewport_width / 256;
|
||||||
let tiles_y = viewport_height / 256;
|
let tiles_y = viewport_height / 256;
|
||||||
|
|
||||||
|
@ -106,17 +107,16 @@ impl Map {
|
||||||
// for each tile, determine pixel coordinates, then offset by the tile fractionals
|
// for each tile, determine pixel coordinates, then offset by the tile fractionals
|
||||||
for x in 1..tiles_x {
|
for x in 1..tiles_x {
|
||||||
let tile_x = tilex + x;
|
let tile_x = tilex + x;
|
||||||
for y in 1..3 {
|
for y in 1..tiles_y+1 {
|
||||||
let tile_y = tiley + y;
|
let tile_y = tiley + y;
|
||||||
|
|
||||||
let pixel_x = 512_f32 * x as f32;
|
let pixel_x = 256_f32 * x as f32 - x_tile_frac as f32;
|
||||||
let pixel_y = (-512_f32 * y as f32);
|
let pixel_y = -256_f32 * y as f32 + y_tile_frac as f32;
|
||||||
|
|
||||||
|
|
||||||
// download the tile
|
// download the tile
|
||||||
let tile = self.layer_manager.tiles.entry((z_clamped as usize, tile_x, tile_y, OSMBaselayer::SOURCE_ID))
|
let tile = self.layer_manager.tiles.entry((z_clamped as usize, tile_x, tile_y, OSMBaselayer::SOURCE_ID))
|
||||||
.or_insert_with(|| {
|
.or_insert_with(|| {
|
||||||
debug!("fetching {}/{}/{}", z_clamped, tile_x, tile_y);
|
|
||||||
let (sender, promise) = Promise::new();
|
let (sender, promise) = Promise::new();
|
||||||
let request = ehttp::Request::get(format!("https://tile.openstreetmap.org/{}/{tile_x}/{tile_y}.png", z_clamped as usize));
|
let request = ehttp::Request::get(format!("https://tile.openstreetmap.org/{}/{tile_x}/{tile_y}.png", z_clamped as usize));
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
|
|
|
@ -122,9 +122,9 @@ impl MapRender {
|
||||||
let verticies: &[f32] = &[
|
let verticies: &[f32] = &[
|
||||||
// X Y Z S T
|
// X Y Z S T
|
||||||
1.0, 1.0, 0.0, 1.0, 1.0, // top right
|
1.0, 1.0, 0.0, 1.0, 1.0, // top right
|
||||||
1.0, -1.0, 0.0, 1.0, 0.0, // bottom right
|
1.0, 0.0, 0.0, 1.0, 0.0, // bottom right
|
||||||
-1.0, -1.0, 0.0, 0.0, 0.0, // bottom left
|
0.0, 0.0, 0.0, 0.0, 0.0, // bottom left
|
||||||
-1.0, 1.0, 0.0, 0.0, 1.0, // top left
|
0.0, 1.0, 0.0, 0.0, 1.0, // top left
|
||||||
];
|
];
|
||||||
let indicies: &[u32] = &[
|
let indicies: &[u32] = &[
|
||||||
0, 1, 3,
|
0, 1, 3,
|
||||||
|
@ -185,12 +185,11 @@ impl MapRender {
|
||||||
|
|
||||||
gl.use_program(Some(self.shader_program));
|
gl.use_program(Some(self.shader_program));
|
||||||
|
|
||||||
debug!("{} {}", tile.x, tile.y);
|
|
||||||
|
|
||||||
let w = 256.0_f32;
|
let w = 256.0_f32;
|
||||||
let h = 256.0_f32;
|
let h = 256.0_f32;
|
||||||
let x = (tile.x + w) / width - 1.0;
|
let x = (tile.x) / width - 1.0;
|
||||||
let y = (tile.y - h) / width + 1.0;
|
let y = (tile.y) / width + 1.0;
|
||||||
|
|
||||||
let transform = nalgebra_glm::translate(&nalgebra_glm::Mat4::identity(), &nalgebra_glm::vec3(x, y, 0.0));
|
let transform = nalgebra_glm::translate(&nalgebra_glm::Mat4::identity(), &nalgebra_glm::vec3(x, y, 0.0));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue