Hey r/threejs! A while back I shared Click-to-Source 3D, a Vite plugin that lets you click any mesh in a three.js or React Three Fiber scene and jump to the line of code that made it. It's now past 8,000 npm downloads, so thank you to everyone who tried it and sent feedback.
v0.2.1 is out, and it's focused on the part that comes after finding where something was made: finding the bug.
What's new
- Used in: select a mesh and see every line in your project that touches it, not just where it was created. It follows the object through variables, class fields, refs (
meshRef.current in useFrame) and helper functions across files, and marks which lines run every frame, on an event or on a timer. - Live values: watch the selected object's position, rotation, material values, uniforms like
uTime and more change in real time, each with a little graph and a link to the line that writes it. - Pause, rewind and step: a video-style player on the canvas. Pause the whole scene, scrub back through the last 10 seconds, step frame by frame, then play on from where your app really was. Great for catching that one frame where something jumps.
- Segment advice: for spheres, cylinders and the like, it tells you how many segments the object actually needs at its size on screen ("6,016 triangles · 28 is smooth at 66 px"), with a button to apply it.
- Device info for AI assistants: if you use Claude Code, Cursor or VS Code over MCP, your assistant can now see your CPU, RAM and GPU and what the scene costs, so it stops adding things your machine can't handle.
- Security and fixes: safer saving back to source, a hardened dev server, and a fix for particles (like dust in light shafts) stealing clicks from the objects behind them.
Setup is one command, with no imports or components to add to your code:
npx click-to-source-3d init
It works with plain three.js and React Three Fiber on Vite, and it's dev-only, so nothing ends up in your production build.
Limits, to be upfront: it's Vite only for now (webpack and Next.js are on the roadmap). The rewind replays object positions; it doesn't run your code backwards, so physics and timers in your app aren't rewound.
Here's a short demo of what's new 👇
This project was built with AI assistance.
Feedback and bug reports are very welcome, especially if something doesn't work in your setup. 🙏