Getting Started
Create your first Hello Terrain scene in react-three/fiber
Prerequisites
The React bindings require:
@hello-terrain/react@react-three/fiber8, 9, or 10three0.183.0or newer (React Three Fiber 10 needs0.185.0or newer)reactreact-dom- a WebGPU renderer: the default
Canvason React Three Fiber 10, or aWebGPURendererfromthree/webgpuon 8 / 9
Smallest Working Setup
This is the smallest complete example using Terrain directly inside a WebGPU Canvas:
import { Terrain } from "@hello-terrain/react";
import { Canvas } from "@react-three/fiber";
import { float } from "three/tsl";
const elevation = () => float(0);
export function App() {
return (
<Canvas renderer={{ antialias: true }} camera={{ position: [0, 30, 60] }}>
<ambientLight intensity={0.15} />
<directionalLight intensity={1} position={[1, 1, 1]} />
<Terrain rootSize={128} maxLevel={10} elevation={elevation}>
{({ positionNode }) => (
<meshStandardNodeMaterial positionNode={positionNode} />
)}
</Terrain>
</Canvas>
);
}What This Does
- The
Canvasrenders withTHREE.WebGPURenderer, the React Three Fiber 10 default. Renderer options go on therendererprop. On React Three Fiber 8 or 9, pass an asyncglfactory that returns an initializedWebGPURendererinstead; see Installation. Terraincreates and manages its own terrain handle internally.- The render prop receives
positionNode, which displaces the terrain mesh through a node material.
Customizing The Terrain
Terrain accepts the same terrain options as useTerrain(). See the Params reference for a table that explains each option in detail.
It also accepts R3F primitive props such as castShadow, receiveShadow, position, and visible.
When To Reach For useTerrain()
The inline Terrain form is great for simple scenes. If you need to reuse the same terrain handle across siblings, inspect the graph, or share runtime access with cameras or gameplay systems, use useTerrain() and pass the handle into Terrain.
Continue to useTerrain for that pattern.