Skip to content

🐛 fix(effects): stabilize LOD effect culling - #107

Open
24KaratAu wants to merge 1 commit into
srizzon:mainfrom
24KaratAu:fix/lod-transition-pop
Open

🐛 fix(effects): stabilize LOD effect culling#107
24KaratAu wants to merge 1 commit into
srizzon:mainfrom
24KaratAu:fix/lod-transition-pop

Conversation

@24KaratAu

Copy link
Copy Markdown

What does this PR do?

Fixes visual popping of high-detail building effects during fly mode in dense city areas.

EffectsLayer.tsx already applied hysteresis for distance-based activation, but the maxActiveEffects capacity limit introduced a second instability source. Buildings near the active-set cutoff boundary continuously swapped positions during small camera movements, triggering rapid mount/unmount churn for ActiveBuildingEffects.

This change stabilizes the capacity-culling step by applying a small prioritization bias to already-active buildings:

const prioritizedDistSq = isActive
  ? Math.max(0,actualDistSq - hysteresisBiasSq)
  : actualDistSq;

This makes active effects slightly "stickier" so they remain mounted until meaningfully outdistanced by new candidates, reducing visible popping while preserving the existing rendering architecture and performance characteristics.

Related issue

Fixes #92

Screenshots

N/A (visual stabilization / reduced effect churn)

Checklist

  • Tested locally
  • No secrets or .env values committed
  • npm run lint passes globally (repo currently contains unrelated pre-existing lint errors)

Copilot AI review requested due to automatic review settings May 29, 2026 18:17
@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown

@24KaratAu is attempting to deploy a commit to the Samuel's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI 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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds hysteresis bias when capping active effects to reduce LOD churn near the cutoff boundary by prioritizing already-active buildings.

Changes:

  • Compute a hysteresis bias from farSq - nearSq
  • Subtract bias from active buildings' squared distances when sorting for cap selection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/EffectsLayer.tsx Outdated
return { idx, distSq: dx * dx + dz * dz };
const actualDistSq = dx * dx + dz * dz;

// // Bias active buildings to reduce LOD churn near the cutoff boundary
Comment thread src/components/EffectsLayer.tsx Outdated

// Cap at maxActiveEffects — keep closest buildings
if (newSet.size > maxActiveEffects) {
const hysteresisBiasSq = Math.max(0,farSq - nearSq);
Comment thread src/components/EffectsLayer.tsx Outdated

// Cap at maxActiveEffects — keep closest buildings
if (newSet.size > maxActiveEffects) {
const hysteresisBiasSq = Math.max(0,farSq - nearSq);
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.

[Bug] Buildings visually "pop" when flying through the city — LOD transition has no blend

2 participants