@json-render/react-three-fiber
React Three Fiber renderer for json-render. 19 built-in 3D components.
Two Entry Points
| Entry Point |
Exports |
Use For |
@json-render/react-three-fiber/catalog |
threeComponentDefinitions |
Catalog schemas (no R3F dependency, safe for server) |
@json-render/react-three-fiber |
threeComponents, ThreeRenderer, ThreeCanvas, schemas |
R3F implementations and renderer |
Usage Pattern
Pick the 3D components you need from the standard definitions:
import { defineCatalog } from "@json-render/core";
import { schema } from "@json-render/react/schema";
import { threeComponentDefinitions } from "@json-render/react-three-fiber/catalog";
import { defineRegistry } from "@json-render/react";
import { threeComponents, ThreeCanvas } from "@json-render/react-three-fiber";
// Catalog: pick definitions
const catalog = defineCatalog(schema, {
components: {
Box: threeComponentDefinitions.Box,
Sphere: threeComponentDefinitions.Sphere,
AmbientLight: threeComponentDefinitions.AmbientLight,
DirectionalLight: threeComponentDefinitions.DirectionalLight,
OrbitControls: threeComponentDefinitions.OrbitControls,
},
actions: {},
});
// Registry: pick matching implementations
const { registry } = defineRegistry(catalog, {
components: {
Box: threeComponents.Box,
Sphere: threeComponents.Sphere,
AmbientLight: threeComponents.AmbientLight,
DirectionalLight: threeComponents.DirectionalLight,
OrbitControls: threeComponents.OrbitControls,
},
});
Rendering
ThreeCanvas (convenience wrapper)
<ThreeCanvas
spec={spec}
registry={registry}
shadows
camera={{ position: [5, 5, 5], fov: 50 }}
style={{ width: "100%", height: "100vh" }}
/>
Manual Canvas setup
import { Canvas } from "@react-three/fiber";
import { ThreeRenderer } from "@json-render/react-three-fiber";
<Canvas shadows>
<ThreeRenderer spec={spec} registry={registry}>
{/* Additional R3F elements */}
</ThreeRenderer>
</Canvas>
Available Components (19)
Primitives (7)
Box -- width, height, depth, material
Sphere -- radius, widthSegments, heightSegments, material
Cylinder -- radiusTop, radiusBottom, height, material
Cone -- radius, height, material
Torus -- radius, tube, material
Plane -- width, height, material
Capsule -- radius, length, material
All primitives share: position, rotation, scale, castShadow, receiveShadow, material.
Lights (4)
AmbientLight -- color, intensity
DirectionalLight -- position, color, intensity, castShadow
PointLight -- position, color, intensity, distance, decay
SpotLight -- position, color, intensity, angle, penumbra
Other (8)
Group -- container with position/rotation/scale, supports children
Model -- GLTF/GLB loader via url prop
Environment -- HDRI environment map (preset, background, blur, intensity)
Fog -- linear fog (color, near, far)
GridHelper -- reference grid (size, divisions, color)
Text3D -- SDF text (text, fontSize, color, anchorX, anchorY)
PerspectiveCamera -- camera (position, fov, near, far, makeDefault)
OrbitControls -- orbit controls (enableDamping, enableZoom, autoRotate)
Shared Schemas
Reusable Zod schemas for custom 3D catalog definitions:
import { vector3Schema, materialSchema, transformProps, shadowProps } from "@json-render/react-three-fiber";
import { z } from "zod";
// Custom 3D component
const myComponentDef = {
props: z.object({
...transformProps,
...shadowProps,
material: materialSchema.nullable(),
myCustomProp: z.string(),
}),
description: "My custom 3D component",
};
Material Schema
materialSchema = z.object({
color: z.string().nullable(), // default "#ffffff"
metalness: z.number().nullable(), // default 0
roughness: z.number().nullable(), // default 1
emissive: z.string().nullable(), // default "#000000"
emissiveIntensity: z.number().nullable(), // default 1
opacity: z.number().nullable(), // default 1
transparent: z.boolean().nullable(), // default false
wireframe: z.boolean().nullable(), // default false
});
Spec Format
3D specs use the standard json-render flat element format:
{
"root": "scene",
"elements": {
"scene": {
"type": "Group",
"props": { "position": [0, 0, 0] },
"children": ["light", "box"]
},
"light": {
"type": "AmbientLight",
"props": { "intensity": 0.5 },
"children": []
},
"box": {
"type": "Box",
"props": {
"position": [0, 0.5, 0],
"material": { "color": "#4488ff", "metalness": 0.3, "roughness": 0.7 }
},
"children": []
}
}
}
Dependencies
Peer dependencies required:
@react-three/fiber >= 8.0.0
@react-three/drei >= 9.0.0
three >= 0.160.0
react ^19.0.0
zod ^4.0.0
1---2name: react-three-fiber3description: React Three Fiber 3D renderer for json-render. Use when working with @json-render/react-three-fiber, building 3D scenes from JSON specs, rendering meshes/lights/models/environments, or integrating Three.js with json-render catalogs.4metadata:5 source: https://skillmd.com/skills/om-scogo/react-three-fiber6---78# @json-render/react-three-fiber910React Three Fiber renderer for json-render. 19 built-in 3D components.1112## Two Entry Points1314| Entry Point | Exports | Use For |15|-------------|---------|---------|16| `@json-render/react-three-fiber/catalog` | `threeComponentDefinitions` | Catalog schemas (no R3F dependency, safe for server) |17| `@json-render/react-three-fiber` | `threeComponents`, `ThreeRenderer`, `ThreeCanvas`, schemas | R3F implementations and renderer |1819## Usage Pattern2021Pick the 3D components you need from the standard definitions:2223```typescript24import { defineCatalog } from "@json-render/core";25import { schema } from "@json-render/react/schema";26import { threeComponentDefinitions } from "@json-render/react-three-fiber/catalog";27import { defineRegistry } from "@json-render/react";28import { threeComponents, ThreeCanvas } from "@json-render/react-three-fiber";2930// Catalog: pick definitions31const catalog = defineCatalog(schema, {32 components: {33 Box: threeComponentDefinitions.Box,34 Sphere: threeComponentDefinitions.Sphere,35 AmbientLight: threeComponentDefinitions.AmbientLight,36 DirectionalLight: threeComponentDefinitions.DirectionalLight,37 OrbitControls: threeComponentDefinitions.OrbitControls,38 },39 actions: {},40});4142// Registry: pick matching implementations43const { registry } = defineRegistry(catalog, {44 components: {45 Box: threeComponents.Box,46 Sphere: threeComponents.Sphere,47 AmbientLight: threeComponents.AmbientLight,48 DirectionalLight: threeComponents.DirectionalLight,49 OrbitControls: threeComponents.OrbitControls,50 },51});52```5354## Rendering5556### ThreeCanvas (convenience wrapper)5758```tsx59<ThreeCanvas60 spec={spec}61 registry={registry}62 shadows63 camera={{ position: [5, 5, 5], fov: 50 }}64 style={{ width: "100%", height: "100vh" }}65/>66```6768### Manual Canvas setup6970```tsx71import { Canvas } from "@react-three/fiber";72import { ThreeRenderer } from "@json-render/react-three-fiber";7374<Canvas shadows>75 <ThreeRenderer spec={spec} registry={registry}>76 {/* Additional R3F elements */}77 </ThreeRenderer>78</Canvas>79```8081## Available Components (19)8283### Primitives (7)84- `Box` -- width, height, depth, material85- `Sphere` -- radius, widthSegments, heightSegments, material86- `Cylinder` -- radiusTop, radiusBottom, height, material87- `Cone` -- radius, height, material88- `Torus` -- radius, tube, material89- `Plane` -- width, height, material90- `Capsule` -- radius, length, material9192All primitives share: `position`, `rotation`, `scale`, `castShadow`, `receiveShadow`, `material`.9394### Lights (4)95- `AmbientLight` -- color, intensity96- `DirectionalLight` -- position, color, intensity, castShadow97- `PointLight` -- position, color, intensity, distance, decay98- `SpotLight` -- position, color, intensity, angle, penumbra99100### Other (8)101- `Group` -- container with position/rotation/scale, supports children102- `Model` -- GLTF/GLB loader via url prop103- `Environment` -- HDRI environment map (preset, background, blur, intensity)104- `Fog` -- linear fog (color, near, far)105- `GridHelper` -- reference grid (size, divisions, color)106- `Text3D` -- SDF text (text, fontSize, color, anchorX, anchorY)107- `PerspectiveCamera` -- camera (position, fov, near, far, makeDefault)108- `OrbitControls` -- orbit controls (enableDamping, enableZoom, autoRotate)109110## Shared Schemas111112Reusable Zod schemas for custom 3D catalog definitions:113114```typescript115import { vector3Schema, materialSchema, transformProps, shadowProps } from "@json-render/react-three-fiber";116import { z } from "zod";117118// Custom 3D component119const myComponentDef = {120 props: z.object({121 ...transformProps,122 ...shadowProps,123 material: materialSchema.nullable(),124 myCustomProp: z.string(),125 }),126 description: "My custom 3D component",127};128```129130## Material Schema131132```typescript133materialSchema = z.object({134 color: z.string().nullable(), // default "#ffffff"135 metalness: z.number().nullable(), // default 0136 roughness: z.number().nullable(), // default 1137 emissive: z.string().nullable(), // default "#000000"138 emissiveIntensity: z.number().nullable(), // default 1139 opacity: z.number().nullable(), // default 1140 transparent: z.boolean().nullable(), // default false141 wireframe: z.boolean().nullable(), // default false142});143```144145## Spec Format1461473D specs use the standard json-render flat element format:148149```json150{151 "root": "scene",152 "elements": {153 "scene": {154 "type": "Group",155 "props": { "position": [0, 0, 0] },156 "children": ["light", "box"]157 },158 "light": {159 "type": "AmbientLight",160 "props": { "intensity": 0.5 },161 "children": []162 },163 "box": {164 "type": "Box",165 "props": {166 "position": [0, 0.5, 0],167 "material": { "color": "#4488ff", "metalness": 0.3, "roughness": 0.7 }168 },169 "children": []170 }171 }172}173```174175## Dependencies176177Peer dependencies required:178- `@react-three/fiber` >= 8.0.0179- `@react-three/drei` >= 9.0.0180- `three` >= 0.160.0181- `react` ^19.0.0182- `zod` ^4.0.0