Documentation ¶
Overview ¶
Package stl provides functionality for writing 3D models in STL (stereolithography) binary format.
STL is a widely used file format for 3D printing and computer-aided design (CAD). This package implements the binary STL format specification, which is more compact and efficient than the ASCII variant. The binary format consists of:
- An 80-byte header
- A 4-byte unsigned integer indicating the number of triangles
- Triangle data, where each triangle consists of:
- A normal vector (3 x 32-bit floats)
- Three vertices (9 x 32-bit floats)
- A 2-byte attribute count (unused in most applications)
This package provides optimized writing capabilities with buffered I/O and efficient memory usage, making it suitable for generating large 3D models.
Index ¶
- func CreateContributionGeometry(contributions [][]types.ContributionDay, yearIndex int, maxContrib int) []types.Triangle
- func GenerateSTL(contributions [][]types.ContributionDay, outputPath, username string, year int) error
- func GenerateSTLRange(contributions [][][]types.ContributionDay, outputPath, username string, ...) error
- func WriteSTLBinary(filename string, triangles []types.Triangle) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateContributionGeometry ¶
func CreateContributionGeometry(contributions [][]types.ContributionDay, yearIndex int, maxContrib int) []types.Triangle
CreateContributionGeometry generates geometry for a single year's worth of contributions
func GenerateSTL ¶
func GenerateSTL(contributions [][]types.ContributionDay, outputPath, username string, year int) error
GenerateSTL creates a 3D model from GitHub contribution data and writes it to an STL file. It's a convenience wrapper around GenerateSTLRange for single year processing.
func GenerateSTLRange ¶
func GenerateSTLRange(contributions [][][]types.ContributionDay, outputPath, username string, startYear, endYear int) error
GenerateSTLRange creates a 3D model from multiple years of GitHub contribution data. It handles the complete process from data validation through geometry generation to file output. Parameters:
- contributions: 3D slice of contribution data ([year][week][day])
- outputPath: destination path for the STL file
- username: GitHub username for the contribution data
- startYear: first year in the range
- endYear: last year in the range
func WriteSTLBinary ¶
WriteSTLBinary writes triangles to a binary STL file with optimized buffering.
The binary STL format consists of: 1. 80-byte header - typically containing version/generator information 2. 4-byte unsigned integer - number of triangles 3. For each triangle:
- Normal vector: 3 x float32 (12 bytes)
- Vertex 1: 3 x float32 (12 bytes)
- Vertex 2: 3 x float32 (12 bytes)
- Vertex 3: 3 x float32 (12 bytes)
- Attribute byte count: uint16 (2 bytes, usually 0)
Types ¶
This section is empty.