feat(world): Palmen und Requisiten als Instanzen mit Stammkollision
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2469d30e76
commit
9173400caa
16 files changed
+2504
-1
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { lampPoints, palmTransforms } from "../src/world/props.js";
|
||||
|
||||
describe("props", () => {
|
||||
it("setzt Laternen im gewünschten Abstand entlang der Linie", () => {
|
||||
const pts = lampPoints([[[0, 0], [100, 0]]], 35);
|
||||
expect(pts.length).toBe(3); // 17,5 / 52,5 / 87,5 Meter
|
||||
expect(pts[0].x).toBeCloseTo(17.5); // nicht auf der Kreuzung
|
||||
expect(pts[1].x).toBeCloseTo(52.5);
|
||||
});
|
||||
|
||||
it("setzt auf einer kurzen Linie eine Laterne in die Mitte", () => {
|
||||
const pts = lampPoints([[[0, 0], [10, 0]]], 35);
|
||||
expect(pts).toHaveLength(1);
|
||||
expect(pts[0].x).toBeCloseTo(5);
|
||||
});
|
||||
|
||||
it("stapelt an einer Kreuzung keine Laternen", () => {
|
||||
// Zwei gegenüberliegende Äste, wie centerlines() sie seit Task 4 liefert.
|
||||
const pts = lampPoints([[[0, 0], [60, 0]], [[0, 0], [-60, 0]]], 35);
|
||||
const keys = new Set(pts.map((p) => `${p.x.toFixed(2)},${p.z.toFixed(2)}`));
|
||||
expect(keys.size).toBe(pts.length);
|
||||
});
|
||||
|
||||
it("skaliert Palmen reproduzierbar zwischen 10 und 18 Metern", () => {
|
||||
const a = palmTransforms([[5, 5], [9, 9]], 7);
|
||||
const b = palmTransforms([[5, 5], [9, 9]], 7);
|
||||
expect(a).toEqual(b);
|
||||
for (const t of a) {
|
||||
expect(t.height).toBeGreaterThanOrEqual(10);
|
||||
expect(t.height).toBeLessThanOrEqual(18);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user