$ show bhouston/threeify
threeify is a TypeScript monorepo providing a WebGL2-based 3D rendering library with a focus on physically-based rendering (PBR), glTF support, and modular architecture. It is loosely derived from three.js but aims for a more modern, tree-shakeable design with native WebGL2 abstractions. The library includes a comprehensive math package (vectors, matrices, quaternions, colors, bounding volumes), a scene graph with cameras, lights, and materials (including clearcoat, sheen, transmission, and anisotropic extensions), a renderer with post-processing effects (tone mapping, Gaussian blur, bloom, cubemap background), a 2D layer compositor with blend modes and panorama support, and a custom GLSL-to-TypeScript transpiler for shader management. The codebase is organized into packages (core, math, scene, layer-compositor) and tools, with over 50 interactive examples demonstrating various rendering techniques. External dependencies include WebGL2 and browser APIs; the library is still in development and not yet recommended for production use.
The LLM identified 4 files worth highlighting for reuse:
A well-typed, immutable-style 3D vector class with functional helpers for arithmetic, transformations, and geometric operations. Includes methods like clone, copy, add, subtract, cross, dot, normalize, and utilities for spherical coordinates. The pattern (Vec2, Vec3, Vec4, Mat3, Mat4, Quat, etc.) is consistent across the math package, making it highly reusable and testable in any graphics or simulation project.
A generic resource cache with reference counting and automatic disposal. Manages GPU resources (programs, textures, geometries) by tracking usage count; when count reaches zero, the resource is released. The pattern is decoupled from specific resource types via a generic type parameter and a dispose callback, making it reusable across any context that needs cached, shared resources with lifecycle management.
A generic worker pool implementation that manages a fixed set of Web Workers, distributes tasks via a queue, and returns promises. Supports dynamic task types (via a generic message type) and handles worker lifecycle (creation, termination). The pattern is self-contained and can be extracted for any browser-based parallel computation (e.g., image processing, physics, data parsing) without modification.
A GLSL implementation of the GGX microfacet specular BRDF, including the normal distribution function (D_GGX), geometry function (Smith with Schlick-GGX), and Fresnel (Schlick). The shader is self-contained, uses standard PBR parameters (roughness, f0), and includes analytic visibility functions. It can be reused in any GLSL-based renderer requiring physically-based specular lighting, and follows a modular import pattern (via #pragma import) used throughout the library.