Skip to content
Agents tracked: 440 Downloads (7d): 202M down 19.5% GitHub stars: 10.4M Releases (7d): 607 Agent status: 1 with issuesSince last limit reset: Claude 28d · Codex 0d Updated Oct 21, 2026

React Three Fiber Examples You Can Edit and Run

Five small React Three Fiber examples written by AgentGid, one idea each. Every one runs in your browser: change the code and see the result at once, or describe a change and let AI rewrite it. The screenshots are taken from the same code by our server, which also checks that each example starts without errors.

React Three Fiber: usage and stats 74 AI-built projects use it

Try them all in one place

import { Canvas, useFrame } from '@react-three/fiber'
import { useMemo, useRef } from 'react'
import * as THREE from 'three'

const SIDE = 50
const COUNT = SIDE * SIDE

function Wave() {
  const ref = useRef()
  // reused every frame: no new objects inside the loop
  const dummy = useMemo(() => new THREE.Object3D(), [])
  const color = useMemo(() => new THREE.Color(), [])
  useFrame(({ clock }) => {
    const t = clock.elapsedTime
    let i = 0
    for (let x = 0; x < SIDE; x++) {
      for (let z = 0; z < SIDE; z++) {
        const d = Math.hypot(x - SIDE / 2, z - SIDE / 2)
        const y = Math.sin(d * 0.35 - t * 2) * 0.8
        dummy.position.set(x - SIDE / 2, y, z - SIDE / 2)
        dummy.scale.setScalar(0.8)
        dummy.updateMatrix()
        ref.current.setMatrixAt(i, dummy.matrix)
        ref.current.setColorAt(i, color.setHSL(0.58 + y * 0.08, 0.7, 0.55))
        i++
      }
    }
    ref.current.instanceMatrix.needsUpdate = true
    ref.current.instanceColor.needsUpdate = true
  })
  return (
    <instancedMesh ref={ref} args={[undefined, undefined, COUNT]}>
      <boxGeometry args={[0.9, 0.9, 0.9]} />
      <meshStandardMaterial />
    </instancedMesh>
  )
}

export default function App() {
  return (
    <Canvas camera={{ position: [42, 36, 42], fov: 40 }}>
      <color attach="background" args={['#111']} />
      <ambientLight intensity={0.6} />
      <directionalLight position={[10, 20, 5]} intensity={2.5} />
      <Wave />
    </Canvas>
  )
}
Ctrl/⌘ + Enter runs

Free for signed-in members, with a daily limit. Describe the change in plain words; the new code runs only in your browser.

2,500 cubes drawn in one draw call: one instancedMesh, animated in useFrame by changing each instance's matrix. Code written by AgentGid [1]. How it works, with a screenshot →

Checked Oct 12, 2026: each example starts without errors in Chromium with React Three Fiber 9.8.1, three.js 0.186.1, Drei 10.7.9, React 19.3.0. Needs WebGL.

Sources

  1. Docs: Scaling performance
  2. three.js docs: InstancedMesh
  3. Docs: Hooks (useFrame, useThree)
  4. Docs: Canvas (the shadows prop)
  5. Docs: Objects, properties and constructor arguments (dash-case props)
  6. three.js docs: DirectionalLightShadow
  7. Docs: Performance pitfalls
  8. Docs: Events
  9. Drei docs: Controls (OrbitControls, makeDefault)
  10. three.js docs: OrbitControls

Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.

Building something with React Three Fiber? Ask AgentGid →