feat: add live multi-plane and 3d array views

This commit is contained in:
2026-08-30 10:35:27 +09:00
parent dda72739a9
commit c289af366c
7 changed files with 1895 additions and 200 deletions
+27
View File
@@ -7,6 +7,7 @@ import {
hitTestMicrophone,
keyboardNudgeForKey,
niceGridStep,
projectArrayPosition3d,
} from "/apps/array-builder/canvas-view.js";
function assertNear(actual, expected, tolerance, label) {
@@ -139,3 +140,29 @@ test("Array canvas grid와 keyboard nudge의 순수 helper가 1/2/5 및 y-up 규
assertEqual(keyboardNudgeForKey("ArrowDown", 0.002, true).dy, -0.02, "shift multiplies by ten");
assertEqual(keyboardNudgeForKey("Enter", 0.002), null, "non-arrow key ignored");
});
test("Array canvas 3D projection은 +Z FRONT와 right-handed XYZ를 보존한다", () => {
const frontView = {
yaw: 0,
pitch: 0,
centerPixelX: 200,
centerPixelY: 120,
centerHorizontal: 0,
centerVertical: 0,
scale: 100,
};
const positiveX = projectArrayPosition3d([1, 0, 0], frontView);
const positiveZ = projectArrayPosition3d([0, 0, 1], frontView);
const positiveY = projectArrayPosition3d([0, 1, 0], frontView);
assertNear(positiveX.x, 300, 1e-12, "+X projects right");
assertNear(positiveX.y, 120, 1e-12, "+X keeps screen height");
assertNear(positiveZ.x, 200, 1e-12, "+Z stays centered horizontally");
assertNear(positiveZ.y, 20, 1e-12, "+Z FRONT projects upward");
assertNear(positiveY.depth, -1, 1e-12, "+Y supplies front-view depth");
const edgeView = { ...frontView, pitch: Math.PI / 2 };
const edgeY = projectArrayPosition3d([0, 1, 0], edgeView);
const edgeZ = projectArrayPosition3d([0, 0, 1], edgeView);
assertNear(edgeY.y, 20, 1e-12, "orbiting exposes +Y vertically");
assertNear(edgeZ.depth, 1, 1e-12, "orbiting moves +Z onto the depth axis");
});