Files
suaveplan/openspec/changes/enterprise-gaming-r3f-terrain/proposal.md
2026-05-27 23:29:53 +01:00

2.0 KiB

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)

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

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