Skip to content

fix: replace GeometryMask with alpha reveal, fix building iso Y position bugs - #64

Merged
linkbag merged 1 commit into
mainfrom
feat/ic-building-graphics-fix
Mar 9, 2026
Merged

linkbag merged 1 commit into
mainfrom
feat/ic-building-graphics-fix

Conversation

@linkbag

@linkbag linkbag commented Mar 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Root cause 1 — GeometryMask invisibility: The constructionMaskShape drew a rect with revealH=0 at constructionProgress=0, leaving the WebGL stencil buffer empty. Since bodyGraphic.setMask(constructionMask) was applied at construction, the building body was permanently invisible until the mask was explicitly cleared — but the clear path could miss in edge cases and the approach was fragile.

  • Root cause 2 — visualRoot.y = 0 wipes iso Y offset: Both the active-promotion guard in update() and the updateConstruction() completion path set this.visualRoot.y = 0, overwriting the correct isometric Y offset (isoPos.y - worldY) that updateRenderTransform() had just set. This placed off-diagonal buildings at their Cartesian worldY instead of isometric isoPos.y.

  • Root cause 3 — Construction animation y was absolute, not additive: updateConstruction() used visualRoot.y = (1-progress)*14 (absolute) which replaced the iso base position. Should be += (additive).

Changes

  • Removed GeometryMask entirely (constructionMaskShape, constructionMask fields, setMask, updateConstructionMask())
  • Replaced mask-based reveal with bodyGraphic.setAlpha(0→1) during construction fade-in
  • Changed construction slide-in to additive visualRoot.y += (1-progress)*14 so it builds on the iso base position
  • Removed all visualRoot.y = 0 overrides — updateRenderTransform() owns the base iso position every frame
  • Guard in update() uses bodyGraphic.setAlpha(1) instead of clearMask()

Test plan

  • npx tsc --noEmit — passes
  • npx vitest run — 96/96 tests pass
  • Launch game, verify starting buildings (Construction Yard, Power Plant, Ore Refinery) are visible as colored 3D isometric boxes
  • Verify buildings at off-diagonal positions (col ≠ row) are at correct iso Y positions
  • Verify player-placed buildings appear immediately after placement
  • Verify AI/enemy buildings are also visible

🤖 Generated with Claude Code

Three bugs caused buildings to be invisible or mispositioned:

1. GeometryMask root cause: constructionMaskShape drew a rect with
   revealH=0 at progress=0, leaving the stencil buffer empty → bodyGraphic
   completely invisible. No fallback existed if the mask was never cleared
   before the first render frame.

2. visualRoot.y = 0 override: both the active-promotion guard and the
   updateConstruction() completion path set visualRoot.y = 0, wiping out
   the correct iso Y offset (isoPos.y - worldY) that updateRenderTransform()
   had just calculated. Off-diagonal buildings rendered at cartesian worldY
   instead of isometric isoPos.y.

3. Construction animation y: updateConstruction() used an absolute assignment
   (visualRoot.y = offset) which replaced the iso base position instead of
   adding to it.

Fix:
- Remove GeometryMask entirely (constructionMaskShape, constructionMask fields,
  setMask call, updateConstructionMask() method)
- Use bodyGraphic.setAlpha(0→1) for the construction fade-in reveal
- Change visualRoot.y slide-in to additive (+= offset) so it builds on top
  of the iso base position set by updateRenderTransform()
- Remove all visualRoot.y = 0 overrides; let updateRenderTransform() own
  the base iso position every frame
- Guard in update() now uses bodyGraphic.setAlpha(1) instead of clearMask()

Result: buildings are always visible (alpha-based reveal, not stencil-based),
positioned correctly at iso coordinates, with working construction animation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@linkbag
linkbag merged commit f93a46f into main Mar 9, 2026
1 check passed
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.

1 participant