3D models
asciify-engine/model reads glTF and GLB, OBJ, STL and PLY files and turns them into characters, in any runtime. It draws on the CPU for servers, terminals and SVGs, or on the GPU as a live source for a field, turning by itself and following the pointer.
import { loadModel, modelToGrid, modelToGrids } from 'asciify-engine/model';
import { gridToSvg, gridsToAnimatedSvg } from 'asciify-engine/headless';
const model = await loadModel('/models/helmet.glb');
const svg = gridToSvg(modelToGrid(model, { columns: 100, yaw: 30, pitch: 20 }));
// A full turn as one animated SVG, for a README.
const turn = gridsToAnimatedSvg(modelToGrids(model, { columns: 80, frames: 36 }), { fps: 12 });On a page
import { loadModel, modelSource } from 'asciify-engine/model';
import { mountGlyphField } from 'asciify-engine/field';
const model = modelSource(await loadModel('/models/shoe.glb'), { spin: 20, orbit: hero });
mountGlyphField(canvas, { source: model.canvas, live: true, sample: 'shape', worker: true });The model is drawn with WebGL2 into a canvas of its own, using the same light, outline and framing as the CPU renderer, and the field reads it every frame. It holds still under reduced motion and in hidden tabs, and falls back to the CPU renderer without WebGL2.
The look
A key light from the upper left, a weak fill, a rim against the background and a low ambient keep the shadowed side dark, so the form reads as depth in characters. Dark lines where one surface passes in front of another give shape mode edges to follow. shading takes toon, normals or depth, and paint sets one colour for the whole model.