Skip to content

feat(v1.0a): multi-adapter contract + headless Babylon + conformance#37

Merged
longyi-xw merged 8 commits into
mainfrom
feat/v1.0-babylon-adapter
Jun 9, 2026
Merged

feat(v1.0a): multi-adapter contract + headless Babylon + conformance#37
longyi-xw merged 8 commits into
mainfrom
feat/v1.0-babylon-adapter

Conversation

@longyi-xw

Copy link
Copy Markdown
Owner

What

v1.0 sub-stage A1 — the foundation for the multi-framework goal: establish IRuntimeAdapter as a genuine engine-neutral seam and prove the abstraction holds for a second engine (Babylon.js) via a conformance suite. Headless only (no live viewport yet).

This is the first step toward switching render engines at runtime and adding new 3D frameworks with minimal change — Three.js is the first engine, not the endpoint.

How (TDD, per-task commits)

  1. keystone — verified Babylon's NullEngine constructs headless under vitest/jsdom (the whole approach depended on it; works zero-config).
  2. contract — added engine-neutral describeNode(): RuntimeNodeInfo | null (+ dispose()) to IRuntimeAdapter; ThreeAdapter implements describeNode by reading the actual engine object (Object3D.position/quaternion/userData.geometryKind + instanceof), not echoing input.
  3. BabylonAdapter@babylonjs/core NullEngine, syncNode for group/mesh/light/camera, describeNode; unimplemented methods (pickAt/syncAsset/export/behaviors) throw/reject "not implemented in v1.0a".
  4. conformance suite — one parameterized describeAdapterConformance(makeAdapter, label) run against both ThreeAdapter and BabylonAdapter; identical assertions, both green = contract holds across engines.

Plus review fixes: dispose() formalized on the contract (suite no longer leaks a NullEngine per test), syncNode('update') on a missing node throws in both engines (parity), and conformance now asserts the rotation round-trip on group/mesh.

Spec: docs/superpowers/specs/2026-06-09-v1.0a-multi-adapter-conformance-design.md
Plan: docs/superpowers/plans/2026-06-09-v1.0a-multi-adapter-conformance-plan.md

Scope / known cross-engine gaps (documented, deferred)

A1 asserts full transform on group/mesh; light/camera assert kind/subtype/visible/parent. Building the 2nd adapter surfaced real engine divergences, recorded in roadmap Backlog for when they become in-scope: Babylon camera orientation (Euler, not quaternion) → A2/B; ambient→HemisphericLight has no position → A2/B; prefab_instance kind (Three "mesh" vs Babylon "unknown") → A3. Live engine-switching (host abstraction) is B; spec §8 has the boundary checklist.

Verification

  • pnpm lint (0 new) · pnpm typecheck (0) · pnpm test (498/498)
  • ✅ Conformance: ThreeAdapter 9/9 + BabylonAdapter 9/9 — same suite, both engines green
  • N/A visual smoke — A1 is headless (no UI), by design

🤖 Generated with Claude Code

longyi-xw and others added 8 commits June 9, 2026 17:15
…ce 设计

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…impl

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…beNode

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tation conformance

- Add dispose() to IRuntimeAdapter (both adapters already implement it);
  conformance suite now disposes adapters in afterEach (was leaking a
  NullEngine + Scene per Babylon test).
- BabylonAdapter.syncNode('update') on a missing node now throws, matching
  ThreeAdapter — keeps the contract symmetric across engines; conformance
  asserts the parity.
- Conformance now asserts the rotation round-trip on group/mesh (was
  position/scale only), closing a gap that masked engine rotation bugs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@longyi-xw longyi-xw merged commit b92686b into main Jun 9, 2026
1 check passed
@longyi-xw longyi-xw deleted the feat/v1.0-babylon-adapter branch June 9, 2026 09:56
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.

1 participant