Skip to content

feat(viewer): export getWallHideState - #576

Merged
Aymericr merged 1 commit into
mainfrom
feat/export-wall-hide-state
Aug 4, 2026
Merged

feat(viewer): export getWallHideState#576
Aymericr merged 1 commit into
mainfrom
feat/export-wall-hide-state

Conversation

@Aymericr

@Aymericr Aymericr commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Closes #572.

What

getWallHideState(wallNode, wallMesh, wallMode, cameraDir) is now exported from @pascal-app/viewer, along with the WallMode type it takes.

Why

@esteban685 asked for this in #572: a host rendering its own layers inside <Viewer>'s children seam has no way to match wall-cutout visibility today. The two available workarounds are both bad:

  • re-derive the getWorldDirection(v).dot(cameraDir) < 0 facing test in host code — it silently drifts the moment the viewer's rule changes
  • read the assigned material variant's transparent flag — fragile, and it conflates translucent mode with a hidden wall

The predicate was already pure: it takes every input explicitly and touches no module state beyond a scratch Vector3. So this is an export, not a refactor — WallCutout calls the same function on the same line it did before.

Changes

  • packages/viewer/src/systems/wall/wall-cutout.tsxexport function getWallHideState, plus a JSDoc block recording why it is public
  • packages/viewer/src/store/use-viewer.ts — extract export type WallMode = 'up' | 'cutaway' | 'down' | 'translucent' so the signature names its mode instead of accepting any string. WALL_MODES already existed as the runtime counterpart; the store fields now reference the named type.
  • packages/viewer/src/index.ts — re-export getWallHideState and type WallMode
  • packages/viewer/src/systems/wall/wall-hide-state.test.ts — 5 cases pinning the semantics that are now public API: up always shows, down always hides, cutaway hides the near exterior face and both-sides-interior walls, and keeps both-sides-exterior walls visible from either direction

Verification

  • bun test packages/viewer/src/systems/wall/ → 24 pass, 0 fail
  • bun run check → 1582 files clean
  • bun run check-types → 9/9 tasks pass

No behavior change: same predicate, same call site, wider visibility.


Note

Low Risk
Export-only surface area with typed signatures and new unit tests; wall rendering behavior is unchanged.

Overview
Public API for wall cutaway visibility so hosts that render custom layers inside <Viewer> can hide or show geometry the same way WallCutout does, without copying the camera-facing test or inferring hide state from material transparency.

getWallHideState is exported from wall-cutout (unchanged logic; JSDoc explains the intent). The wallMode argument is typed as a new exported WallMode union ('up' | 'cutaway' | 'down' | 'translucent') on the viewer store and the helper. Both symbols are re-exported from @pascal-app/viewer.

Tests in wall-hide-state.test.ts lock in up/down overrides and cutaway behavior for interior/exterior combinations.

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

…ayers

Hosts that render overlays inside `<Viewer>`'s children seam had no way to
match wall-cutout visibility: they either re-derived the camera facing
dot-product (which drifts from the source of truth) or inferred state from
the assigned material variant's `transparent` flag. The predicate is already
pure, so export it as-is and give `wallMode` a named `WallMode` type instead
of a bare `string`.

Closes #572
@Aymericr
Aymericr force-pushed the feat/export-wall-hide-state branch from 32bd509 to 4c1f8ab Compare August 4, 2026 16:42
@Aymericr
Aymericr merged commit 5152cda into main Aug 4, 2026
2 checks passed
@Aymericr
Aymericr deleted the feat/export-wall-hide-state branch August 4, 2026 16:57
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.

viewer: export getWallHideState from systems/wall/wall-cutout

1 participant