Skip to content

Core Types

All types below are exported from @glyphcss/core unless marked with glyphcss (the vanilla package).

TypeDescriptionUsed in
Vec2[u, v] tuple — UV coordinatesTextureTriangle.uvs, polygon UVs
Vec3[x, y, z] tuple — world-space point or vectorVertices, directions, hotspot anchors
PolygonN coplanar vertices + optional color/textureHelper generators, mesh parsers
TextureTriangle3 vertices + 3 UV pairs + optional colorParser-internal type for UV-mapped meshes
WireframeEdgefrom/to Vec3 pair + optional weight/colorbuildSceneContext wireframe mode
type Vec2 = [number, number];
type Vec3 = [number, number, number];
interface Polygon {
vertices: Vec3[];
color?: string;
texture?: string;
uvs?: Vec2[];
}
interface TextureTriangle {
vertices: [Vec3, Vec3, Vec3];
uvs: [Vec2, Vec2, Vec2];
color?: string;
}
interface WireframeEdge {
from: Vec3;
to: Vec3;
weight?: EdgeWeight; // 1 | 2 | 3
color?: string;
}
TypeDescriptionUsed in
RenderMode"wireframe" | "solid" | "voxel"SceneContextOptions.mode, all framework props
CharRampstring[] — index 0 = darkest, last = brightestSolid-mode Lambert → glyph mapping
EdgeWeight1 | 2 | 3 — thin / normal / coreWireframeEdge.weight
type RenderMode = "wireframe" | "solid" | "voxel";
type CharRamp = string[]; // e.g. [" ", ".", ":", "-", "=", "+", "*", "#", "%", "@"]
type EdgeWeight = 1 | 2 | 3;
TypeDescriptionUsed in
GlyphDirectionalLightSingle distant light sourceSceneContextOptions.directionalLight
GlyphAmbientLightUniform fill lightSceneContextOptions.ambientLight
interface GlyphDirectionalLight {
direction: Vec3;
intensity?: number; // default 1
color?: string; // hex, default white
}
interface GlyphAmbientLight {
intensity?: number; // default 0.4
color?: string; // hex, default white
}
TypeDescriptionUsed in
GlyphShadowOptionsShadow-map configuration. undefined on the scene = shadows offSceneContextOptions.shadow, <GlyphScene shadow={…}>
interface GlyphShadowOptions {
color?: string; // shadow tint hex; default "#000000"
opacity?: number; // darkness 0..1 toward color; default 0.25
lift?: number; // depth bias — prevents self-shadow acne; default 0.05
maxExtend?: number; // half-extent of the light-space projection volume; default 2000
}

Shadow flags on meshes (GlyphMeshTransform, <GlyphMesh>, <glyph-mesh>):

Field / prop / attributeDefaultDescription
castShadow / cast-shadowfalseThis mesh casts shadows onto receiveShadow surfaces
receiveShadow / receive-shadowfalseThis mesh receives shadows. Both flags on the same mesh = self-shadow

GlyphGround sets receiveShadow=true and castShadow=false by default.

TypeDescriptionUsed in
GridSize{ cols, rows, cellAspect }buildSceneContext, camera project()
SceneContextResolved scene state used by the rasterizerbuildSceneContext return value
interface GridSize {
cols: number;
rows: number;
cellAspect: number; // cellH / cellW — typically ~2.0
}
TypeDescriptionUsed in
HotspotA 3D anchor that projects to a 2D hitboxscene.addHotspot(), projectHotspots()
HotspotCellProjected result for one frameprojectHotspots() return value
interface Hotspot {
id: string;
at: Vec3;
size?: [number, number]; // cols × rows in cells; default [1, 1]
}
interface HotspotCell {
id: string;
col: number;
row: number;
depth: number; // camera-space Z; use for z-index
visible: boolean; // false when behind camera or off-grid
}
TypeDescriptionUsed in
ParseResultUnified output of all polygon-emitting parsersparseObj, parseGltf, loadMesh
ParseAnimationClipMetadata for one animation in a glTF fileParseResult.animation.clips
interface ParseResult {
polygons: Polygon[];
animation?: ParseAnimationController;
objectUrls: string[];
dispose: () => void; // revoke blob URLs — always call on unmount
warnings: string[];
metadata?: {
triangleCount?: number;
meshes?: string[];
materials?: string[];
animations?: ParseAnimationClip[];
sourceBytes?: number;
};
}
interface ParseAnimationClip {
index: number;
name: string;
duration: number; // seconds
channelCount: number;
}
TypeDescriptionUsed in
GlyphAnimationMixerDrives one or more animation actions against a mesh targetcreateGlyphAnimationMixer()
GlyphAnimationActionPer-clip playback statemixer.clipAction()
// Minimal usage — requires a glTF/GLB file with embedded animation clips.
// Replace "/character.glb" with the path to your own animated mesh.
import { createGlyphAnimationMixer, LoopRepeat, loadMesh } from "@glyphcss/core";
const { polygons, animation } = await loadMesh("/character.glb");
const mixer = createGlyphAnimationMixer(meshHandle, animation!);
const action = mixer.clipAction("walk");
action.setLoop(LoopRepeat, Infinity).play();
// In your animation loop (requestAnimationFrame):
mixer.update(deltaSeconds);