update
This commit is contained in:
@@ -192,7 +192,7 @@ fn create_road_mesh(points: &[[f64; 2]], width: f32) -> Vec<Vertex> {
|
||||
async fn fetch_cached(url: &str) -> Option<String> {
|
||||
let window = web_sys::window()?;
|
||||
let caches = window.caches().ok()?;
|
||||
let cache_name = "map-data-v1";
|
||||
let cache_name = "map-data-v2";
|
||||
let cache = wasm_bindgen_futures::JsFuture::from(caches.open(cache_name)).await.ok()?;
|
||||
let cache: web_sys::Cache = cache.dyn_into().ok()?;
|
||||
|
||||
@@ -839,7 +839,7 @@ pub async fn run() {
|
||||
let window_clone_for_fetch = window.clone();
|
||||
wasm_bindgen_futures::spawn_local(async move {
|
||||
// Fetch nodes
|
||||
let url_nodes = format!("http://localhost:3000/api/tiles/{}/{}/{}", z, x, y);
|
||||
let url_nodes = format!("/api/tiles/{}/{}/{}", z, x, y);
|
||||
let nodes_data = if let Some(json) = fetch_cached(&url_nodes).await {
|
||||
serde_json::from_str::<Vec<MapNode>>(&json).ok()
|
||||
} else {
|
||||
@@ -847,7 +847,7 @@ pub async fn run() {
|
||||
};
|
||||
|
||||
// Fetch ways
|
||||
let url_ways = format!("http://localhost:3000/api/tiles/{}/{}/{}/ways", z, x, y);
|
||||
let url_ways = format!("/api/tiles/{}/{}/{}/ways", z, x, y);
|
||||
let ways_data = if let Some(json) = fetch_cached(&url_ways).await {
|
||||
serde_json::from_str::<Vec<MapWay>>(&json).ok()
|
||||
} else {
|
||||
@@ -855,7 +855,7 @@ pub async fn run() {
|
||||
};
|
||||
|
||||
// Fetch buildings
|
||||
let url_buildings = format!("http://localhost:3000/api/tiles/{}/{}/{}/buildings", z, x, y);
|
||||
let url_buildings = format!("/api/tiles/{}/{}/{}/buildings", z, x, y);
|
||||
let buildings_data = if let Some(json) = fetch_cached(&url_buildings).await {
|
||||
serde_json::from_str::<Vec<MapWay>>(&json).ok()
|
||||
} else {
|
||||
@@ -863,7 +863,7 @@ pub async fn run() {
|
||||
};
|
||||
|
||||
// Fetch landuse
|
||||
let url_landuse = format!("http://localhost:3000/api/tiles/{}/{}/{}/landuse", z, x, y);
|
||||
let url_landuse = format!("/api/tiles/{}/{}/{}/landuse", z, x, y);
|
||||
let landuse_data = if let Some(json) = fetch_cached(&url_landuse).await {
|
||||
serde_json::from_str::<Vec<MapWay>>(&json).ok()
|
||||
} else {
|
||||
@@ -871,7 +871,7 @@ pub async fn run() {
|
||||
};
|
||||
|
||||
// Fetch water
|
||||
let url_water = format!("http://localhost:3000/api/tiles/{}/{}/{}/water", z, x, y);
|
||||
let url_water = format!("/api/tiles/{}/{}/{}/water", z, x, y);
|
||||
let water_data = if let Some(json) = fetch_cached(&url_water).await {
|
||||
serde_json::from_str::<Vec<MapWay>>(&json).ok()
|
||||
} else {
|
||||
@@ -879,7 +879,7 @@ pub async fn run() {
|
||||
};
|
||||
|
||||
// Fetch railways
|
||||
let url_railways = format!("http://localhost:3000/api/tiles/{}/{}/{}/railways", z, x, y);
|
||||
let url_railways = format!("/api/tiles/{}/{}/{}/railways", z, x, y);
|
||||
let railways_data = if let Some(json) = fetch_cached(&url_railways).await {
|
||||
serde_json::from_str::<Vec<MapWay>>(&json).ok()
|
||||
} else {
|
||||
@@ -1099,6 +1099,10 @@ fn create_pipeline(
|
||||
let x = world_pos.x * camera.params.x + camera.params.z;
|
||||
let y = world_pos.y * camera.params.y + camera.params.w;
|
||||
|
||||
// Globe Effect: Spherize
|
||||
// let r2 = x*x + y*y;
|
||||
// let w = 1.0 + r2 * 0.5;
|
||||
|
||||
out.clip_position = vec4<f32>(x, y, 0.0, 1.0);
|
||||
return out;
|
||||
}
|
||||
@@ -1184,6 +1188,10 @@ fn create_road_pipeline(
|
||||
let x = world_pos.x * camera.params.x + camera.params.z;
|
||||
let y = world_pos.y * camera.params.y + camera.params.w;
|
||||
|
||||
// Globe Effect: Spherize
|
||||
// let r2 = x*x + y*y;
|
||||
// let w = 1.0 + r2 * 0.5;
|
||||
|
||||
out.clip_position = vec4<f32>(x, y, 0.0, 1.0);
|
||||
return out;
|
||||
}
|
||||
@@ -1268,6 +1276,10 @@ fn create_building_pipeline(
|
||||
let x = world_pos.x * camera.params.x + camera.params.z;
|
||||
let y = world_pos.y * camera.params.y + camera.params.w;
|
||||
|
||||
// Globe Effect: Spherize
|
||||
// let r2 = x*x + y*y;
|
||||
// let w = 1.0 + r2 * 0.5;
|
||||
|
||||
out.clip_position = vec4<f32>(x, y, 0.0, 1.0);
|
||||
return out;
|
||||
}
|
||||
@@ -1352,6 +1364,10 @@ fn create_landuse_pipeline(
|
||||
let x = world_pos.x * camera.params.x + camera.params.z;
|
||||
let y = world_pos.y * camera.params.y + camera.params.w;
|
||||
|
||||
// Globe Effect: Spherize
|
||||
// let r2 = x*x + y*y;
|
||||
// let w = 1.0 + r2 * 0.5;
|
||||
|
||||
out.clip_position = vec4<f32>(x, y, 0.0, 1.0);
|
||||
return out;
|
||||
}
|
||||
@@ -1446,6 +1462,10 @@ fn create_water_pipeline(
|
||||
let x = world_pos.x * camera.params.x + camera.params.z;
|
||||
let y = world_pos.y * camera.params.y + camera.params.w;
|
||||
|
||||
// Globe Effect: Spherize
|
||||
// let r2 = x*x + y*y;
|
||||
// let w = 1.0 + r2 * 0.5;
|
||||
|
||||
out.clip_position = vec4<f32>(x, y, 0.0, 1.0);
|
||||
return out;
|
||||
}
|
||||
@@ -1540,6 +1560,10 @@ fn create_railway_pipeline(
|
||||
let x = world_pos.x * camera.params.x + camera.params.z;
|
||||
let y = world_pos.y * camera.params.y + camera.params.w;
|
||||
|
||||
// Globe Effect: Spherize
|
||||
// let r2 = x*x + y*y;
|
||||
// let w = 1.0 + r2 * 0.5;
|
||||
|
||||
out.clip_position = vec4<f32>(x, y, 0.0, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user