ifcviewer-web: wire WebViewportHost + ViewportCore (#87)

Replaces the standalone wgpu-only clear-color spike in main_web.cpp
with a real WebViewportHost implementation: surface creation via the
emdawnwebgpu canvas-selector source, framebufferSize through
emscripten_get_element_css_size + dpr, requestFrame as a deferred
flag the RAF main_loop consumes, quit through emscripten_force_exit.

main_web.cpp now does the same lifecycle the desktop initWgpu shell
does: core_.initWgpu(web_limits=true) → buildPipelines → buildHiz/
Edge/Pick. The render loop runs core_.render() once per RAF tick when
the host has flagged a frame pending, with a surface reconfigure on
size changes.

Builds clean under emcc 6.0 + emdawnwebgpu (1.4 MB wasm, 278 KB JS
glue). Renders an empty scene with the configured background — the
plumbing is end-to-end through the same ViewportCore code path the
desktop build uses. No sidecar load yet: that lands with the
emscripten_fetch streaming backend (#88).
This commit is contained in:
Dion Moult
2026-06-06 21:09:35 +10:00
parent 50014f4842
commit 1fc15e78f2
4 changed files with 213 additions and 157 deletions
+5 -1
View File
@@ -74,7 +74,11 @@ add_subdirectory(${IFCVIEWER_DIR} ifcviewer EXCLUDE_FROM_ALL)
# --- The web executable ------------------------------------------------------
add_executable(IfcViewerWeb main_web.cpp)
add_executable(IfcViewerWeb
main_web.cpp
WebViewportHost.cpp
WebViewportHost.h
)
target_link_libraries(IfcViewerWeb PRIVATE IfcViewerCore)
target_link_options(IfcViewerWeb PRIVATE
# Asyncify lets us await wgpu's RequestAdapter/RequestDevice/MapAsync