# sebasvcx/viewportstencil architecture

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

- Interactive diagram: https://gitdiagram.com/sebasvcx/viewportstencil
- Repository: https://github.com/sebasvcx/viewportstencil

## Overview

ViewportStencil is a client-side Roblox library for making a model appear through an opening in a surface, without cutting the surface geometry. The documented workflow is for a LocalScript to derive a surface CFrame with Utils, then create a stencil from a prepared model; the stencil displays that model in a ViewportFrame with perspective aligned to the player’s camera. The README also documents stencil lifecycle and lighting/display options. Source excerpts were unavailable, so internal implementation links are omitted where the README does not establish them.

Main entry points: [`src/Renderer.lua`](https://github.com/sebasvcx/viewportstencil/blob/main/src/Renderer.lua) (Viewport renderer), [`src/init.lua`](https://github.com/sebasvcx/viewportstencil/blob/main/src/init.lua) (ViewportStencil API), [`src/Stencil.lua`](https://github.com/sebasvcx/viewportstencil/blob/main/src/Stencil.lua) (Stencil lifecycle), [`src/Projection.lua`](https://github.com/sebasvcx/viewportstencil/blob/main/src/Projection.lua) (Off-axis projection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_entry["ViewportStencil API<br/>[init.lua]"]
  node_stencil["Stencil lifecycle<br/>[Stencil.lua]"]
end

subgraph group_render["Stencil Rendering"]
  node_renderer["Viewport renderer<br/>[Renderer.lua]"]
  node_projection["Off-axis projection<br/>[Projection.lua]"]
  node_surface["Surface mask<br/>[Stencil.lua]"]
end

subgraph group_support["Utilities And Types"]
  node_utils["Surface utilities<br/>[Utils.lua]"]
  node_rigpool["Rig pool<br/>[RigPool.lua]"]
  node_types["API types<br/>[Types.lua]"]
end

node_client(("LocalScript developer"))
node_model["Prepared model"]
node_camera["Player camera"]

node_client -->|"gets surface CFrame"| node_utils
node_client -->|"creates stencil"| node_entry
node_entry -->|"creates object"| node_stencil
node_model -->|"supplied for rendering"| node_stencil
node_camera -->|"provides viewpoint"| node_renderer
node_renderer -->|"uses projection"| node_projection
node_renderer -->|"displays through mask"| node_surface

click node_entry "https://github.com/sebasvcx/viewportstencil/blob/main/src/init.lua"
click node_stencil "https://github.com/sebasvcx/viewportstencil/blob/main/src/Stencil.lua"
click node_renderer "https://github.com/sebasvcx/viewportstencil/blob/main/src/Renderer.lua"
click node_projection "https://github.com/sebasvcx/viewportstencil/blob/main/src/Projection.lua"
click node_surface "https://github.com/sebasvcx/viewportstencil/blob/main/src/Stencil.lua"
click node_utils "https://github.com/sebasvcx/viewportstencil/blob/main/src/Utils.lua"
click node_rigpool "https://github.com/sebasvcx/viewportstencil/blob/main/src/RigPool.lua"
click node_types "https://github.com/sebasvcx/viewportstencil/blob/main/src/Types.lua"

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_entry,node_stencil toneBlue
class node_renderer,node_projection,node_surface toneAmber
class node_utils,node_rigpool,node_types toneMint
class node_client,node_model,node_camera toneIndigo
```

## Components

### Public API

- [ViewportStencil API](https://github.com/sebasvcx/viewportstencil/blob/main/src/init.lua): `src/init.lua`
- [Stencil lifecycle](https://github.com/sebasvcx/viewportstencil/blob/main/src/Stencil.lua): `src/Stencil.lua`

### Stencil Rendering

- [Viewport renderer](https://github.com/sebasvcx/viewportstencil/blob/main/src/Renderer.lua): `src/Renderer.lua`
- [Off-axis projection](https://github.com/sebasvcx/viewportstencil/blob/main/src/Projection.lua): `src/Projection.lua`
- [Surface mask](https://github.com/sebasvcx/viewportstencil/blob/main/src/Stencil.lua): `src/Stencil.lua`

### Utilities And Types

- [Surface utilities](https://github.com/sebasvcx/viewportstencil/blob/main/src/Utils.lua): `src/Utils.lua`
- [Rig pool](https://github.com/sebasvcx/viewportstencil/blob/main/src/RigPool.lua): `src/RigPool.lua`
- [API types](https://github.com/sebasvcx/viewportstencil/blob/main/src/Types.lua): `src/Types.lua`

### Other components

- **LocalScript developer**
- **Prepared model**
- **Player camera**

## Connections

- LocalScript developer → Surface utilities: gets surface CFrame (evidence: `README.md`)
- LocalScript developer → ViewportStencil API: creates stencil (evidence: `README.md`)
- ViewportStencil API → Stencil lifecycle: creates object (evidence: `README.md`)
- Prepared model → Stencil lifecycle: supplied for rendering (evidence: `README.md`)
- Player camera → Viewport renderer: provides viewpoint (evidence: `README.md`)
- Viewport renderer → Off-axis projection: uses projection (evidence: `README.md`)
- Viewport renderer → Surface mask: displays through mask (evidence: `README.md`)
