Skip to content

test(octree): smoke tests for the 2.5D pattern (Camera3d + same-Z gameplay)#1477

Merged
obiot merged 1 commit into
masterfrom
test/octree-2.5d-pattern
May 31, 2026
Merged

test(octree): smoke tests for the 2.5D pattern (Camera3d + same-Z gameplay)#1477
obiot merged 1 commit into
masterfrom
test/octree-2.5d-pattern

Conversation

@obiot

@obiot obiot commented May 31, 2026

Copy link
Copy Markdown
Member

Summary

Adds three smoke tests in `tests/octree.spec.js` guarding the architectural claims in the wiki's 2.5D Games section:

  • `world.sortOn = "depth"` swaps the broadphase to an Octree
  • Two entities sharing a Z plane surface as broadphase candidates of each other so SAT can resolve the XY overlap (or non-overlap) exactly as in a 2D world
  • A Renderable inserted via `world.addChild(child, 0)` is retrievable through the broadphase's 2D-Rect path that `adapter.queryAABB(rect)` uses internally

These guard against regressions in the World → broadphase pipeline for the 2.5D use case before #1476 lands a worked example on top.

What this PR also fixes (in the wiki, not code)

The initial draft of the 2.5D wiki section overpromised "free Z isolation" between gameplay and parallax via the Octree. Writing the test surfaced that this isn't true: the Octree's strict midpoint test (`rz < mid`, `rz > mid`) keeps items at exactly the depth midpoint stuck at root and visible to every query. Under the default ±10000 root box, gameplay at `z = 0` is at the midpoint, so the broadphase walk doesn't isolate it from parallax. The wiki page has been corrected on the same day to recommend `isKinematic` / `collisionType` for deterministic gameplay-vs-parallax filtering — same advice that already applies to 2D Camera2d + QuadTree.

The missing test ("parallax-Z items pruned from gameplay-Z queries") is not added — it would have failed against the actual behavior, which is documented behavior, not a bug.

Test plan

  • All 98 tests pass under `pnpm vitest run tests/octree.spec.js`
  • Tests run under both WebGL-available and Canvas-fallback envs (use `video.CANVAS`)
  • Wiki section updated to match actual behavior

Related

🤖 Generated with Claude Code

…eplay)

Add three smoke tests guarding the architectural claims in the wiki's
new 2.5D-games section (Working in 3D — Paper Mario-style):

- `world.sortOn = "depth"` swaps the broadphase to an Octree
- Two entities sharing a Z plane surface as broadphase candidates of
  each other so SAT can resolve the XY overlap (or non-overlap)
  exactly as in a 2D world
- A Renderable inserted via `world.addChild(child, 0)` is retrievable
  through the broadphase's 2D-Rect path that
  `adapter.queryAABB(rect)` uses internally

These guard against regressions in the World → broadphase pipeline for
the 2.5D use case before issue #1476 lands a worked example on top.

Notably absent: a "parallax-Z items are pruned from gameplay-Z queries"
test. The wiki's initial draft overpromised free Z isolation, but the
Octree's strict midpoint test (`rz < mid`, `rz > mid`) keeps items at
exactly the depth midpoint stuck at root, so a z=0 gameplay plane under
the default ±10000 root box doesn't actually get parallax isolation
from the broadphase. Wiki has been corrected to recommend
`isKinematic`/`collisionType` for deterministic gameplay-vs-parallax
filtering — same advice that already applies to 2D Camera2d + QuadTree.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 31, 2026 07:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@obiot obiot merged commit 1334467 into master May 31, 2026
6 of 7 checks passed
@obiot obiot deleted the test/octree-2.5d-pattern branch May 31, 2026 08:10
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