Skip to content

fix(viewer): stack levels per building#519

Merged
Aymericr merged 2 commits into
mainfrom
agent/fix-level-stacking-per-building
Jul 19, 2026
Merged

fix(viewer): stack levels per building#519
Aymericr merged 2 commits into
mainfrom
agent/fix-level-stacking-per-building

Conversation

@Aymericr

@Aymericr Aymericr commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #511.

What changed

  • compute cumulative level heights independently for each building
  • share the same stacking calculation between the live LevelSystem and the temporary true-position snap used by exports and thumbnails
  • preserve the existing single stack for legacy orphan levels
  • cover single-building, multi-building, and orphan-level cases with focused tests

Why

LevelSystem previously sorted every registered level together and used one global cumulative Y offset. A second building's ground floor therefore started above the first building instead of on its own ground plane. The export/thumbnail helper duplicated the same global-stack behavior.

Thanks @archicorp46-debug for the precise report and reproduction.

Verification

  • bun test packages/viewer/src/systems/level/level-stacking.test.ts
  • bun run --filter @pascal-app/viewer build
  • bun check
  • bun check-types

Note

Medium Risk
Changes core 3D level positioning for all scenes; behavior is well-tested for multi-building and legacy orphans but wrong building resolution could mis-stack levels visually.

Overview
Fixes multi-building scenes where every level was stacked on one global Y ladder, so a second building’s ground floor appeared above the first.

The PR adds level-stacking helpers: getLevelBuildingId (building parent or legacy children lookup) and getLevelStackPositions (cumulative height per buildingId, with orphan levels sharing one null stack). LevelSystem and snapLevelsToTruePositions in level-utils now build the same entries and read Y from that map instead of a single walk over all levels. Bun tests cover single-building order, independent ground planes per building, and orphan legacy stacking.

Reviewed by Cursor Bugbot for commit 40e6a71. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 592bd21. Configure here.

Comment thread packages/viewer/src/systems/level/level-system.tsx Outdated
@Aymericr
Aymericr merged commit 494150d into main Jul 19, 2026
2 checks passed
@Aymericr
Aymericr deleted the agent/fix-level-stacking-per-building branch July 19, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LevelSystem stacks all levels globally — breaks multi-building sites

1 participant