Skip to content

Refactor mesh selection into shared handler and improve camera focus selection behavior#604

Merged
tracygardner merged 2 commits intomainfrom
codex/update-f-key-to-select-mesh
May 4, 2026
Merged

Refactor mesh selection into shared handler and improve camera focus selection behavior#604
tracygardner merged 2 commits intomainfrom
codex/update-f-key-to-select-mesh

Conversation

@tracygardner
Copy link
Copy Markdown
Contributor

@tracygardner tracygardner commented May 4, 2026

Motivation

  • Consolidate duplicate mesh-selection logic so selection behavior is consistent across camera focus and select gizmo paths.
  • Ensure clicking a mesh (or its children) highlights the correct root mesh and associated Blockly block.
  • Provide a clear readout when the ground is clicked and clean up attached gizmo state when deselecting.

Description

  • Introduces a new helper function applyMeshSelection(pickedMesh, pickedPoint) that centralizes selection behavior and ground click handling.
  • focusCameraOnMesh() now calls applyMeshSelection to apply the same highlighting and gizmo attachment when focusing a mesh.
  • handleSelectGizmo() was simplified to delegate to applyMeshSelection, removing duplicated code for parent/root mesh resolution, visibility adjustments, bounding-box display, block highlighting, and ground readout.
  • When deselecting, the code now calls resetChildMeshesOfAttachedMesh() and detaches the gizmo via gizmoManager.attachToMesh(null) to restore child visibility consistently.

Testing

  • No automated tests were added or run for this change.

Codex Task

Summary by CodeRabbit

  • Improvements
    • Mesh selection interactions now consistently update block highlighting and gizmo attachment, providing unified visual feedback when focusing on or selecting objects in the viewport.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@tracygardner has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 26 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0407762e-6d91-4e15-b392-e9c84752583a

📥 Commits

Reviewing files that changed from the base of the PR and between b3c15cf and 300b9d7.

📒 Files selected for processing (1)
  • ui/gizmos.js
📝 Walkthrough

Walkthrough

A refactoring of ui/gizmos.js extracts and centralizes mesh selection behavior into a shared helper function applyMeshSelection(), which is now invoked by both focusCameraOnMesh() and handleSelectGizmo() to ensure consistent handling of block highlighting, gizmo attachment, and bounding-box visibility.

Changes

Selection Logic Centralization

Layer / File(s) Summary
Helper Extraction
ui/gizmos.js (lines 405–433)
New applyMeshSelection(pickedMesh, pickedPoint) helper encapsulates root-mesh normalization, visibility adjustments, Blockly highlighting, gizmo attachment, bounding-box toggling, and position readouts for ground picks.
Camera Focus Integration
ui/gizmos.js (line 383)
focusCameraOnMesh() now calls applyMeshSelection(mesh) to apply consistent selection side effects before computing bounds and moving camera.
Select Gizmo Integration
ui/gizmos.js (lines 1808–1809)
handleSelectGizmo() callback replaces inline selection/highlight/attach logic with a single call to applyMeshSelection(pickedMesh, pickedPoint).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A helper hops through the code so neat,
Gathering selection logic, oh what a feat!
No more duplication, no scattered lines—
One shared function that beautifully aligns!
Focus and select now dance as one tune. 🎯

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: refactoring mesh selection into a shared handler (applyMeshSelection) and improving camera focus selection behavior (focusCameraOnMesh now invokes the shared handler).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/update-f-key-to-select-mesh

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 51 minutes and 26 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying flockxr with  Cloudflare Pages  Cloudflare Pages

Latest commit: b3c15cf
Status: ✅  Deploy successful!
Preview URL: https://f5ef8794.flockxr.pages.dev
Branch Preview URL: https://codex-update-f-key-to-select.flockxr.pages.dev

View logs

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ui/gizmos.js`:
- Around line 429-432: The deselect path leaves a composite root's visibility at
0.001 because resetBoundingBoxVisibilityIfManuallyChanged isn't called; update
the click-to-deselect flow so after resetChildMeshesOfAttachedMesh() (and before
or after gizmoManager.attachToMesh(null)) you explicitly call
resetBoundingBoxVisibilityIfManuallyChanged for the previously attached mesh (or
invoke the same sequence turnOffAllGizmos uses) so the root mesh visibility is
restored; reference functions: applyMeshSelection,
resetChildMeshesOfAttachedMesh, resetBoundingBoxVisibilityIfManuallyChanged,
resetAttachedMesh, hideBoundingBox, gizmoManager.attachToMesh, and
turnOffAllGizmos to locate where to insert the call.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2a7ac1cb-2e1a-4ed5-8ecf-36b84a94022d

📥 Commits

Reviewing files that changed from the base of the PR and between b48093a and b3c15cf.

📒 Files selected for processing (1)
  • ui/gizmos.js

Comment thread ui/gizmos.js
Comment on lines +429 to +432
if (gizmoManager.attachedMesh) {
resetChildMeshesOfAttachedMesh();
gizmoManager.attachToMesh(null);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Composite mesh root visibility is not restored on deselect — visual regression

When a composite (e.g. glTF) mesh is selected, applyMeshSelection sets its root's visibility to 0.001 (line 409) so the bounding box renders. On deselect, the deselect path (lines 429-432) calls resetChildMeshesOfAttachedMesh() and gizmoManager.attachToMesh(null). The patched attachToMesh internally calls resetAttachedMeshhideBoundingBox, but neither path calls resetBoundingBoxVisibilityIfManuallyChanged, so the root mesh's visibility stays at 0.001 — the model remains fractionally visible after being "deselected".

turnOffAllGizmos handles this correctly (line 1920), but it is not in the click-to-deselect flow.

🐛 Proposed fix
  if (gizmoManager.attachedMesh) {
+   resetBoundingBoxVisibilityIfManuallyChanged(gizmoManager.attachedMesh);
    resetChildMeshesOfAttachedMesh();
    gizmoManager.attachToMesh(null);
  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/gizmos.js` around lines 429 - 432, The deselect path leaves a composite
root's visibility at 0.001 because resetBoundingBoxVisibilityIfManuallyChanged
isn't called; update the click-to-deselect flow so after
resetChildMeshesOfAttachedMesh() (and before or after
gizmoManager.attachToMesh(null)) you explicitly call
resetBoundingBoxVisibilityIfManuallyChanged for the previously attached mesh (or
invoke the same sequence turnOffAllGizmos uses) so the root mesh visibility is
restored; reference functions: applyMeshSelection,
resetChildMeshesOfAttachedMesh, resetBoundingBoxVisibilityIfManuallyChanged,
resetAttachedMesh, hideBoundingBox, gizmoManager.attachToMesh, and
turnOffAllGizmos to locate where to insert the call.

@tracygardner tracygardner merged commit 47cd038 into main May 4, 2026
8 checks passed
@tracygardner tracygardner deleted the codex/update-f-key-to-select-mesh branch May 4, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant