← Back to Pull requests

docs(physics): document how sleeping affects forces, joints and contacts #926

Open
unknown opened this pull request with 517 lines diff across 6 files
View on GitHub
unknown unknown commented on Oct 25, 2026 19:10 UTC
Author

Summary

Most of what #834 asks for landed with its dependency PRs: physics/sleeping.md, createSleepEcsSystem in the physics index's registration example, and the "Sleep state" section in rigid-bodies.md. This PR fills in what was still missing and fixes two inaccurate sentences:

  • forces.md: one paragraph explains that applyImpulse, applyTorque and applyExplosiveForce act on sleeping bodies and wake their islands. A torque on a body with locked rotation changes nothing, so that body stays asleep. The Gravity section now says gravity isn't applied to a sleeping body. It also used to say a gravity change wakes "every body it rests on or against", which is wrong: only the body's island wakes, and a static floor doesn't.

  • joints.md: a new "Sleeping jointed bodies" section covers these points:

  • - Two dynamic bodies a joint connects share an island.
    - A static, kinematic or collider-only end is recorded as a partner. The sleeping body wakes when that partner is moved, turned, removed or given a new collider, or when a kinematic end has a velocity.
    - A joint links its bodies only while both have a position and a rotation.
    - Adding or removing a joint, or changing entityA/entityB, wakes the bodies. Any other field change needs wakeRequested.
  • collisions.md: a sleeping body's contacts keep touching with nothing in started/ended. A new solid contact is listed in started and wakes the body. A sensor still lists a sleeping body it overlaps, and never wakes it.

  • sleeping.md: removed the Box2D comparison and some figurative wording, which the document-feature skill doesn't allow, and added the sensor touching behavior.
  • Where the sleep system is registered (differs from the issue): the issue asks for createSleepEcsSystem "directly after createTransformEcsSystem" in physics/index.md. The sleep system reads this step's collisionManifolds, and its JSDoc says to register it after createNarrowPhaseEcsSystem. Placing it right after the transform system would make it read the previous step's collisions. The index already registers it after the narrow phase and explains why (item 3 of the order list), so I left that unchanged.

    The JSDoc of RigidBodyEcsComponent, createSleepEcsSystem, SleepOptions and isBodyAwake already covers every option, default and throw that the guide leaves to the API reference. No /src changes.

    solution-reviewer: REVISE on the first plan. It caught the false torque statement for locked-rotation bodies and the wrong gravity sentence, and asked for the partner and position+rotation details in the joints section. APPROVE on the revised diff. I also applied its three optional wording fixes.

    No demo pages need a manual check, since no demo code or engine code changed. The pages to read in the browser are Physics → Sleeping Bodies, Applying Forces, Joints and Collisions.

    Related issue(s)

    Closes #834

    Verification checklist

  • npm run check-types passes with 0 errors

  • npm test passes (not run: the run's tool permissions didn't allow it. This PR changes only Markdown under documentation-site/docs)

  • npm run lint passes with 0 errors

  • npm run cspell passes with 0 errors

  • npm run check-exports passes

  • Any new/changed public API is exported from the module's index.ts

  • (and /src/index.ts / package.json exports if it's a new module) (no API changes)
  • Documentation under /documentation-site/docs/docs is updated if this

  • change affects documented behavior
  • If this change touches a module with a demo under

  • /documentation-site/src/pages/demos, the demo has been updated and
    verified (see AGENTS.md's "Documentation Site Demos" section) (no /src or demo changes)

    I also ran npm run build, and from documentation-site/, npm run typecheck and npm run build. All passed, with no broken links.

    Changelog

  • A bullet has been added under ## [Unreleased] in CHANGELOG.md (not required: this is a docs change)
  • 🤖 Generated with Claude Code

    Diff: 517 lines (+387 / -130) across 6 files Reviewer: claude[bot] Review duration: 11m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.48) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 517 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 91% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.374
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #926"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.7% (MEDIUM) · Higher = larger blast radius
    47.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26.4% · Safe to merge
    26.4%