voxolith

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

ParameterTypeDescription
entityEntityA generated entity; only its model is drawn (rest pose for a rigged one).
opts?RenderOptionsImage size, camera and lighting.

Returns

RenderResult

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));

On this page