# meshsplatting/mesh-splatting architecture

> Architecture diagram of the GitHub repository meshsplatting/mesh-splatting, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/meshsplatting/mesh-splatting
- Repository: https://github.com/meshsplatting/mesh-splatting

## Overview

MeshSplatting trains differentiable opaque-triangle scene representations from camera images, then supports rendering, evaluation, mesh export, and object extraction. The main workflow loads COLMAP or synthetic-scene data, optimizes a triangle model through differentiable rendering, and exports or evaluates the result. Optional depth and normal supervision and the documented SAM-based extraction flow are shown as separate branches. Some entry-point implementations were not sampled; paths and links for those capabilities rely on the README and file tree, so uncertain internal wiring is omitted.

Main entry points: [`triangle_renderer/__init__.py`](https://github.com/meshsplatting/mesh-splatting/blob/main/triangle_renderer/__init__.py) (Differentiable renderer), [`scene/__init__.py`](https://github.com/meshsplatting/mesh-splatting/blob/main/scene/__init__.py) (Scene loader), [`train.py`](https://github.com/meshsplatting/mesh-splatting/blob/main/train.py) (Training loop), [`scene/dataset_readers.py`](https://github.com/meshsplatting/mesh-splatting/blob/main/scene/dataset_readers.py) (Dataset readers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Scene data"]
  node_scene["Scene loader<br/>[__init__.py]"]
  node_readers["Dataset readers<br/>[dataset_readers.py]"]
  node_colmap["COLMAP model IO<br/>[colmap_loader.py]"]
  node_cameras["Camera model<br/>[cameras.py]"]
  node_dataset[("Scene images")]
end

subgraph group_training["Model training"]
  node_train["Training loop<br/>[train.py]"]
  node_triangle_model["Triangle model<br/>[triangle_model.py]"]
  node_renderer["Differentiable renderer<br/>[__init__.py]"]
  node_losses["Training losses<br/>[loss_utils.py]"]
end

subgraph group_outputs["Render and evaluate"]
  node_render_cli["Scene rendering<br/>[render.py]"]
  node_video["Video creation<br/>[create_video.py]"]
  node_evaluation["Evaluation<br/>[full_eval.py]"]
  node_metrics["Image metrics<br/>[metrics.py]"]
  node_ply["Scene PLY export<br/>[create_ply.py]"]
end

subgraph group_objects["Object extraction"]
  node_annotate["Mask annotation"]
  node_extract_images["View extraction<br/>[extract_images.py]"]
  node_sam_masks["SAM mask generation"]
  node_segment["Triangle assignment<br/>[segment.py]"]
  node_single_object["Object rendering"]
  node_object_ply["Object PLY export<br/>[create_ply.py]"]
end

subgraph group_supervision["Optional supervision"]
  node_normal_prep["Normal extraction<br/>[extract_normals.py]"]
  node_depth_prep["Depth scale prep"]
end

node_user(("Researcher"))
node_depth_service["Depth estimator"]
node_sam["SAM model"]

node_user -->|"starts training"| node_train
node_train -->|"loads scene"| node_scene
node_scene -->|"selects reader"| node_readers
node_readers -->|"reads reconstruction"| node_colmap
node_readers -->|"loads images"| node_dataset
node_readers -->|"creates cameras"| node_cameras
node_dataset -->|"provides images"| node_readers
node_train -->|"optimizes model"| node_triangle_model
node_train -->|"renders views"| node_renderer
node_train -->|"computes losses"| node_losses
node_renderer -->|"reads geometry"| node_triangle_model
node_renderer -->|"uses camera"| node_cameras
node_normal_prep -->|"writes normals"| node_dataset
node_depth_service -.->|"produces depth maps"| node_dataset
node_depth_prep -->|"writes depth parameters"| node_dataset
node_user -->|"requests render"| node_render_cli
node_render_cli -->|"loads scene"| node_scene
node_render_cli -->|"renders views"| node_renderer
node_user -->|"requests video"| node_video
node_video -->|"loads scene"| node_scene
node_video -->|"renders frames"| node_renderer
node_user -->|"requests evaluation"| node_evaluation
node_evaluation -->|"runs rendering"| node_render_cli
node_evaluation -->|"computes metrics"| node_metrics
node_user -->|"requests export"| node_ply
node_ply -->|"loads trained model"| node_triangle_model
node_user -->|"marks object"| node_annotate
node_user -->|"starts extraction"| node_extract_images
node_extract_images -->|"loads scene"| node_scene
node_extract_images -->|"renders views"| node_renderer
node_user -->|"requests masks"| node_sam_masks
node_sam_masks -.->|"generates masks"| node_sam
node_user -->|"assigns triangles"| node_segment
node_segment -->|"loads scene"| node_scene
node_segment -->|"renders views"| node_renderer
node_segment -->|"reads triangles"| node_triangle_model
node_user -->|"renders selection"| node_single_object
node_single_object -->|"loads scene"| node_scene
node_single_object -->|"renders selected triangles"| node_renderer
node_user -->|"exports selection"| node_object_ply

click node_scene "https://github.com/meshsplatting/mesh-splatting/blob/main/scene/__init__.py"
click node_readers "https://github.com/meshsplatting/mesh-splatting/blob/main/scene/dataset_readers.py"
click node_colmap "https://github.com/meshsplatting/mesh-splatting/blob/main/scene/colmap_loader.py"
click node_cameras "https://github.com/meshsplatting/mesh-splatting/blob/main/scene/cameras.py"
click node_train "https://github.com/meshsplatting/mesh-splatting/blob/main/train.py"
click node_triangle_model "https://github.com/meshsplatting/mesh-splatting/blob/main/scene/triangle_model.py"
click node_renderer "https://github.com/meshsplatting/mesh-splatting/blob/main/triangle_renderer/__init__.py"
click node_losses "https://github.com/meshsplatting/mesh-splatting/blob/main/utils/loss_utils.py"
click node_normal_prep "https://github.com/meshsplatting/mesh-splatting/blob/main/extract_normals.py"
click node_depth_prep "https://github.com/meshsplatting/mesh-splatting/blob/main/utils/make_depth_scale.py"
click node_render_cli "https://github.com/meshsplatting/mesh-splatting/blob/main/render.py"
click node_video "https://github.com/meshsplatting/mesh-splatting/blob/main/create_video.py"
click node_evaluation "https://github.com/meshsplatting/mesh-splatting/blob/main/full_eval.py"
click node_metrics "https://github.com/meshsplatting/mesh-splatting/blob/main/metrics.py"
click node_ply "https://github.com/meshsplatting/mesh-splatting/blob/main/create_ply.py"
click node_annotate "https://github.com/meshsplatting/mesh-splatting/blob/main/annotate_points_boxes.py"
click node_extract_images "https://github.com/meshsplatting/mesh-splatting/blob/main/segmentation/extract_images.py"
click node_sam_masks "https://github.com/meshsplatting/mesh-splatting/blob/main/segmentation/sam_mask_generator_json.py"
click node_segment "https://github.com/meshsplatting/mesh-splatting/blob/main/segmentation/segment.py"
click node_single_object "https://github.com/meshsplatting/mesh-splatting/blob/main/segmentation/run_single_object.py"
click node_object_ply "https://github.com/meshsplatting/mesh-splatting/blob/main/segmentation/create_ply.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_scene,node_readers,node_colmap,node_cameras,node_dataset toneBlue
class node_train,node_triangle_model,node_renderer,node_losses toneAmber
class node_render_cli,node_video,node_evaluation,node_metrics,node_ply toneMint
class node_annotate,node_extract_images,node_sam_masks,node_segment,node_single_object,node_object_ply toneRose
class node_normal_prep,node_depth_prep,node_user,node_depth_service,node_sam toneIndigo
```

## Components

### Scene data

- [Scene loader](https://github.com/meshsplatting/mesh-splatting/blob/main/scene/__init__.py): `scene/__init__.py`
- [Dataset readers](https://github.com/meshsplatting/mesh-splatting/blob/main/scene/dataset_readers.py): `scene/dataset_readers.py`
- [COLMAP model IO](https://github.com/meshsplatting/mesh-splatting/blob/main/scene/colmap_loader.py): `scene/colmap_loader.py`
- [Camera model](https://github.com/meshsplatting/mesh-splatting/blob/main/scene/cameras.py): `scene/cameras.py`
- **Scene images**

### Model training

- [Training loop](https://github.com/meshsplatting/mesh-splatting/blob/main/train.py): `train.py`
- [Triangle model](https://github.com/meshsplatting/mesh-splatting/blob/main/scene/triangle_model.py): `scene/triangle_model.py`
- [Differentiable renderer](https://github.com/meshsplatting/mesh-splatting/blob/main/triangle_renderer/__init__.py): `triangle_renderer/__init__.py`
- [Training losses](https://github.com/meshsplatting/mesh-splatting/blob/main/utils/loss_utils.py): `utils/loss_utils.py`

### Render and evaluate

- [Scene rendering](https://github.com/meshsplatting/mesh-splatting/blob/main/render.py): `render.py`
- [Video creation](https://github.com/meshsplatting/mesh-splatting/blob/main/create_video.py): `create_video.py`
- [Evaluation](https://github.com/meshsplatting/mesh-splatting/blob/main/full_eval.py): `full_eval.py`
- [Image metrics](https://github.com/meshsplatting/mesh-splatting/blob/main/metrics.py): `metrics.py`
- [Scene PLY export](https://github.com/meshsplatting/mesh-splatting/blob/main/create_ply.py): `create_ply.py`

### Object extraction

- [Mask annotation](https://github.com/meshsplatting/mesh-splatting/blob/main/annotate_points_boxes.py): `annotate_points_boxes.py`
- [View extraction](https://github.com/meshsplatting/mesh-splatting/blob/main/segmentation/extract_images.py): `segmentation/extract_images.py`
- [SAM mask generation](https://github.com/meshsplatting/mesh-splatting/blob/main/segmentation/sam_mask_generator_json.py): `segmentation/sam_mask_generator_json.py`
- [Triangle assignment](https://github.com/meshsplatting/mesh-splatting/blob/main/segmentation/segment.py): `segmentation/segment.py`
- [Object rendering](https://github.com/meshsplatting/mesh-splatting/blob/main/segmentation/run_single_object.py): `segmentation/run_single_object.py`
- [Object PLY export](https://github.com/meshsplatting/mesh-splatting/blob/main/segmentation/create_ply.py): `segmentation/create_ply.py`

### Optional supervision

- [Normal extraction](https://github.com/meshsplatting/mesh-splatting/blob/main/extract_normals.py): `extract_normals.py`
- [Depth scale prep](https://github.com/meshsplatting/mesh-splatting/blob/main/utils/make_depth_scale.py): `utils/make_depth_scale.py`

### Other components

- **Researcher**
- **Depth estimator**
- **SAM model**

## Connections

- Researcher → Training loop: starts training
- Training loop → Scene loader: loads scene
- Scene loader → Dataset readers: selects reader
- Dataset readers → COLMAP model IO: reads reconstruction
- Dataset readers → Scene images: loads images
- Dataset readers → Camera model: creates cameras
- Scene images → Dataset readers: provides images
- Training loop → Triangle model: optimizes model
- Training loop → Differentiable renderer: renders views
- Training loop → Training losses: computes losses
- Differentiable renderer → Triangle model: reads geometry
- Differentiable renderer → Camera model: uses camera
- Normal extraction → Scene images: writes normals
- Depth estimator → Scene images: produces depth maps
- Depth scale prep → Scene images: writes depth parameters
- Researcher → Scene rendering: requests render
- Scene rendering → Scene loader: loads scene
- Scene rendering → Differentiable renderer: renders views
- Researcher → Video creation: requests video
- Video creation → Scene loader: loads scene
- Video creation → Differentiable renderer: renders frames
- Researcher → Evaluation: requests evaluation
- Evaluation → Scene rendering: runs rendering
- Evaluation → Image metrics: computes metrics
- Researcher → Scene PLY export: requests export
- Scene PLY export → Triangle model: loads trained model
- Researcher → Mask annotation: marks object
- Researcher → View extraction: starts extraction
- View extraction → Scene loader: loads scene
- View extraction → Differentiable renderer: renders views
- Researcher → SAM mask generation: requests masks
- SAM mask generation → SAM model: generates masks
- Researcher → Triangle assignment: assigns triangles
- Triangle assignment → Scene loader: loads scene
- Triangle assignment → Differentiable renderer: renders views
- Triangle assignment → Triangle model: reads triangles
- Researcher → Object rendering: renders selection
- Object rendering → Scene loader: loads scene
- Object rendering → Differentiable renderer: renders selected triangles
- Researcher → Object PLY export: exports selection
