Scaffold a new project
Section titled “Scaffold a new project”create-three-flatland generates a Vite starter with a running WebGPU sprite scene, linting, unit and
Playwright tests, and agent guidance files.
npm create three-flatland@latestpnpm create three-flatlandyarn create three-flatlandbun create three-flatlandThe CLI prompts for the target directory and template. Available templates are three (plain
Three.js) and react (React Three Fiber). For non-interactive use:
pnpm create three-flatland my-app --template reactpnpm create three-flatland --help-t, --template <name> selects a template. --overwrite deletes every existing file and directory
in the target except .git before scaffolding. Back up existing work before using this option.
Install in an existing project
Section titled “Install in an existing project”npm install three-flatland threepnpm add three-flatland threeyarn add three-flatland threebun add three-flatland threeSet up a new project with three-flatland, a 2D sprite and effects libraryfor Three.js using WebGPU and TSL (Three Shader Language).
Read the API reference: https://tjw.dev/three-flatland/llms-full.txt
Install: npm install three-flatland threeRequires: three.js ^0.185.1 and WebGPURenderer from "three/webgpu"Import from: "three-flatland"
Create a minimal project with a Sprite2D on screen. Include:- WebGPU renderer setup with await renderer.init()- Orthographic camera- A sprite loaded with TextureLoaderReact Three Fiber (optional)
Section titled “React Three Fiber (optional)”React is not required. If you’re using React Three Fiber, add the additional dependencies:
npm install three-flatland three @react-three/fiber@10.0.0-alpha.3 react@~19.2.0 react-dom@~19.2.0pnpm add three-flatland three @react-three/fiber@10.0.0-alpha.3 react@~19.2.0 react-dom@~19.2.0yarn add three-flatland three @react-three/fiber@10.0.0-alpha.3 react@~19.2.0 react-dom@~19.2.0bun add three-flatland three @react-three/fiber@10.0.0-alpha.3 react@~19.2.0 react-dom@~19.2.0Set up a new React Three Fiber project with three-flatland, a 2D spriteand effects library for Three.js using WebGPU and TSL.
Read the API reference: https://tjw.dev/three-flatland/llms-full.txt
Install: npm install three-flatland three @react-three/fiber@10.0.0-alpha.3 react@~19.2.0 react-dom@~19.2.0Requires: React ~19.2.0, R3F 10.0.0-alpha.3Import from: "three-flatland/react" (re-exports core + JSX type augmentation)Canvas import: import { Canvas, extend, useFrame, useThree } from "@react-three/fiber/webgpu"
Create a minimal R3F app with a Sprite2D. Include:- Canvas with WebGPU (import from @react-three/fiber/webgpu)- extend() call to register custom elements (Sprite2D, SpriteGroup, etc.)- A sprite loaded with useLoader(TextureLoader, url)- Suspense boundary around components that load assets- useFrame for per-frame animation (refs + imperative updates)- useState(() => ...) for WASM objects (SkiaPaint, SkiaPath) — survives strict modeRequirements
Section titled “Requirements”- Three.js: ^0.185.1 (required for TSL/WebGPU support)
- React: ~19.2.0 (for
three-flatland/react; R3F alpha.3 requiresReact < 19.3) - @react-three/fiber: 10.0.0-alpha.3 (for
three-flatland/react) - Node.js: >= 22 (LTS)
TypeScript
Section titled “TypeScript”three-flatland ships its own type definitions. Three.js uses separate declarations; add them to an existing TypeScript project:
pnpm add -D @types/three@^0.185.4React TypeScript projects also need their usual @types/react and @types/react-dom development dependencies.
The generated starters already include the declarations required by their template.
See the LLMs page for more prompts and machine-readable documentation.