Skip to content

fix(renderer-manager): make swapRenderers() actually swap renderers (#808)#811

Open
GaneshPatil7517 wants to merge 1 commit intoHSF:mainfrom
GaneshPatil7517:fix/renderer-manager-swap-renderers-808
Open

fix(renderer-manager): make swapRenderers() actually swap renderers (#808)#811
GaneshPatil7517 wants to merge 1 commit intoHSF:mainfrom
GaneshPatil7517:fix/renderer-manager-swap-renderers-808

Conversation

@GaneshPatil7517
Copy link

hello @EdwardMoyse
The swapRenderers method only swapped local parameter references:

public swapRenderers(rendererA: WebGLRenderer, rendererB: WebGLRenderer) {
  const temp = rendererA;
  rendererA = rendererB;
  rendererB = temp;
}

Since JavaScript passes object references by value, reassigning the parameters inside the function has no effect on the caller or the class's internal state. The method silently did nothing.

Fix
Replaced the no-op local swap with logic that:

  • Finds both renderers in the internal this.renderers array by index.
  • Swaps their positions in the array.
  • Updates mainRenderer and overlayRenderer references if either renderer is involved in the swap.
  • Returns early (no-op) if either renderer is not found in the list.

Tests
Added renderer-manager.test.ts with 5 test cases covering:

  • Swapping two renderers in the list
  • No-op when a renderer is not in the list
  • Updating mainRenderer reference when it's part of the swap
  • Updating overlayRenderer reference when it's part of the swap
  • Swapping a renderer with itself (identity case)

… params

The swapRenderers method only swapped local parameter references,
which had no effect on the caller or internal state. Replaced with
logic that swaps entries in the renderers array and updates
mainRenderer/overlayRenderer references accordingly.

Fixes HSF#808
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