trophy

command module
v1.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2026 License: 0BSD Imports: 19 Imported by: 0

README

Go Reference Go Report Card GitHub Release CI Checks codecov

Trophy 🏆

Terminal 3D Model Viewer - View OBJ, GLB, and STL files directly in your terminal, ansipixels port + improvements.

Trophy Demo

Features

  • OBJ, GLB & STL Support - Load standard 3D model formats
  • Embedded Textures - Automatically extracts and applies GLB textures
  • Interactive Controls - Rotate, zoom, and spin models with mouse/keyboard
  • Software Rendering - No GPU required, works over SSH
  • Springy Physics - Smooth, satisfying rotation with momentum

Installation

See the binary releases or

From source/with go:

go install github.com/ansipixels/trophy@latest

Or on mac

brew install ansipixels/tap/trophy

Or even with docker (slower than native though)

docker run -ti ghcr.io/ansipixels/trophy # default Trophy model demo
# Or
docker run -v `pwd`:/data -ti ghcr.io/ansipixels/trophy ./yourmodel.glb

On windows with powershell, you probably need to set COLORTERM if not already to get the 24 bit images instead of mono:

$env:COLORTERM = 'truecolor'

Usage

trophy help                   # See all the options and flags
trophy -ls                    # list the res:* embedded models
trophy res:teapot.stl         # Run the viewer for the Teapot embedded model
trophy                        # Run the viewer for the Trophy embedded model
trophy model.glb              # View a GLB model
trophy model.obj              # View an OBJ model
trophy model.stl              # View an STL model
trophy -texture tex.png model.obj  # Apply custom texture
trophy -fps 60 model.glb      # Higher framerate

Controls

Input Action
Mouse drag Rotate model
Scroll wheel Zoom in/out
W/S Pitch up/down
A/D Yaw left/right
Q/E Roll
Space Toggle spin mode
+/- Zoom
R Reset view
T Toggle texture
X Toggle wireframe
B Toggle backface cull
L Position light
? Toggle HUD overlay
Esc Quit

Lighting

Press L to enter lighting mode and drag to reposition the light source in real-time:

Lighting Demo

Library Usage

Trophy's rendering packages can be used as a library:

import (
    "github.com/ansipixels/trophy/models"
    "github.com/ansipixels/trophy/render"
    "github.com/ansipixels/trophy/math3d"
)

// Load a model
mesh, texture, _ := models.LoadGLBWithTexture("model.glb")

// Create renderer
fb := render.NewFramebuffer(320, 200)
camera := render.NewCamera()
rasterizer := render.NewRasterizer(camera, fb)

// Render (uses optimized edge-function rasterizer)
rasterizer.DrawMeshTexturedOpt(mesh, transform, texture, lightDir)

Packages

  • math3d - 3D math (Vec2, Vec3, Vec4, Mat4)
  • models - Model loaders (OBJ, GLB/GLTF, STL)
  • render - Software rasterizer, camera, textures

Benchmarks

Run with go test -bench=. -benchmem ./...

Math (math3d)
Benchmark ns/op B/op allocs/op
Mat4Mul 74.86 0 0
Mat4MulVec4 6.84 0 0
Mat4MulVec3 8.24 0 0
Mat4Inverse 62.13 0 0
Vec3Normalize 7.41 0 0
Vec3Cross 2.47 0 0
Vec3Dot 2.48 0 0
Perspective 24.15 0 0
LookAt 33.66 0 0
ViewProjection 71.32 0 0
Rendering (render)
Benchmark ns/op B/op allocs/op
FrustumExtract 37.03 0 0
AABBIntersection (visible) 9.96 0 0
AABBIntersection (culled) 7.76 0 0
TransformAABB 125.8 0 0
FrustumIntersectAABB 7.31 0 0
FrustumIntersectsSphere 4.91 0 0
DrawTriangleGouraud 4858 0 0
DrawTriangleGouraudOpt 3981 0 0
DrawMeshGouraud 55741 0 0
DrawMeshGouraudOpt 27868 0 0
Culling Performance
Benchmark ns/op B/op allocs/op
MeshRendering (with culling) 115793 0 0
MeshRendering (without culling) 141766 0 0

The optimized rasterizer (*Opt variants) uses incremental edge functions instead of per-pixel barycentric recomputation, yielding ~18% speedup on triangles and ~50% speedup on full mesh rendering.

Benchmarks run on AMD EPYC 7642 48-Core, linux/amd64

Credits

The (Awesome!) original github.com/taigrr/trophy was built with ultraviolet for terminal rendering.

This is the Ansipixels TUI version which 30% smaller binary and has faster/more stable FPS and I believe clearer/simpler main loop code.

Documentation

Overview

trophy - Terminal 3D Model Viewer - ansipixels port + improvements, view OBJ and GLB files in your terminal with full 3D rendering.

Controls:

Mouse drag  - Rotate model (yaw/pitch)
Scroll      - Zoom in/out
W/S         - Pitch up/down
A/D         - Yaw left/right
Q/E         - Roll left/right (Q rolls left, E rolls right)
Space       - Apply random impulse
R           - Reset rotation
T           - Toggle texture on/off
X           - Toggle wireframe mode (x-ray)
L           - Light positioning mode (move mouse, click to set, Esc to cancel)
?           - Toggle HUD overlay (FPS, filename, poly count, mode status)
+/-         - Adjust zoom
Esc         - Quit (or cancel light mode)

Directories

Path Synopsis
Package math3d provides 3D math primitives for the Trophy engine.
Package math3d provides 3D math primitives for the Trophy engine.
Package models provides 3D model loading and representation for Trophy.
Package models provides 3D model loading and representation for Trophy.
Package render provides optimized software asterization routines using edge function rasterization.
Package render provides optimized software asterization routines using edge function rasterization.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL