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 * as THREE from 'three/webgpu';
import { beautyCameraSpec } from '../src/framing.mjs';
test('legacy beauty camera frames a translated sphere without near/far clipping', () => {
for (const radius of [0.001, 1, 100]) {
const center = [12, -7, 32],
spec = beautyCameraSpec(center, radius);
const camera = new THREE.PerspectiveCamera(spec.fovDeg, spec.aspect, spec.near, spec.far);
camera.position.fromArray(spec.position);
camera.up.fromArray(spec.up);
camera.lookAt(...spec.target);
camera.updateMatrixWorld(true);
for (let lat = 0; lat <= 12; lat++)
for (let lon = 0; lon < 24; lon++) {
const theta = (lat * Math.PI) / 12,
phi = (lon * Math.PI) / 12;
const p = new THREE.Vector3(
center[0] + radius * Math.sin(theta) * Math.cos(phi),
center[1] + radius * Math.cos(theta),
center[2] + radius * Math.sin(theta) * Math.sin(phi),
).project(camera);
assert(
Math.abs(p.x) < 1 && Math.abs(p.y) < 1 && p.z > -1 && p.z < 1,
'sphere must stay in frame',
);
}
assert.deepEqual(spec.target, center);
}
});