Files
shacraft-core/client/tests/player-avatar.test.js
Emil c7e86663d8
MVP checks / mvp (push) Canceled after 0s
Expand voxel gameplay, lighting, full-height streaming and world imports
Add shared Rust/WASM physics, worker meshing and diagnostics, 64-chunk full-height streaming, atlas texture support, and baseline world import. Document the current implementation and include the supplied in-game lobby screenshot.
2026-09-17 02:10:53 +03:00

40 lines
1.7 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import { playerAvatarParts } from "../renderer.js";
test("remote avatar stance and eye placement follow server physics dimensions", () => {
for (const [pose, height, eye_height] of [
["standing", 1.8, 1.62],
["crouching", 1.5, 1.27],
["swimming", 0.6, 0.4],
]) {
const parts = playerAvatarParts({ pose, height, eye_height });
assert.equal(Math.max(...parts.map(({ box }) => box.max[1])), height);
const head = parts.find(({ part }) => part === "head").box;
const eyes = parts.find(({ part }) => part === "eyes").box;
assert.ok(Math.abs((eyes.min[1] + eyes.max[1]) / 2 - eye_height) < 1e-12);
assert.ok(eyes.min[1] >= head.min[1] && eyes.max[1] <= head.max[1]);
for (const { box } of parts)
for (let axis = 0; axis < 3; axis++) {
assert.ok(
Number.isFinite(box.min[axis]) && box.max[axis] > box.min[axis],
);
}
}
});
test("swimming and crawling use a horizontal silhouette while crouching leans forward", () => {
const standing = playerAvatarParts({});
const crouching = playerAvatarParts({ pose: "crouching" });
const swimming = playerAvatarParts({ pose: "swimming" });
const head = (parts) => parts.find(({ part }) => part === "head").box;
assert.ok(head(crouching).min[2] < head(standing).min[2]);
const length =
Math.max(...swimming.map(({ box }) => box.max[2])) -
Math.min(...swimming.map(({ box }) => box.min[2]));
assert.ok(length > 1.6);
assert.ok(Math.max(...swimming.map(({ box }) => box.max[1])) <= 0.6);
assert.equal(swimming.filter(({ part }) => part === "leg").length, 2);
assert.equal(swimming.filter(({ part }) => part === "arm").length, 2);
});