Metadata-Version: 2.4
Name: ls3d
Version: 0.1.2
Summary: List files in three dimensions — a command-line tool analogous to ls that renders any directory as an interactive 3D spatial room directly inside your terminal
Author: Vasken Houdoverdov
License-Expression: MIT
Project-URL: Homepage, https://github.com/vhoudoverdov/ls3d
Project-URL: Repository, https://github.com/vhoudoverdov/ls3d.git
Project-URL: Issues, https://github.com/vhoudoverdov/ls3d/issues
Project-URL: Changelog, https://github.com/vhoudoverdov/ls3d/releases
Keywords: cli,tui,terminal,ls,3d,directory,spatial,visualizer,filesystem,treemap,clustering,ansi,truecolor,unicode
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Filesystems
Classifier: Topic :: Terminals
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Dynamic: license-file

# ls3d - List files in three dimensions

**`ls3d`** is a command-line tool analogous to `ls` that renders any directory as an interactive **3D spatial room** directly inside your terminal.

Instead of scrolling through flat text lists, `ls3d` maps every file and subdirectory onto the floor of a single 3D room—scaled logarithmically by size and shaped/colored by filetype—so you can perceive the structure and weight of a directory at a glance.  I was interested in creating this tool as a way to visualize any arbitrary directory as a single "room of objects" regardless of how many items exist.

Created with Google Antigravity

![ls3d](https://raw.githubusercontent.com/vhoudoverdov/ls3d/refs/heads/main/gif/ls3d.gif)

## How It Works

Every item in the directory is placed on the room floor using a **3D Squarified Treemap** (so even folders with 100+ files fit cleanly inside one room) or an optional **Uniform Grid** (`T` to toggle):

| File Type | 3D Shape | Color | Examples |
| :--- | :--- | :--- | :--- |
| **Directories** | Recessed Crate | Cyan | Subfolders (scaled by shallow size) |
| **Code & Text** | Cuboid | Indigo | `.py`, `.ts`, `.js`, `.json`, `.md`, `.yaml` |
| **Media, DB & Archives** | Smooth Cylinder | Emerald | `.png`, `.mp4`, `.db`, `.sqlite`, `.zip`, `.gguf` |
| **Executables & Scripts** | Pyramid | Amber | `.sh`, `.bat`, `.ps1`, `.exe`, `+x` binaries |
| **File Clusters (Large Dirs)** | **Stacked / Layered Shape** | Type Color | Bundled groups (e.g., `[x1,000] Images`) |

Under the hood, `ls3d` uses a pure Python + NumPy 3D software rasterizer with a per-pixel Z-buffer, directional lighting, ambient-occlusion floor shadows, **2x2 Supersampling Anti-Aliasing (SSAA)**, and **2x2 Unicode Quadrant Sub-Cells** (`▘▝▖▗▚▞▛▜▙▟▀▄▌▐█`) for crisp diagonal edges in any 24-bit TrueColor terminal.

### Handling Massive Directories (Semantic Clustering & Focus Mode)

Real folders often hold thousands of files (for example, 1,000 photos, 500 code files, and 300 logs). Rather than rendering 2,000 unreadable pixels or dropping files off-screen, `ls3d` automatically bundles large directories (default threshold: `> 28` items) into **stacked 3D clusters** representing every file in the room:

1. **Single-Room Overview**: `1,000` photos appear as one stacked emerald cylinder (`[x1,000] Images`), `500` scripts as one stacked indigo cuboid (`[x500] Source Code`), etc.—keeping rendering fast regardless of directory size.
2. **In-Room Focus Drill-Down (`Enter`)**: Press `Enter` on a cluster to **focus** the 3D room onto that subset without leaving the directory (`~/photos > [Focus: Images]`). It splits by extension (`*.jpg`, `*.png`) and then into smart sorted buckets until you reach individual files.
3. **Zoom Back Out (`Backspace` / `U`)**: Pops back out one focus level at a time, and only steps up to the parent directory (`..`) once you're back at the full room view.
4. **Raw Override (`K`)**: Toggle smart clustering ON/OFF at any time (or pass `--no-cluster` / `--cluster-threshold N`).

![ls3d-many-files](https://raw.githubusercontent.com/vhoudoverdov/ls3d/refs/heads/main/gif/many-files.gif)

## Requirements

- Python 3.10+
- `numpy>=1.24`
- Any terminal supporting 24-bit TrueColor and UTF-8 (Windows Terminal, iTerm2, Kitty, Alacritty, WezTerm, GNOME Terminal, VS Code integrated terminal, etc.)

## Installation

Install from PyPI with `pip` or `pipx`:

```bash
pip install ls3d
# or isolated CLI install:
pipx install ls3d
```

Or install from source for development:

```bash
git clone https://github.com/vhoudoverdov/ls3d.git
cd ls3d
pip install -e .
```

You can also invoke it as a Python module:

```bash
python -m ls3d
```

## Usage

```bash
# Open an interactive 3D room for the current directory
ls3d

# Open a specific directory
ls3d ~/projects/webapp

# One-shot static output (prints inline to terminal scrollback and exits, like ls)
ls3d --once

# Customize camera angle, view mode, or floor layout
ls3d --once --angle -45
ls3d --once --first-person
ls3d --layout grid

# Include hidden dotfiles
ls3d -a

# Export a high-resolution PNG snapshot of the 3D room
ls3d --once --snapshot room.png --headless
```

## Interactive Controls

| Key | Action |
| :--- | :--- |
| `←` / `→` or `A` / `D` | Rotate horizontal camera angle (smooth 60 FPS yaw) |
| `↑` / `↓` or `W` / `S` | Tilt camera elevation (pitch) |
| `+` / `-` | Zoom camera in / out |
| `Tab` or `[` / `]` | Select next / previous shape in the room |
| `PgDn` / `PgUp` | Jump forward / backward by 10 shapes |
| `Enter` | **Focus** into a stacked Cluster, OR step into a Directory (`cd`) |
| `Backspace` or `U` | Zoom out of Focus Mode, OR step up to parent directory (`..`) |
| `K` | Toggle Smart Semantic Clustering (`Auto` vs `Raw`) |
| `T` | Toggle floor layout (`3D Treemap` vs `Uniform Grid`) |
| `V` | Toggle camera projection (`Isometric` vs `First-Person`) |
| `G` | Toggle glyph renderer (`2x2 Quadrant Sub-Cells` vs `Half-Blocks`) |
| `M` | Toggle `2x2 SSAA` anti-aliasing |
| `O` | Cycle sort order (`SIZE` → `NAME` → `MTIME`) |
| `.` | Toggle hidden dotfiles |
| `L` | Toggle floating 3D filename & size labels |
| `R` | Reset camera to default isometric angle (`38°`) |
| `P` | Save a PNG snapshot (`ls3d_snapshot.png`) |
| `?` or `H` | Toggle in-app help overlay |
| `Q` or `Esc` | Quit |

## Running Tests

```bash
python -m unittest discover -s tests -v
```

## License

MIT — see [LICENSE](https://github.com/vhoudoverdov/ls3d/blob/main/LICENSE).
