Repository navigation
Visualization System Camera System
The Camera System manages the viewport in the 3D canvas, transitioning smoothly between free-roam orbit mode and programmatic follow mode.
Navigating a 24-layer transformer stack manually via scrolling is tedious and disorienting. A smart camera system acts like a director, automatically framing the relevant mathematical operation so the user can focus on the data.
TokenPrint uses the R3F <PerspectiveCamera> paired with drei's <OrbitControls>.
During Live Inference and Walkthrough chapters, the camera relies on a custom easing function.
-
playback.tscalculates aVector3anchor coordinate for every layer in the stack based on the known geometric heights. - When the
activeOpadvances to a new layer, thetargetAnchorupdates. - Inside a
useFrameloop, the camera's position and look-at target are mathematically interpolated (usingdamporlerp) towards the new anchor.
If the user clicks and drags the canvas, an event fires that sets userOrbiting = true. This instantly disables the easing function, yielding full control to the user. The UI displays a "Recenter" button to re-engage the Follow mode.
flowchart TD
Tick[activeOp updates] --> Math[Calculate target Y coordinate]
Math --> Lerp[useFrame: lerp(current, target, 0.1)]
Lerp --> Cam[Update Camera Position]
User[Mouse Drag Event] --> Lock[Set userOrbiting = true]
Lock -.->|Disables| Lerp
| Previous | Home | Next |
|---|---|---|
| Color Mapping | Home | Interaction Model |
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