An open API service indexing awesome lists of open source software.

https://github.com/umurotti/3d-visualizer

A lightweight 3D visualizer built with Flask and Three.js. It lets you render meshes, point clouds, frustums, and coordinate axes in the browser โ€” all controlled live via a Python API.
https://github.com/umurotti/3d-visualizer

3d-visualization flask interactive open-source threejs trimesh visualizer webgl

Last synced: 11 months ago
JSON representation

A lightweight 3D visualizer built with Flask and Three.js. It lets you render meshes, point clouds, frustums, and coordinate axes in the browser โ€” all controlled live via a Python API.

Awesome Lists containing this project

README

          

# ๐Ÿ”ญ 3D Visualizer

A lightweight 3D visualizer built with **Flask** and **Three.js**.
It lets you render meshes (Trimesh), point clouds, frustums, and coordinate axes in the browser โ€” all controlled live via a Python API.

---

## ๐Ÿ“ฆ Features

- โœ… Render point clouds and triangle meshes
- โœ… Add camera frustums (green = random, red = known view)
- โœ… Show object and global coordinate systems
- โœ… Toggle visibility of individual elements (e.g. frustums, mesh)
- โœ… OrbitControls to rotate, pan, and zoom the view
- โœ… Light automatically follows the camera

---

## ๐Ÿš€ Quick Start

### 1. Install dependencies

```bash
pip install flask flask-cors
```

---

### 2. Run the server

```bash
python app.py
```

๐ŸŒ Open the browser at: [http://localahost:{YOUR-PORT-HERE}](http://localhost:{your-port-here})

---

### 3. Example usage from Python

```python
from viewer_client import Online3DViewer
import trimesh
import numpy as np

# Start viewer client
viewer = Online3DViewer()

# Create dummy point cloud and mesh
points = np.random.rand(100, 3)
mesh = trimesh.creation.icosphere()

# Load mesh and point cloud
viewer.load_scene(mesh=mesh, pointcloud=points)

# Add camera frustums
pose_matrix = np.eye(4)
viewer.add_frustum(pose_matrix) # Default green

# Red frustum for known views
viewer.add_frustum(pose_matrix, color='red')

# Add coordinate axis
viewer.add_object_axis(pose_matrix, label="Object Frame")

# Show global XYZ
viewer.add_global_axes()

# Update mesh
viewer.update_mesh(mesh, label="epoch_1")

# Update pointcloud
viewer.update_point_cloud(points+2, label="epoch_1")
```
![Demo](assets/output.gif)

---

## ๐Ÿงช Demo

You can run a full demonstration using real mesh data (Stanford Bunny) to showcase all interactive features: mesh updates, frustum visualization, global/object axes, and orbiting motion.

This demo:
- Loads the Stanford Bunny mesh
- Centers it at the origin
- Iteratively updates the mesh position and orientation along a circular orbit
- Visualizes each iteration with a new green frustum and labeled object axis
- Adds a red frustum for a known view

### ๐Ÿ” Iterative Mesh Update Demo

To run it:

```bash
python run_demo.py
```

### ๐Ÿ‡ Demo Preview

![Demo](assets/demo-preview.gif)

### ๐Ÿ—‚๏ธ Demo Folder Structure

```
demo/
โ””โ”€โ”€ bunny/
โ””โ”€โ”€ reconstruction/
โ””โ”€โ”€ bun_zipper_res3.ply
```

Ensure that the `bun_zipper_res3.ply` file is present in the path above.

You can download the Stanford Bunny `.ply` file from the [Stanford 3D Scanning Repository](http://graphics.stanford.edu/data/3Dscanrep/) if needed.

---

## ๐Ÿ’ก Notes

- Works best with recent versions of Chrome or Firefox
- Designed for local visual debugging โ€” not production
- Easily embeddable in larger training/experiment loops

Inspired by the needs of fast real-time mesh and pose inspection during model training.

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=umurotti/3d-visualizer&type=Date)](https://www.star-history.com/#umurotti/3d-visualizer&Date)