geometry3d

Luna-Flow/geometry3d is a small 3D rendering pipeline for MoonBit, built on Luna-Flow/linear-algebra. It takes quad meshes through homogeneous transforms, a look-at camera with a physical lens model, perspective projection, back-face culling, Lambert shading and shadow mapping, and draws the result in a terminal, on an HTML canvas or as animated SVG. It is deliberately not a game engine: every stage is short enough to read and is documented with the mathematics it implements.

This manual describes version 0.5.1 of the module, migrated to MoonBit 0.10.

Packages

The library packages form a chain: each depends only on the ones above it. The executables at the bottom are demos.

PackageRolePages
coreVectors, quad meshes and generators, face normals, visibility, Lambert intensity, 4×4 transformsAPI · tutorial · design
viewLook-at camera, perspective and orthographic projection, perspective-correct depth, sensor and lens modelAPI · tutorial · design
frontendScenes, the backend-neutral DrawList, shadow mapping, the luma depth buffer, exposure, optical flow, timelinesAPI · tutorial · design
backend/tuiCharacter frame buffer, shade ramp, terminal aspect correction, .tuiimg and .tui3d filesAPI · tutorial · design
backend/canvasHTML canvas output with exact occlusion (js only)API · tutorial · design
backend/gsapSVG polygons in painter’s order and a GSAP playback controller (js only)API · tutorial · design
demoTerminal demo: scenes, exposure effects, recording and playback (native)CLI · tutorial · design
demo_canvasBrowser demo of the Canvas backend (js)page · tutorial · design
demo_gsapBrowser player for the GSAP SVG backend (js)page · tutorial · design

Package paths are Luna-Flow/geometry3d/<package>. The architecture guide shows how a frame flows through them.

Reading paths

Install

moon add Luna-Flow/geometry3d@0.5.1
moon add Luna-Flow/linear-algebra@0.4.2

linear-algebra is needed in your own module only if you name its types, for example @la.Vector[Double] in a signature. The browser backends also need moonbit-community/rabbita@0.12.4.

Toolchain

The module requires MoonBit with moonc 0.10 or later. core, view, frontend and backend/tui build on every target (wasm-gc, wasm, js, native). backend/canvas, backend/gsap, demo_canvas and demo_gsap build only for js, and the terminal demo is meant for native.

moon check --target all
bash ./run_test.sh

run_test.sh runs the test suite on every target and smoke-tests the demo.