PluginBench
Skill
Official
Pass
Audit score 90

react-three-fiber

vercel-labs/json-render

Render interactive 3D scenes from JSON specs using React Three Fiber and Three.js

What is react-three-fiber?

@json-render/react-three-fiber is a React Three Fiber renderer for json-render that lets you build 3D scenes declaratively from JSON specifications. Use it when you need to render 3D meshes, lights, models, and environments without writing imperative Three.js code, or when integrating 3D content into json-render catalogs.

  • Render 19 built-in 3D components (primitives, lights, cameras, controls, models, environments)
  • Define 3D scenes as JSON specs with a flat element structure
  • Load GLTF/GLB models and HDRI environment maps
  • Apply materials with metalness, roughness, emissive properties, and transparency
  • Support shadows, fog, grids, and 3D text rendering
  • Compose scenes with Groups and OrbitControls for interactive navigation

How to install react-three-fiber

npx skills add https://github.com/vercel-labs/json-render --skill react-three-fiber
Prerequisites
  • @react-three/fiber >= 8.0.0
  • @react-three/drei >= 9.0.0
  • three >= 0.160.0
  • react ^19.0.0
  • zod ^4.0.0
Claude Code
Cursor
Windsurf
Cline

How to use react-three-fiber

  1. 1.Import component definitions from @json-render/react-three-fiber/catalog (Box, Sphere, Lights, etc.)
  2. 2.Define a catalog using defineCatalog with your selected 3D component definitions
  3. 3.Create a registry using defineRegistry with matching component implementations
  4. 4.Write your 3D scene as a JSON spec with a root element and nested children
  5. 5.Render using ThreeCanvas (convenience wrapper) or Canvas + ThreeRenderer (manual setup)
  6. 6.Customize camera, shadows, and canvas styling via props or Canvas configuration

Use cases

Good for
  • Build interactive product visualizers from JSON scene definitions
  • Create data visualization dashboards with 3D charts and models
  • Render architectural or design previews from structured scene specs
  • Integrate 3D content into json-render catalogs alongside other component types
  • Generate dynamic 3D environments with lighting and materials from configuration
Who it's for
  • Full-stack developers building 3D web experiences with React
  • Teams using json-render for declarative UI and wanting 3D support
  • Developers familiar with Three.js looking for a JSON-driven approach
  • Product teams needing configurable 3D visualizations without custom code

react-three-fiber FAQ

What's the difference between the two entry points?

@json-render/react-three-fiber/catalog exports schemas only (safe for server, no R3F dependency). @json-render/react-three-fiber exports implementations (ThreeRenderer, ThreeCanvas, threeComponents) for client-side rendering.

Can I load external 3D models?

Yes, use the Model component with a url prop to load GLTF/GLB files. You can also use Environment for HDRI maps.

How do I add interactivity like rotating or zooming?

Include OrbitControls in your scene spec with props like enableDamping, enableZoom, and autoRotate to enable camera controls.

Can I use custom 3D components beyond the 19 built-ins?

Yes, you can define custom components using the shared schemas (vector3Schema, materialSchema, transformProps, shadowProps) and add them to your catalog and registry.

Do I need to write Three.js code directly?

No, the entire scene is defined in JSON. You only write TypeScript/React for catalog and registry setup; all 3D content is declarative.

Full instructions (SKILL.md)

Source of truth, from vercel-labs/json-render.


name: react-three-fiber description: 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.

@json-render/react-three-fiber

React Three Fiber renderer for json-render. 19 built-in 3D components.

Two Entry Points

Entry PointExportsUse For
@json-render/react-three-fiber/catalogthreeComponentDefinitionsCatalog schemas (no R3F dependency, safe for server)
@json-render/react-three-fiberthreeComponents, ThreeRenderer, ThreeCanvas, schemasR3F 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