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,62 @@
# OpenSpec Change: enterprise-gaming-r3f-networking
- **Change ID**: enterprise-gaming-r3f-networking
- **Package**: `@suaveplan/r3f-networking`
- **Category**: gaming/gameplay
- **Target path**: `gaming/gameplay/r3f-networking`
- **Status**: SUPERSEDED-BY-GENESIS-WAVE
- **Date**: 2026-04-24
---
## Summary
Deliver `@suaveplan/r3f-networking` on the genesis branch from scratch at enterprise quality. The package provides multiplayer state synchronization for React Three Fiber: `NetworkedTransform` component applying snapshot interpolation (lerp/slerp per-axis with configurable extrapolation buffer), `NetworkedAnimator` syncing animation state across clients, `ClientPrediction` applying local-authoritative input with server reconciliation, `LagCompensation` utility for rollback-based hit detection, and `useNetworkPing` hook for RTT display. Built on WebSocket transport from `@suaveplan/game-server`. Genesis adds 100% coverage and Storybook stories.
---
## Available workspace deps
`@suaveplan/game-server`, `@suaveplan/game-state-schemas`, `@suaveplan/error`, `@suaveplan/types`, `@suaveplan/timing`, react, `@react-three/fiber`, three.
---
## Public API surface
```ts
function NetworkProvider(props: NetworkProviderProps): JSX.Element
// url, tickRate, interpolationDelay, onConnect, onDisconnect
function NetworkedTransform(props: NetworkedTransformProps): JSX.Element
// networkId, interpolation: 'lerp' | 'hermite', extrapolate
function NetworkedAnimator(props: NetworkedAnimatorProps): JSX.Element
// networkId, mixer
function ClientPrediction(props: ClientPredictionProps): JSX.Element
// networkId, applyInput, rollback
function useNetworkPing(): { ping: number; jitter: number }
function useNetworkProvider(): NetworkContext
// send(msg), latency, connected, tick
```
---
## File layout
```text
gaming/gameplay/r3f-networking/
package.json / tsconfig.json / vitest.config.ts
src/
index.ts / error-codes.ts
types/common.ts + md
context/network-provider.tsx + md + test
interpolation/ (snapshot-buffer.ts + md + test, hermite.ts + md + test)
hooks/use-network-ping.ts + md + test
components/
NetworkedTransform/ (tsx + md + test + stories + index)
NetworkedAnimator/ (tsx + md + test + stories + index)
ClientPrediction/ (tsx + md + test + stories + index)
tests/integration.test.ts
```

View File

@@ -0,0 +1,39 @@
# Tasks: enterprise-gaming-r3f-networking
## Phase 1 — Scaffold
- [x] Create `gaming/gameplay/r3f-networking/` (`@suaveplan/r3f-networking`, `0.1.0`, `sideEffects: false`)
## Phase 2 — Types + error codes
- [x] `src/types/common.ts` + `common.md`
- [x] `src/error-codes.ts`
## Phase 3 — Interpolation core
- [x] `snapshot-buffer.ts` — ring buffer of timestamped snapshots
- [x] `hermite.ts` — cubic Hermite spline for smooth extrapolation
- [x] Tests + docs
## Phase 4 — Context + hooks
- [x] `NetworkProvider` — WebSocket transport, tick loop
- [x] `useNetworkPing` — RTT/jitter measurement
- [x] Tests + docs
## Phase 5 — Components
- [x] `NetworkedTransform` — lerp/hermite interpolation with extrapolation buffer
- [x] `NetworkedAnimator` — synced animation state
- [x] `ClientPrediction` — local input prediction with server reconciliation
- [x] Tests + Storybook stories for each
## Phase 6 — Integration tests
- [x] `tests/integration.test.ts` — snapshot replay, reconciliation rollback
## Phase 7 — Pre-publish gate
- [x] `bunx turbo lint typecheck test --filter=@suaveplan/r3f-networking` green
- [x] 100% coverage
- [x] Publish: `bun scripts/publish.ts --package @suaveplan/r3f-networking`