Repository navigation
Architecture Renderer
The Renderer is the sub-system responsible for translating the React component hierarchy into WebGL draw calls using Three.js and React Three Fiber.
WebGL is a low-level API. Three.js simplifies it, but rendering thousands of objects naively will still crash a browser. The Renderer must employ optimizations like Geometry Instancing and custom Shaders to maintain 60fps.
TokenPrint employs several specific rendering strategies:
For the Architecture Explorer, TokenPrint uses a single Points mesh with a custom ShaderMaterial. This allows it to render hundreds of thousands of vertices in a single draw call, rather than mounting thousands of individual React <mesh> components.
For the Attention Blades in the TransformerStack, TokenPrint uses <instancedMesh>. If a model has 32 query heads, TokenPrint doesn't create 32 separate cylinder geometries; it creates one geometry and instances it 32 times with different rotation matrices.
Browsers routinely drop WebGL contexts if the GPU is stressed. The Renderer includes a SceneLoader wrapper that listens for the webglcontextlost event and displays a clean fallback UI rather than a white screen of death.
flowchart TD
React[React Tree] --> R3F[React Three Fiber]
subgraph Renderer Optimizations
R3F --> Points[THREE.Points<br/>1 Draw Call / 1M vertices]
R3F --> Instance[InstancedMesh<br/>1 Draw Call / N Blades]
R3F --> Basic[Standard Meshes<br/>Funnels, Waists]
end
Renderer Optimizations --> WebGL[Browser WebGL API]
WebGL --> GPU[GPU execution]
| Previous | Home | Next |
|---|---|---|
| Data Pipeline | Home | Event System |
TokenPrint Wiki | Home | Getting Started | User Guide | Concepts | Architecture | API | GitHub
TokenPrint is an interactive 3D visualization platform for exploring transformer architectures, tensors, and real-time LLM inference.
- User Guide
- Architecture Explorer
- Live Inference
- Tensor Inspector
- Camera Controls
- HUD
- Timeline
- Scene Navigation
- Transformer Concepts
- Tokenization
- Embeddings
- Positional Encoding
- RoPE
- Multi-Head Attention
- KV Cache
- LayerNorm
- Feed Forward Network
- Residual Connections
- Logits
- Softmax
- Sampling
- Autoregressive Generation
- Visualization System
- Scene Graph
- Geometry
- Materials
- Animation System
- Color Mapping
- Camera System
- Interaction Model
- Architecture
- Overall Architecture
- Frontend
- Backend
- WebSocket Protocol
- Data Pipeline
- Renderer
- Event System