Initial Commit
This commit is contained in:
57
openspec/changes/enterprise-gaming-r3f-terrain/proposal.md
Normal file
57
openspec/changes/enterprise-gaming-r3f-terrain/proposal.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# OpenSpec Change: enterprise-gaming-r3f-terrain
|
||||
|
||||
- **Change ID**: enterprise-gaming-r3f-terrain
|
||||
- **Package**: `@suaveplan/r3f-terrain`
|
||||
- **Category**: gaming/scene
|
||||
- **Target path**: `gaming/scene/r3f-terrain`
|
||||
- **Status**: PROPOSED
|
||||
- **Date**: 2026-04-24
|
||||
- **Reference spec**: `/mnt/s/web/suaveplan/enterprise/r3f-terrain.md`
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
Deliver `@suaveplan/r3f-terrain` on the genesis branch from scratch at enterprise quality. The package provides procedural terrain with chunked LOD for React Three Fiber. A `TerrainSystem` divides world space into equal-size chunks; each chunk generates a height-mapped `PlaneGeometry` using a pluggable noise function (simplex, perlin, or caller-supplied); LOD is managed by camera distance — near chunks use high subdivision, far chunks use low. Biome tinting (grass/rock/snow) is applied via vertex color or shader. Genesis adds Zod chunk config schemas, structured errors, OTel chunk-load histogram, and 100% coverage.
|
||||
|
||||
---
|
||||
|
||||
## Available workspace deps
|
||||
|
||||
`@suaveplan/error`, `@suaveplan/types`, `@suaveplan/events`, `@suaveplan/spatial-hash`, react, `@react-three/fiber`, `@react-three/drei`, three.
|
||||
|
||||
---
|
||||
|
||||
## Public API surface (key exports)
|
||||
|
||||
```ts
|
||||
function Terrain(props: TerrainProps): JSX.Element
|
||||
// - chunkSize, worldSize, maxLOD, heightScale, noiseFn, biomeMap
|
||||
|
||||
function useTerrainHeight(x: number, z: number): number // sample height at world position
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File layout
|
||||
|
||||
```text
|
||||
gaming/scene/r3f-terrain/
|
||||
package.json / tsconfig.json / vitest.config.ts
|
||||
src/
|
||||
index.ts
|
||||
error-codes.ts
|
||||
constants/index.ts
|
||||
types/common.ts + md
|
||||
core/
|
||||
terrain-system/ (ts + md + types + test + index)
|
||||
chunk-manager/ (ts + md + types + test + index)
|
||||
lod-controller/ (ts + md + types + test + index)
|
||||
components/
|
||||
Terrain/ (tsx + md + test + stories + index)
|
||||
TerrainChunk/ (tsx + md + test + stories + index)
|
||||
utils/
|
||||
noise.ts + md + test
|
||||
height-sample.ts + md + test
|
||||
tests/integration.test.ts
|
||||
```
|
||||
53
openspec/changes/enterprise-gaming-r3f-terrain/tasks.md
Normal file
53
openspec/changes/enterprise-gaming-r3f-terrain/tasks.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Tasks: enterprise-gaming-r3f-terrain
|
||||
|
||||
## 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
|
||||
|
||||
- [ ] Create `gaming/scene/r3f-terrain/` (`@suaveplan/r3f-terrain`, `0.1.0`, `sideEffects: false`)
|
||||
|
||||
## Phase 2 — Error codes + types
|
||||
|
||||
- [ ] `src/error-codes.ts` + `src/types/common.ts` + `common.md`
|
||||
|
||||
## Phase 3 — Noise utility
|
||||
|
||||
- [ ] `src/utils/noise.ts` — simplex 2D noise, octave FBM
|
||||
- [ ] Tests + docs
|
||||
|
||||
## Phase 4 — Height sample utility
|
||||
|
||||
- [ ] `src/utils/height-sample.ts` — world XZ → height value from active terrain
|
||||
- [ ] Tests + docs
|
||||
|
||||
## Phase 5 — Chunk manager
|
||||
|
||||
- [ ] Camera-relative chunk loading/unloading, spatial hash for active set
|
||||
- [ ] Tests + docs
|
||||
|
||||
## Phase 6 — LOD controller
|
||||
|
||||
- [ ] Distance → subdivision level mapping, hysteresis band
|
||||
- [ ] Tests + docs
|
||||
|
||||
## Phase 7 — Terrain system
|
||||
|
||||
- [ ] Chunk generation with height + biome vertex color
|
||||
- [ ] Tests + docs
|
||||
|
||||
## Phase 8 — Components
|
||||
|
||||
- [ ] `TerrainChunk` — single chunk mesh
|
||||
- [ ] `Terrain` — top-level system with chunk manager wiring
|
||||
- [ ] Tests + Storybook stories
|
||||
|
||||
## Phase 9 — Integration + pre-publish gate
|
||||
|
||||
- [ ] `tests/integration.test.ts`
|
||||
- [ ] `bunx turbo lint typecheck test --filter=@suaveplan/r3f-terrain` green
|
||||
- [ ] 100% coverage
|
||||
- [ ] Publish: `bun scripts/publish.ts --package @suaveplan/r3f-terrain`
|
||||
Reference in New Issue
Block a user