4.4 KiB
4.4 KiB
Tasks: enterprise-r3f-earth
Change ID: enterprise-r3f-earth
Package: @suaveplan/r3f-earth
Target path: r3f/geo/r3f-earth
Prerequisites on Verdaccio: @suaveplan/error, @suaveplan/types, @suaveplan/logger
0. Pre-flight (non-negotiable)
- 0.1 Confirm clean working tree (
git statusreports nothing) and no in-flight worktrees with uncommitted work (git worktree listthengit statusin 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.mdmatchesfind packages -maxdepth 3 -name package.jsoncount. Drift here means a prior change archived without regenerating the manifest.
1. Scaffold
- Create directory tree per
proposal.md. package.jsonat0.1.0,"sideEffects": false, exports"."+ per-component subpaths +utils/geo-math.- Deps:
@suaveplan/error workspace:^,@suaveplan/types workspace:^,@suaveplan/logger workspace:^,zod catalog:forms,@opentelemetry/api catalog:observability,three catalog:r3f,@react-three/fiber catalog:r3f,@react-three/drei catalog:r3f,react catalog:react,tslib catalog:build. - Peer deps:
react,three. - DevDeps:
vitest catalog:testing,@vitest/coverage-istanbul catalog:testing,@suaveplan/testing workspace:^,@suaveplan/testing-dom workspace:^,react-dom catalog:react,@testing-library/react catalog:testing,@storybook/react catalog:storybook. tsconfig.jsonextendingreact-library.json;vitest.config.tswithpool: 'forks', jsdom environment,fileParallelism: false.- Scripts:
lint,typecheck,test,test:coverage,build,docs:check.
2. Types and errors
- Define all prop interfaces and Zod schemas in
src/types/r3f-earth.types.ts. - Write
r3f-earth.types.md(≥200 words). src/error-codes.ts:R3F_EARTH_INVALID_COORDS,R3F_EARTH_GEOJSON_PARSE_FAILED;registerR3fEarthErrorCodes(); eager call.
3. Geo math utility
- Implement
src/utils/geo-math/geo-math.ts:latLngToVector3(lat, lng, radius): THREE.Vector3— spherical to Cartesian.vector3ToLatLng(v: THREE.Vector3): [lat, lng]— Cartesian to spherical.createArcPoints(from, to, numPoints, height): THREE.Vector3[]— arc for shipping lanes.createGeoJsonGeometry(feature, radius): THREE.BufferGeometry— polygon to geometry.
- Write
geo-math.test.ts: round-trip lat/lng ↔ Vector3; arc midpoint above surface; known coordinate values. - Write
geo-math.md(≥200 words).
4. Components
For each of Earth, EarthScene, EarthMarker, EarthLane, EarthOverlay:
- Implement the React component using
@react-three/fiberprimitives and@react-three/dreihelpers. Earth: sphere mesh with texture, bump map, optional cloud sphere, atmosphere; country highlight via mouse raycast.EarthScene: wrapsEarthin a<Canvas>withOrbitControls, background, and lighting.EarthMarker: position vialatLngToVector3; optional label via<Html>from drei.EarthLane: arc curve viacreateArcPoints; animated via shader orTubeGeometry.EarthOverlay: GeoJSON polygon rendered asLineSegmentson the sphere surface.- Write
.test.tsxfor each: renders without crash; key props change updates mesh; click handlers fire;{ timeout: 5000 }. - Write
.stories.tsxfor each: default story + playground + variants story (perCLAUDE.mdrequirement). - Write
.mdper component (≥200 words, simple + advanced examples, API reference).
5. OTel
- Counter
r3f_earth.renders_totalincremented onEarthmount;r3f_earth.markers_totalon marker mount.
6. Docs + verify + publish
- Root
README.md: quick-start globe with markers and lanes, GeoJSON overlay example, API table. bunx turbo lint --filter=@suaveplan/r3f-earth— zero errors.bunx turbo typecheck --filter=@suaveplan/r3f-earth— zero errors.bunx turbo test --filter=@suaveplan/r3f-earth— all pass.bunx turbo test:coverage --filter=@suaveplan/r3f-earth— 100%.bun scripts/publish.ts --package @suaveplan/r3f-earth.- Update
CLAUDE.md; archive toopenspec/archive/2026-04-24-enterprise-r3f-earth/.