Greenfield: Effect-native Three.js for Foldkit
Build a new, independent TypeScript library providing declarative Three.js integration with Foldkit, using Effect as the resource and concurrency runtime.
Research
Study these repositories before implementation:
- https://github.com/mrdoob/three.js
- https://github.com/pmndrs/react-three-fiber
- https://github.com/pmndrs/drei
- https://github.com/OpenAgentsInc/three-effect
- https://github.com/foldkit/foldkit
Compare their architecture, ownership models, scheduling and developer experience.
Treat them as references, not implementations to copy.
Architecture requirements
- Effect-first, with scoped acquisition, cancellation and disposal.
- Declarative scene descriptions and minimal keyed reconciliation.
- Core independent of Foldkit, React and the DOM.
- Thin Foldkit adapter with typed messages and pure updates.
- Independent animation loop with a testable clock.
- Correct ownership of shared GPU resources.
- Renderer boundary capable of supporting WebGPU later.
- Headless scene tests and browser-based visual tests.
- Strict TypeScript without
any, runtime enums or unnecessary type assertions. - https://www.npmjs.com/package/@opsydyn/oxlint-effect all rules no exc eptions oxlint and of fmt
- use bun 1.4.x latest for build and testing
- effects built in fastcheck property based testing suite
First vertical slice
Implement a scene containing a camera, light and rotating cube.
Prove:
- Model changes update existing scene objects rather than recreating them.
- Pointer interaction dispatches a typed Foldkit message.
- Animation runs without causing Foldkit model updates every frame.
- Mount/unmount cycles release owned resources and event handlers.
- Shared resources survive until their final owner releases them.
- Frame advancement and scene updates can be tested deterministically.
Delivery
First produce an architecture decision record comparing a greenfield implementation with extending three-effect.
Then implement only the vertical slice.
Avoid premature Drei parity, scene-specific helpers, ECS systems or physics engines.
Finish with tests, benchmarks, a working demo and a documented public API.