Skip to content

Fix camera target Y position fallback in flock transform#529

Merged
tracygardner merged 1 commit intomainfrom
claude/fix-look-object-y-axis-jlM0I
Apr 13, 2026
Merged

Fix camera target Y position fallback in flock transform#529
tracygardner merged 1 commit intomainfrom
claude/fix-look-object-y-axis-jlM0I

Conversation

@tracygardner
Copy link
Copy Markdown
Contributor

@tracygardner tracygardner commented Apr 13, 2026

Summary

Updated the camera target Y position logic in the flock transform to use the existing mesh target's Y coordinate as the primary fallback before defaulting to the camera position.

Key Changes

  • Modified the Y position assignment for tgtPos to check mesh1.target?.y first before falling back to camPos.y
  • This ensures that if a target Y position was previously set on the mesh, it will be preserved rather than always resetting to the camera's Y position

Implementation Details

The change improves the behavior when useY is false by maintaining consistency with any previously established target Y values, providing a more predictable camera positioning experience during flock transformations.

https://claude.ai/code/session_012ASzHmpUWv39A2j5hiFzyc

Summary by CodeRabbit

  • Bug Fixes
    • Improved camera target positioning logic to use the mesh's vertical coordinate when the vertical-axis constraint is disabled, rather than always defaulting to the camera's position. When no mesh target is available, the camera position is used as a fallback. This ensures more accurate and consistent camera behavior when working with constrained camera controls.

For ArcRotateCamera, getAbsolutePosition() returns the camera's world
position (orbit centre + orbital offset), not the orbit centre itself.
Using that Y value as the new setTarget() height displaced the orbit
centre upward by the full orbital offset, making the camera tilt down
instead of staying level.

Fix: use mesh1.target?.y (the actual orbit-centre Y for ArcRotateCamera,
and the current look-at Y for FreeCamera) so that only the X/Z of the
orbit centre changes, giving a pure horizontal yaw with no pitch change.

https://claude.ai/code/session_012ASzHmpUWv39A2j5hiFzyc
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying flockxr with  Cloudflare Pages  Cloudflare Pages

Latest commit: b71940f
Status: ✅  Deploy successful!
Preview URL: https://29f13809.flockxr.pages.dev
Branch Preview URL: https://claude-fix-look-object-y-axi.flockxr.pages.dev

View logs

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1c6772da-ade5-48e4-bb0a-58ccfd5d30b4

📥 Commits

Reviewing files that changed from the base of the PR and between fdcdb6c and b71940f.

📒 Files selected for processing (1)
  • api/transform.js

📝 Walkthrough

Walkthrough

The api/transform.js file has been updated to modify the camera lookAt special-case logic. When useY is false, the target position's y coordinate now retrieves from mesh1.target?.y with a fallback to camPos.y, replacing the previous behavior of always using camPos.y.

Changes

Cohort / File(s) Summary
Camera Target Position Logic
api/transform.js
Modified the y coordinate source in the target position vector when useY is false, changing from a fixed camPos.y to a dynamic fallback pattern using mesh1.target?.y.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 The camera now gazes with more grace,
Target's Y-coordinate finds its place,
A fallback whisper from mesh to cam,
One line adjusted—a precise exam! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: fixing the camera target Y position fallback logic in the flock transform. It is specific, concise, and accurately represents the core modification in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-look-object-y-axis-jlM0I

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

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

@tracygardner tracygardner merged commit b5cf821 into main Apr 13, 2026
10 checks passed
@tracygardner tracygardner deleted the claude/fix-look-object-y-axis-jlM0I branch April 13, 2026 15:34
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.

2 participants