The render introspection OS for three.js
Deep causal analysis, trace-based debugging, and actionable optimization for WebGL/WebGPU apps.
π§ Major Redesign In Progress
3Lens is undergoing a complete architectural redesign. The new system is built on 5 foundational primitives: Capture, Model, Query, Visualize, and Act + Verify. See the Architecture section for details.
3Lens is not just another metrics panel. It's a render introspection OS where every tool is a view over shared primitives:
- Deep Trace + Causal Analysis β Understand why something is slow, not just that it's slow
- Offline Diff/Regression β Compare traces across sessions, catch regressions in CI
- Resource Leak Detection β Full lifecycle tracking, not just counts
- Actionable Optimization Paths β Click a metric β see the blame chain β fix the culprit
- Multi-Context Support β First-class support for multiple renderers, scenes, cameras
| Package | Description |
|---|---|
@3lens/kernel |
Event capture, entity graph, query engine, trace format |
@3lens/runtime |
Public API: createLens(), context registration, discovery |
@3lens/devtools |
Batteries-included meta-package for most users |
| Package | Description |
|---|---|
@3lens/host-manual |
Vanilla three.js (user provides renderer/scene/camera) |
@3lens/host-r3f |
React Three Fiber integration |
@3lens/host-tres |
TresJS/Vue integration |
@3lens/host-worker |
OffscreenCanvas/Worker support |
| Package | Description |
|---|---|
@3lens/addon-inspector |
Entity graph browser + blame navigator |
@3lens/addon-perf |
Performance analysis with attribution |
@3lens/addon-memory |
Resource lifecycle + leak detection |
@3lens/addon-diff |
Frame/session/trace comparison |
@3lens/addon-shader |
Shader introspection |
| Package | Description |
|---|---|
@3lens/ui-core |
Framework-agnostic UI shell |
@3lens/ui-web |
Web Components for universal mounting |
| Package | Description |
|---|---|
@3lens/mount-angular |
Angular service/component wrapper |
@3lens/mount-react |
React context/hooks wrapper |
@3lens/mount-vue |
Vue plugin/composables |
@3lens/mount-svelte |
Svelte action/component |
| Package | Description |
|---|---|
@3lens/vite-plugin |
Dev server injection |
@3lens/cli |
Trace recording, diff, validation commands |
Note: Packages are not yet published. This shows the target API.
import { createLens, manualHost, uiOverlay } from "@3lens/devtools";
const lens = createLens({
ui: uiOverlay(),
addons: ["inspector", "perf", "memory"],
});
lens.registerContext({
id: "main",
host: manualHost({ renderer, scene, camera }),
});
lens.attach();<script type="module">
import '@3lens/ui-web';
import { createLens, manualHost } from '@3lens/runtime';
const lens = createLens();
lens.registerContext({ id: 'main', host: manualHost({ renderer, scene, camera }) });
const overlay = document.querySelector('three-lens-overlay');
overlay.lens = lens;
</script>
<three-lens-overlay></three-lens-overlay>βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Your App β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Mount Kit (optional) β Host Integration β
β @3lens/mount-react β @3lens/host-manual β
β @3lens/mount-vue β @3lens/host-r3f β
β @3lens/mount-angular β @3lens/host-tres β
β @3lens/mount-svelte β @3lens/host-worker β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β @3lens/runtime β
β createLens() β’ registerContext() β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Addons β UI β
β @3lens/addon-inspector β @3lens/ui-core β
β @3lens/addon-perf β @3lens/ui-web β
β @3lens/addon-memory β β
β @3lens/addon-diff β β
β @3lens/addon-shader β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β @3lens/kernel β
β Capture β’ Entity Graph β’ Query β’ Trace β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Capture β Authoritative event stream (render events, resource lifecycle)
- Model β Unified typed dependency graph (entities + relationships)
- Query β Tools query the model, not the renderer directly
- Visualize β Views are projections of queries
- Act + Verify β Actions produce events, verification shows diffs
packages/
βββ core/ # Core packages
β βββ kernel/ # Event capture, entity graph, queries, trace
β βββ runtime/ # Public API, createLens, hosts, addons
β βββ devtools/ # Batteries-included meta-package
βββ hosts/ # Runtime integrations
β βββ manual/ # Vanilla three.js
β βββ r3f/ # React Three Fiber
β βββ tres/ # TresJS/Vue
β βββ worker/ # OffscreenCanvas/Worker
βββ addons/ # Feature modules
β βββ inspector/ # Entity browser, blame navigator
β βββ perf/ # Performance analysis
β βββ memory/ # Resource lifecycle, leak detection
β βββ diff/ # Frame/trace comparison
β βββ shader/ # Shader introspection
βββ ui/ # UI packages
β βββ core/ # Framework-agnostic UI shell
β βββ web/ # Web Components
βββ mounts/ # Framework mount kits
β βββ angular/
β βββ react/
β βββ vue/
β βββ svelte/
βββ tools/ # Build & CLI tools
βββ cli/
βββ vite-plugin/
- Node.js 20+
- pnpm 9+
git clone https://github.com/adriandarian/3Lens.git
cd 3Lens
pnpm installpnpm buildpnpm test| Component | Status |
|---|---|
| Kernel (capture, graph, query, trace) | β Implemented |
| Runtime (createLens, hosts, addons) | β Implemented |
| Host: Manual | β Implemented |
| Host: R3F, TresJS, Worker | π Stub |
| Addons: Inspector | β Implemented |
| Addons: Perf, Memory, Diff, Shader | π Stub |
| UI: Core | β Implemented |
| UI: Web Components | β Implemented |
| Mount Kits | π Stub |
| CLI | β Implemented |
| Vite Plugin | β Implemented |
| Examples | π Not Started |
| Documentation | π In Progress |
- Architecture Guide β Project philosophy and design principles
- Contracts β System invariants and guarantees
- Plugin API β Building third-party addons
- Skills & Commands β CLI commands and programmatic APIs
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
# Run tests
pnpm test
# Type check
pnpm typecheck
# Lint
pnpm lintMIT Β© 3Lens Contributors
Built with β€οΈ for the three.js community
