Skip to content

Sync constraint anchor physics transform before attaching vertical constraint#476

Merged
tracygardner merged 1 commit intomainfrom
codex/sync-physics-body-transform-in-camera.js
Mar 26, 2026
Merged

Sync constraint anchor physics transform before attaching vertical constraint#476
tracygardner merged 1 commit intomainfrom
codex/sync-physics-body-transform-in-camera.js

Conversation

@tracygardner
Copy link
Copy Markdown
Contributor

@tracygardner tracygardner commented Mar 26, 2026

Motivation

  • Ensure the reusable hidden constraint anchor's physics body is synchronized with its scene transform before calling mesh.physics.addConstraint(...) to avoid misaligned constraints or jitter.

Description

  • After positioning the constraint anchor, force a world-matrix update with constraintBox.computeWorldMatrix(true) and only run the sync when constraintBox.physics exists.
  • Ensure the anchor has a rotation quaternion by assigning Quaternion.Identity() if missing and set constraintBox.physics.disablePreStep = false to match other static-body patterns before syncing.
  • Push the transform into the physics body with constraintBox.physics.setTargetTransform(constraintBox.position, constraintBox.rotationQuaternion) prior to creating/adding the Physics6DoFConstraint.

Testing

  • Ran node --check api/camera.js which succeeded.
  • Verified changes were committed to the repository.

Codex Task

Summary by CodeRabbit

  • Bug Fixes
    • Fixed constraint synchronization for cameras with physics bodies

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

cloudflare-workers-and-pages bot commented Mar 26, 2026

Deploying flockdev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 949c8a3
Status: ✅  Deploy successful!
Preview URL: https://774197b6.flockdev.pages.dev
Branch Preview URL: https://codex-sync-physics-body-tran.flockdev.pages.dev

View logs

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 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: 5791b377-2e0d-423e-8ff1-b90701dba365

📥 Commits

Reviewing files that changed from the base of the PR and between ef99afc and 949c8a3.

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

📝 Walkthrough

Walkthrough

Updated ensureVerticalConstraint function to synchronize the constraint anchor's rendered and physics transforms. After repositioning the anchor under a mesh, the function now recomputes its world matrix and, when a physics body exists, ensures valid quaternion, disables preStep, and explicitly sets the physics target transform.

Changes

Cohort / File(s) Summary
Physics Transform Synchronization
api/camera.js
Enhanced ensureVerticalConstraint with world matrix recomputation and conditional physics body synchronization, including quaternion validation and explicit target transform updates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hop along the constraint's dance,
Physics and render in perfect stance,
Quaternions twirl, transforms align,
The camera's anchor now feels fine!

🚥 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 clearly and specifically describes the main change: syncing the constraint anchor's physics transform before attaching the vertical constraint, which is the core purpose of the modifications to ensureVerticalConstraint.
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 codex/sync-physics-body-transform-in-camera.js

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

@tracygardner tracygardner merged commit b62685d into main Mar 26, 2026
9 checks passed
@tracygardner tracygardner deleted the codex/sync-physics-body-transform-in-camera.js branch March 27, 2026 12:06
@coderabbitai coderabbitai bot mentioned this pull request Mar 27, 2026
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