renderEntity()
Render an entity's model on the CPU, as the GPU would roughly show it: sun shadows, face ambient occlusion, a ground plane and a sky. For judging generator output in headless tools.
function renderEntity(entity: Entity, opts?: RenderOptions): RenderResult;Defined in: preview/render.ts:98
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | Entity | A generated entity; only its model is drawn (rest pose for a rigged one). |
opts? | RenderOptions | Image size, camera and lighting. |
Returns
The image as row-major RGB.
Example
import { seededRandom } from "@voxolith/renderer/core";
import { encodePng, renderEntity } from "@voxolith/gen-kit/preview";
import { generateTree, PRESETS } from "@voxolith/gen-tree";
const { entity } = generateTree(PRESETS.oak, seededRandom(1));
const img = renderEntity(entity, { width: 300, height: 400, yawDeg: 34, pitchDeg: 8 });
await Bun.write("oak.png", encodePng(img.width, img.height, img.rgb));