Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.
JavaScript 3d3d-assets3d-modelingagent-skillsagent-toolsai-agentsasset-pipelinecligame-assetsglbgltfmcpmcp-servermodel-context-protocolprocedural-generationprocedural-modelingtext-to-3dthreejstypescript
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { packRgbaReadback } from '../src/readback.mjs';
test('1200-wide GPU rows discard 256-byte alignment padding and preserve every row', () => {
const width = 1200,
height = 3,
row = width * 4,
stride = Math.ceil(row / 256) * 256;
const input = new Uint8Array((height - 1) * stride + row).fill(255);
for (let y = 0; y < height; y++) input.fill(y + 1, y * stride, y * stride + row);
const output = packRgbaReadback(input, width, height);
assert.equal(output.length, row * height);
for (let y = 0; y < height; y++)
assert.ok(output.subarray(y * row, (y + 1) * row).every((v) => v === y + 1));
});
test('aligned and already packed arrays retain exact pixels and respect byte offsets', () => {
const backing = new Uint8Array(1024 * 2 * 4 + 16).fill(7);
const input = backing.subarray(8, -8);
assert.deepEqual(packRgbaReadback(input, 1024, 2), Buffer.from(input));
assert.throws(() => packRgbaReadback(new Uint8Array(2), 1200, 2), /readback/);
});