Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
# OpenSpec Change: enterprise-gaming-r3f-physics-core
- **Change ID**: enterprise-gaming-r3f-physics-core
- **Package**: `@suaveplan/r3f-physics-core`
- **Category**: gaming/physics
- **Target path**: `gaming/physics/r3f-physics-core`
- **Status**: PROPOSED
- **Date**: 2026-04-24
---
## Summary
Deliver `@suaveplan/r3f-physics-core` on the genesis branch from scratch at enterprise quality. The package provides a physics engine abstraction layer for React Three Fiber: a `PhysicsProvider` React context wraps any physics backend (Rapier, Cannon, custom); `useRigidBody()`, `useCollider()`, and `usePhysicsWorld()` hooks provide access to physics primitives in a backend-agnostic way. The `PhysicsBackend` interface matches `@suaveplan/character-physics`'s `PhysicsBackend` + `@suaveplan/vehicle-physics`'s `VehiclePhysicsBackend`. Genesis adds structured errors, OTel step-time histogram, and 100% coverage.
---
## Available workspace deps
`@suaveplan/error`, `@suaveplan/types`, `@suaveplan/events`, react, `@react-three/fiber`, three.
---
## Public API surface
```ts
function PhysicsProvider(props: PhysicsProviderProps): JSX.Element
// backend, gravity, fixedStep, debug
function usePhysicsWorld(): PhysicsWorld
function useRigidBody(options: RigidBodyOptions): RigidBodyHandle
function useCollider(body: RigidBodyHandle, desc: ColliderDesc): ColliderHandle
interface PhysicsWorld {
step(dt: number): void
raycast(origin: Vec3, dir: Vec3, maxDist: number): RaycastHit | null
readonly bodies: ReadonlyMap<string, RigidBodyHandle>
}
```
---
## File layout
```text
gaming/physics/r3f-physics-core/
package.json / tsconfig.json / vitest.config.ts
src/
index.ts / error-codes.ts
types/common.ts + md
context/physics-provider.tsx + md + test
hooks/
use-physics-world.ts + md + test
use-rigid-body.ts + md + test
use-collider.ts + md + test
tests/integration.test.ts
```

View File

@@ -0,0 +1,23 @@
# Tasks: enterprise-gaming-r3f-physics-core
## 0. Pre-flight (non-negotiable)
- [ ] 0.1 Confirm clean working tree (`git status` reports nothing) and no in-flight worktrees with uncommitted work (`git worktree list` then `git status` in each)
- [ ] 0.2 If any worktrees exist under `.claude/worktrees/`, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (`git worktree remove`) before opening a new one — code that has been lost twice on main is the failure mode this guards against.
- [ ] 0.3 Confirm the package set in `MANIFEST.md` matches `find packages -maxdepth 3 -name package.json` count. Drift here means a prior change archived without regenerating the manifest.
## Phase 1 — Scaffold + types + interfaces
## Phase 2 — PhysicsProvider context
- [ ] Backend injection, fixed-step accumulator, debug toggle
## Phase 3 — Hooks: usePhysicsWorld / useRigidBody / useCollider
- [ ] Tests + docs for each
## Phase 4 — Pre-publish gate
- [ ] `bunx turbo lint typecheck test --filter=@suaveplan/r3f-physics-core` green
- [ ] 100% coverage
- [ ] Publish: `bun scripts/publish.ts --package @suaveplan/r3f-physics-core`