mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-17 10:59:17 +00:00
ifcviewer-web: navigation parity — view all, XYZ views, ortho, zoom-to-selected
The camera math already lived in the shared ViewportCore; the desktop just bound keys to it. The web build had no keyboard handler and no camera UI, so none of it was reachable. Wire it up (Tier 1 + 2 of nav parity; fly mode is a separate follow-up). Shared core: - setStandardView(StandardView) — named Front/Back/Left/Right/Top/Bottom wrapper over setStandardView(yaw,pitch), so the axis→angle mapping lives in one place. - frameSelection() — lifts the desktop's "union selected AABBs → frameAabb(1.30)" focus logic out of ViewportWindow into the core. Desktop's focusOnSelectedObject and the X/Y/Z hotkeys now call these (DRY, behaviour unchanged). Web: - main_web gains a keydown handler matching the desktop bindings — Home=view all, F=zoom to selected, P=ortho toggle, X/Y/Z (+Shift=negative)=standard views — plus exported entry points (view_all_c / frame_selection_c / toggle_projection_c / projection_is_ortho_c / standard_view_c) for the toolbar. - shell.html adds a bottom nav toolbar (Fit / Focus / Persp-Ortho / the six views) with the hotkeys in tooltips; the ortho button reflects state. Verified: Z key and Front button both move the camera, ortho toggles render + label, zero GPU errors; 111/111 unit + 6/6 web smoke pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -445,6 +445,40 @@ void ViewportCore::setStandardView(float yaw_deg, float pitch_deg) {
|
||||
host_->requestFrame();
|
||||
}
|
||||
|
||||
void ViewportCore::setStandardView(StandardView view) {
|
||||
switch (view) {
|
||||
case StandardView::Front: setStandardView(0.0f, 0.0f); break;
|
||||
case StandardView::Back: setStandardView(180.0f, 0.0f); break;
|
||||
case StandardView::Right: setStandardView(90.0f, 0.0f); break;
|
||||
case StandardView::Left: setStandardView(270.0f, 0.0f); break;
|
||||
case StandardView::Top: setStandardView(camera_yaw_deg_, 90.0f); break;
|
||||
case StandardView::Bottom: setStandardView(camera_yaw_deg_, -90.0f); break;
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewportCore::frameSelection() {
|
||||
if (selection_.count() == 0) return false;
|
||||
float lo[3] = { std::numeric_limits<float>::infinity(),
|
||||
std::numeric_limits<float>::infinity(),
|
||||
std::numeric_limits<float>::infinity() };
|
||||
float hi[3] = { -std::numeric_limits<float>::infinity(),
|
||||
-std::numeric_limits<float>::infinity(),
|
||||
-std::numeric_limits<float>::infinity() };
|
||||
bool any = false;
|
||||
for (uint32_t id : selection_.selectionIds()) {
|
||||
float mn[3], mx[3];
|
||||
if (!computeObjectAabb(id, mn, mx)) continue;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
lo[i] = std::min(lo[i], mn[i]);
|
||||
hi[i] = std::max(hi[i], mx[i]);
|
||||
}
|
||||
any = true;
|
||||
}
|
||||
if (!any) return false;
|
||||
frameAabb(lo, hi, 1.30f);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewportCore::orbitBy(float dx_px, float dy_px) {
|
||||
// 0.4 deg/px matches the GL viewport. pitch is clamped just shy of
|
||||
// the pole so orbitEye() stays well-conditioned.
|
||||
|
||||
Reference in New Issue
Block a user