This commit is contained in:
Dongho Kim
2025-12-29 03:44:27 +09:00
parent 3885ddd977
commit f3f1a568e2
14 changed files with 380 additions and 100 deletions

View File

@@ -25,6 +25,7 @@ use winit::{
window::WindowBuilder,
platform::web::WindowExtWebSys,
};
use web_sys::Window; // Ensure web_sys Window is available if needed, though usually covered by wasm_bindgen
use wgpu::util::DeviceExt;
use crate::domain::camera::Camera;
@@ -291,6 +292,20 @@ pub async fn run() {
}
}
// Hide loading screen
if let Some(loader) = window_doc.get_element_by_id("loading-screen") {
let _ = loader.class_list().add_1("fade-out");
// Remove after transition
let closure = wasm_bindgen::closure::Closure::<dyn FnMut()>::new(move || {
let _ = loader.set_attribute("style", "display: none;");
});
window_doc.default_view().unwrap().set_timeout_with_callback_and_timeout_and_arguments_0(
closure.as_ref().unchecked_ref(),
500,
).unwrap();
closure.forget();
}
// Event Loop
event_loop.run(move |event, elwt| {
elwt.set_control_flow(winit::event_loop::ControlFlow::Wait);
@@ -381,7 +396,7 @@ pub async fn run() {
for tile in tiles_to_process {
// Call RenderService static helper? Or just logic.
// I put logic in RenderService::create_tile_buffers which takes state.
RenderService::create_tile_buffers(&device, &mut state_guard, tile);
RenderService::create_tile_buffers(&device, &mut state_guard, tile, &render_service.tile_bind_group_layout);
}
}
@@ -567,6 +582,7 @@ pub async fn run() {
rpass.set_bind_group(0, &camera_bind_group, &[]);
for buffers in &tiles_to_render {
if buffers.railway_vertex_count > 0 {
rpass.set_bind_group(1, &buffers.tile_bind_group, &[]);
rpass.set_vertex_buffer(0, buffers.railway_vertex_buffer.slice(..));
rpass.draw(0..buffers.railway_vertex_count, 0..1);
}