most entitys working backup
This commit is contained in:
@@ -83,7 +83,8 @@ assert(allInRange, 'all UVs within [0,1]');
|
||||
// Unmapped bones default to the pack's main texture.
|
||||
assert(headCube.texture === 'needsofnature:textures/entity/zombie/zombie.png', 'head uses default texture');
|
||||
|
||||
// ---------- 2. Synthetic rotated bone: Rz(90°) around pivot (0,10,0) ----------
|
||||
// ---------- 2. Synthetic rotated bone: Rz(-90°) around pivot (0,10,0) ----------
|
||||
// Rotations are negated to match the Bedrock/GeckoLib direction.
|
||||
const rotated = {
|
||||
'minecraft:geometry': [{
|
||||
description: { identifier: 'geometry.t', texture_width: 64, texture_height: 64 },
|
||||
@@ -95,10 +96,10 @@ const rotated = {
|
||||
};
|
||||
const rotBuilt = GeoBuilder.build(rotated);
|
||||
assert(rotBuilt.cubes.length === 1, 'rotated model has one cube');
|
||||
// cube center = origin + size/2 = (1,11,1); Rz90 around pivot (0,10,0):
|
||||
// rel (1,1,1) -> (-1,1,1) -> +pivot = (-1,11,1)
|
||||
// cube center = origin + size/2 = (1,11,1); Rz(-90) around pivot (0,10,0):
|
||||
// rel (1,1,1) -> (1,-1,1) -> +pivot = (1,9,1)
|
||||
const rotCenter = worldCenter(rotBuilt.cubes[0].matrix);
|
||||
assertVec(rotCenter, [-1, 11, 1], 'rotated cube center around pivot (expect (-1,11,1))');
|
||||
assertVec(rotCenter, [1, 9, 1], 'rotated cube center around pivot (expect (1,9,1))');
|
||||
|
||||
// ---------- 3. Nested pivot with rotation ----------
|
||||
const nested = {
|
||||
@@ -115,6 +116,38 @@ const nested = {
|
||||
const nestedBuilt = GeoBuilder.build(nested);
|
||||
assertVec(worldCenter(nestedBuilt.cubes[0].matrix), [0, 28, 0], 'nested pivot head center (expect (0,28,0))');
|
||||
|
||||
// ---------- 4. Real wolf model: rotated bones must produce a quadruped layout ----------
|
||||
const wolf = require(path.join(__dirname, 'fixtures', 'wolf.geo.json'));
|
||||
const wolfBuilt = GeoBuilder.build(wolf);
|
||||
const wolfCenters = wolfBuilt.cubes.map(c => ({ c, center: worldCenter(c.matrix) }));
|
||||
|
||||
const wBody = wolfCenters.find(({ c }) => c.size[0] === 8 && c.size[1] === 6 && c.size[2] === 7);
|
||||
assert(!!wBody, 'wolf body cube found');
|
||||
if (wBody) {
|
||||
// Body high (y~10.5) and in the front half (z<2). Under the old rotation
|
||||
// sign the body landed at the back (z=7) — this catches the regression.
|
||||
assertVec(wBody.center, [-1, 10.5, -3], 'wolf body center (expect (-1,10.5,-3))');
|
||||
}
|
||||
|
||||
const wHead = wolfCenters.find(({ c }) => c.size[0] === 6 && c.size[1] === 6 && c.size[2] === 4);
|
||||
assert(!!wHead, 'wolf head cube found');
|
||||
if (wHead) {
|
||||
assertVec(wHead.center, [-1, 10.5, -7], 'wolf head center (expect (-1,10.5,-7))');
|
||||
}
|
||||
|
||||
// 4 legs (size 2x8x2 cubes whose y is near the ground).
|
||||
const wLegs = wolfCenters.filter(({ c, center }) => c.size[0] === 2 && c.size[1] === 8 && c.size[2] === 2 && center[1] < 6);
|
||||
assert(wLegs.length === 4, `wolf has 4 legs near the ground (got ${wLegs.length})`);
|
||||
wLegs.forEach(({ center }) => assert(approx(center[1], 4.0, 0.2), `leg at ground level y=${center[1].toFixed(1)}`));
|
||||
|
||||
// Tail: the cube with the largest |z|, behind the body.
|
||||
let wTail = wolfCenters[0];
|
||||
for (const w of wolfCenters) {
|
||||
if (Math.abs(w.center[2]) > Math.abs(wTail.center[2])) wTail = w;
|
||||
}
|
||||
assert(wTail.center[2] > 8, `wolf tail behind body (z=${wTail.center[2].toFixed(1)})`);
|
||||
assert(wBody && wTail.center[2] > wBody.center[2], 'tail z > body z');
|
||||
|
||||
// ---------- summary ----------
|
||||
if (failures === 0) {
|
||||
console.log(`geo_builder tests OK (${checks} checks)`);
|
||||
|
||||
Reference in New Issue
Block a user