Skip to content

Developer tools for inspecting, debugging, and profiling three.js scenes

License

Notifications You must be signed in to change notification settings

adriandarian/3Lens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

250 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

3Lens

3Lens Logo

The render introspection OS for three.js

License Three.js Status CI

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.


✨ Vision

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 Architecture

Core Packages

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

Host Packages

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

Addon Packages

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

UI Packages

Package Description
@3lens/ui-core Framework-agnostic UI shell
@3lens/ui-web Web Components for universal mounting

Mount Kits

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

Tooling

Package Description
@3lens/vite-plugin Dev server injection
@3lens/cli Trace recording, diff, validation commands

πŸš€ Quick Start (Preview)

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();

Web Components

<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>

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        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              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The 5 Foundational Primitives

  1. Capture β€” Authoritative event stream (render events, resource lifecycle)
  2. Model β€” Unified typed dependency graph (entities + relationships)
  3. Query β€” Tools query the model, not the renderer directly
  4. Visualize β€” Views are projections of queries
  5. Act + Verify β€” Actions produce events, verification shows diffs

πŸ“ Project Structure

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/

πŸ› οΈ Development Setup

Prerequisites

  • Node.js 20+
  • pnpm 9+

Clone and Install

git clone https://github.com/adriandarian/3Lens.git
cd 3Lens
pnpm install

Build All Packages

pnpm build

Run Tests

pnpm test

πŸ“‹ Project Status

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

πŸ“– Documentation


🀝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

# Run tests
pnpm test

# Type check
pnpm typecheck

# Lint
pnpm lint

πŸ“„ License

MIT Β© 3Lens Contributors


Built with ❀️ for the three.js community

About

Developer tools for inspecting, debugging, and profiling three.js scenes

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •