import { pageMetadata } from "@/lib/page-metadata" export const metadata = pageMetadata("docs/api/react-three-fiber") # @json-render/react-three-fiber React Three Fiber renderer for json-render. 19 built-in 3D components for meshes, lights, models, environments, text, cameras, and controls. ## Installation ```bash npm install @json-render/react-three-fiber @json-render/core @json-render/react @react-three/fiber @react-three/drei three zod ``` ## Entry Points
| Entry Point | Exports | Use For |
|---|---|---|
@json-render/react-three-fiber |
threeComponents, ThreeRenderer, ThreeCanvas, schemas |
React Three Fiber implementations and renderer |
@json-render/react-three-fiber/catalog |
threeComponentDefinitions |
Catalog schemas (no R3F dependency, safe for server) |
| Component | Description | Key Props |
|---|---|---|
Box |
Box mesh (default 1x1x1) | width, height, depth, material |
Sphere |
Sphere mesh | radius, widthSegments, heightSegments, material |
Cylinder |
Cylinder mesh | radiusTop, radiusBottom, height, material |
Cone |
Cone mesh | radius, height, material |
Torus |
Torus (donut) mesh | radius, tube, material |
Plane |
Flat plane mesh | width, height, material |
Capsule |
Capsule mesh | radius, length, material |
position, rotation, scale, castShadow, receiveShadow, material.
### Material Schema
| Property | Type | Default |
|---|---|---|
color |
string |
"#ffffff" |
metalness |
number |
0 |
roughness |
number |
1 |
emissive |
string |
"#000000" |
emissiveIntensity |
number |
1 |
opacity |
number |
1 |
transparent |
boolean |
false |
wireframe |
boolean |
false |
| Component | Description | Key Props |
|---|---|---|
AmbientLight |
Uniform illumination | color, intensity |
DirectionalLight |
Sunlight-style | position, color, intensity, castShadow |
PointLight |
Radiates from a point | position, color, intensity, distance, decay |
SpotLight |
Cone of light | position, color, intensity, angle, penumbra |
| Component | Description | Key Props |
|---|---|---|
Group |
Container for children | position, rotation, scale |
Model |
GLTF/GLB model loader | url, position, rotation, scale |
Environment |
HDRI environment map | preset, background, blur, intensity |
Fog |
Linear fog effect | color, near, far |
GridHelper |
Reference grid | size, divisions, color |
Text3D |
3D text (SDF) | text, fontSize, color, anchorX, anchorY |
PerspectiveCamera |
Camera | position, fov, near, far, makeDefault |
OrbitControls |
Camera controls | enableDamping, enableZoom, autoRotate |
| Export | Description |
|---|---|
vector3Schema |
z.tuple([z.number(), z.number(), z.number()]) |
materialSchema |
Standard material props (color, metalness, roughness, etc.) |
transformProps |
{'{ position, rotation, scale }'} schema fields |
shadowProps |
{'{ castShadow, receiveShadow }'} schema fields |
| Prop | Type | Description |
|---|---|---|
spec |
Spec | null |
The spec to render as a 3D scene |
registry |
ComponentRegistry |
Component registry from defineRegistry |
store |
StateStore |
External state store (controlled mode) |
initialState |
Record<string, unknown> |
Initial state (uncontrolled mode) |
handlers |
Record<string, Function> |
Action handlers |
loading |
boolean |
Whether the spec is streaming |
children |
ReactNode |
Additional R3F elements alongside the spec |
ThreeRendererProps with Canvas options:
| Prop | Type | Description |
|---|---|---|
shadows |
boolean |
Enable shadow maps |
camera |
object |
Default camera config (position, fov, etc.) |
className |
string |
CSS class for the canvas container |
style |
CSSProperties |
Inline styles for the canvas container |