Skip to content

Templates

m4bwav edited this page Oct 26, 2026 · 1 revision

Twelve starters ship in templates/. Each passed tw check when it was made, and its template.json records where and how (verified). Copy one with tw new <template> <dir>; list them with:

tw templates
chart-3d-scatter   3D scatter chart for docs: seeded data, axes with ticks and labels, legend with shape and colour per series, pause and reset buttons, reduced-motion aware, no build [webgl, three 0.186.1]
                   verified 2026-09-26: tw check OK, tw check --reduced-motion OK, tw lint clean, tw shot looked at (axes, labels, four series, legend)
game-starter       Game starter on Vite + TypeScript + Rapier: deterministic fixed-step simulation with no DOM (runs in Node tests), kinematic character controller, pickups, lives, HUD, pause and restart, keyboard and gamepad, window.__game hooks to step, inject input, replay and hash [webgl, three 0.186.1]
                   verified 2026-09-26: npm ci, typecheck and build, 4 Node simulation tests (determinism, movement, fixed step), tw check dist OK, --eval drove 90 ticks through window.__game (player moved 5.9 m, stable hash), tw shot looked at
globe              Globe for docs with no downloads beyond three.js: land drawn from a coarse inline outline into a CanvasTexture, 15 degree graticule, real city coordinates, great-circle route arcs (TubeGeometry), latLonToVector3 helper, CSS2D city labels hidden on the far side and when they collide, hover or keyboard tooltips, OrbitControls with min and max distance, auto-rotation that stops for reduced motion, route table with great-circle distances, no build [webgl, three 0.186.1]
                   verified 2026-09-26: tw check OK (54 draw calls, 48k tris, pixels 12% coverage), tw check --reduced-motion OK (3 render calls, rotation off), tw lint clean, --eval: far-side labels hidden (6 of 12 shown from the home view), N key faced each city in turn and filled the live region, a hover scan picked cities and routes and ignored the far side, longest route Singapore to Los Angeles 14,122 km; tw sheet (current, front, right, top) showed consistent land placement; tw shot at 960x720 looked at: Europe, Africa and the Atlantic in view, hub labels readable on a translucent backing, arcs clear of the frame, Mumbai label hidden where it would overlap Dubai; headless Chrome reported the dark colour scheme, so the light palette was not shot
html-importmap     One HTML file, no build: WebGLRenderer, import map pinned to three 0.186.1, OrbitControls, RoomEnvironment lighting, shadows, Timer-driven animation [webgl, three 0.186.1]
                   verified 2026-09-26: tw check OK, tw sheet, tw video (mp4, webm, gif, mov, canvas capture)
html-webgpu        One HTML file, no build: WebGPURenderer (WebGL 2 fallback), a TSL node material, RenderPipeline with bloom, await renderer.init() before PMREM [webgpu, three 0.186.1]
                   verified 2026-09-26: tw check --webgpu OK on the real WebGPU backend (draw calls 16, PCF shadows), tw shot looked at: TSL knot, bloom, shadow on the floor
product-viewer     Product viewer for one GLB, no build: GLTFLoader with Draco and Meshopt wired, RoomEnvironment light, soft shadow on an invisible floor, camera fitted on load, OrbitControls with damping and limits, loading and error states, colour buttons, keyboard orbit, reduced motion (no auto-rotate, no inertia); Draco and KTX2 decoders load from next to their loaders, so tw new vendors three and both decoders into vendor/ [webgl, three 0.186.1]
                   verified 2026-09-26: tw check OK (also --cdn offline), tw check --reduced-motion OK (eval __tw.variant(3) gave Coral), tw lint clean (index.html, make-model.mjs), tw glb model.glb 239 KB, 8 draw calls, 12,352 triangles, no textures, no decoders; ?model=missing.glb over http shows the error text; tw shot looked at: speaker framed in the middle, fabric, metal cap and rubber foot read clearly, not blown out, soft shadow falling back right, swatches and Pause turning button below; reduced-motion shot shows Turn instead of Pause
r3f                React Three Fiber + drei on Vite + TypeScript: <Canvas> with dpr [1, 2] and PCF shadows, drei OrbitControls (makeDefault), an offline <Environment> built from <Lightformer> panels, useFrame animation, window.__tw.ready from inside the Canvas [webgl, three 0.186.1]
                   verified 2026-09-26: npm ci, typecheck and build with no warnings, tw check OK on dist with no console warnings (also on vite dev and vite preview), tw shot, tw lint clean, tw video --frames-dir on the virtual clock
scroll-hero        Scroll-driven hero, no build: GSAP 3.15.0 ScrollTrigger scrubs one timeline over four text sections, Lenis 1.3.26 smooths the scroll through GSAP's ticker, one fixed three.js canvas rendered on demand behind a poster image, WebGL started after first paint; reduced motion means no Lenis and the final view held still; ?progress=0..1, #progress= or window.__tw.setProgress(p) jumps to any point; tw new vendors three, GSAP and Lenis into vendor/ [webgl, three 0.186.1]
                   verified 2026-09-26: tw new vendored 9 files (2476 KB) and rewrote the import map; tw check OK with --cdn offline (no CDN requests), with --reduced-motion, with ?progress=0.6 and at 390x844; reduced motion: tw diff of the canvas at progress 0 and 1 with the text hidden, 0 pixels (normal mode 14%); the four posters looked at; tw lint clean
splats             Gaussian splat viewer on the r186 native GaussianSplat (WebGPURenderer, WebGL 2 fallback): SPLATLoader, a generated 24,000-splat scene, load and error states, backend readout, auto-rotate off for reduced motion [webgpu, three 0.186.1]
                   verified 2026-09-26: tw check --webgpu OK on the real WebGPU backend (page reports 24,000 splats), tw check --gl swiftshader OK on the WebGL 2 fallback, tw check --reduced-motion OK, tw lint clean, tw shot looked at on both backends: striped sphere, petal ring and ground disc, sorted correctly
surface            3D surface chart z = f(x, y) for docs: indexed BufferGeometry grid with viridis vertex colours (unlit), contour lines at the z ticks, axes with ticks and CSS2D labels, colour bar legend, hover readout of x, y and z, keyboard orbit, pause and reset, reduced-motion aware, render on demand, tables of extremes and a coarse grid, no build [webgl, three 0.186.1]
                   verified 2026-09-26: tw check OK (93 render calls, 12 draw calls, 7.2k tris, pixels 11% coverage), tw check --reduced-motion OK (3 render calls: render on demand holds still, button reads Start rotation), tw lint clean, --eval hover and N key gave correct tooltip and live-region text, tw sheet (current, front, right, top), tw shot at 960x720 and 420x640 looked at: axes, ticks and titles readable, viridis surface with contours and mesh lines, colour bar -6 to 8, nothing clipped (the lowest z tick and first x tick sit close at the front corner, still legible); headless Chrome reported the dark colour scheme, so the light palette was not shot
video-turntable    Product turntable for video: procedural studio model, neutral tone mapping, soft shadows, window.__tw.renderFrame(i, fps) so tw video captures exact frames and a seamless loop [webgl, three 0.186.1]
                   verified 2026-09-26: tw check OK, tw check --reduced-motion OK, tw lint clean, tw shot looked at, tw video mp4 through page renderFrame()
vite-ts            Vite + TypeScript bundler starter: WebGLRenderer, OrbitControls from three/addons, RoomEnvironment lighting, shadows, Timer-driven animation, window.__tw.ready after the first frame [webgl, three 0.186.1]
                   verified 2026-09-26: npm ci, typecheck and build with no warnings, tw check OK on dist with no console warnings (also on vite dev and vite preview), tw shot, tw lint clean, tw video --frames-dir on the virtual clock

Notes on using them

  • html-importmap, html-webgpu, chart-3d-scatter, surface, globe, product-viewer, scroll-hero, splats and video-turntable are single pages with no build. Their import maps pin three 0.186.1 on jsDelivr; tw check serves those files from node_modules or the tw cache when it can (cdn: line).
  • product-viewer and scroll-hero are marked "vendor": true, so tw new copies three (and the Draco and KTX2 decoders, or GSAP and Lenis) into vendor/ and rewrites the import map; --no-vendor keeps the CDN. tw new also writes product-viewer's sample model.glb with make-model.mjs and splats' scene.splat with make-splat.mjs (since 0.6.3, the binaries are not in the repository).
  • vite-ts, r3f and game-starter need a build: run npm ci in the new folder, build, then tw check dist/. The browser tests build and check them only when their own node_modules exists.
  • html-webgpu and splats run on WebGPU where the browser has an adapter and fall back to WebGL 2 otherwise; tw check --webgpu and tw check --gl swiftshader check each path.
  • Headless Chrome reports prefers-color-scheme: dark; use --color-scheme light to see a light palette.

The Recipes page has a copy, check and record walk-through.

Clone this wiki locally