Add tests for cone and torus brushes in whitebox-primitives.test.ts
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
createConeBrush,
|
||||
createRadialPrismBrush,
|
||||
createTorusBrush,
|
||||
createWedgeBrush,
|
||||
deriveBrushSizeFromGeometry
|
||||
} from "../../src/document/brushes";
|
||||
@@ -24,6 +26,11 @@ describe("whitebox primitives", () => {
|
||||
});
|
||||
const derivedMesh = buildBoxBrushDerivedMeshData(brush);
|
||||
|
||||
expect(brush.rotationDegrees).toEqual({
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 180
|
||||
});
|
||||
expect(getBrushFaceIds(brush)).toEqual([
|
||||
"bottom",
|
||||
"back",
|
||||
@@ -82,6 +89,78 @@ describe("whitebox primitives", () => {
|
||||
expect(getBrushVertexIds(brush)).toHaveLength(24);
|
||||
expect(validateBoxBrushGeometry(brush)).toEqual([]);
|
||||
expect(derivedMesh.faceIdsInOrder).toEqual(getBrushFaceIds(brush));
|
||||
expect(
|
||||
derivedMesh.faceSurfaces.find((surface) => surface.faceId === "top")?.normal
|
||||
).toEqual({
|
||||
x: 0,
|
||||
y: 1,
|
||||
z: 0
|
||||
});
|
||||
expect(
|
||||
derivedMesh.faceSurfaces.find((surface) => surface.faceId === "bottom")?.normal
|
||||
).toEqual({
|
||||
x: 0,
|
||||
y: -1,
|
||||
z: 0
|
||||
});
|
||||
expect(Array.from(derivedMesh.colliderVertices).every(Number.isFinite)).toBe(
|
||||
true
|
||||
);
|
||||
expect(Array.from(derivedMesh.colliderIndices).every(Number.isFinite)).toBe(
|
||||
true
|
||||
);
|
||||
expect(deriveBrushSizeFromGeometry(brush.geometry)).toEqual(brush.size);
|
||||
});
|
||||
|
||||
it("builds deterministic cone topology and finite collider buffers", () => {
|
||||
const brush = createConeBrush({
|
||||
id: "brush-cone-test",
|
||||
sideCount: 12,
|
||||
size: {
|
||||
x: 4,
|
||||
y: 3,
|
||||
z: 4
|
||||
}
|
||||
});
|
||||
const derivedMesh = buildBoxBrushDerivedMeshData(brush);
|
||||
|
||||
expect(getBrushFaceIds(brush)).toEqual([
|
||||
"bottom",
|
||||
...Array.from({ length: 12 }, (_, index) => `side-${index}`)
|
||||
]);
|
||||
expect(getBrushEdgeIds(brush)).toHaveLength(24);
|
||||
expect(getBrushVertexIds(brush)).toHaveLength(13);
|
||||
expect(validateBoxBrushGeometry(brush)).toEqual([]);
|
||||
expect(derivedMesh.faceIdsInOrder).toEqual(getBrushFaceIds(brush));
|
||||
expect(
|
||||
derivedMesh.faceSurfaces.find((surface) => surface.faceId === "bottom")?.normal
|
||||
).toEqual({
|
||||
x: 0,
|
||||
y: -1,
|
||||
z: 0
|
||||
});
|
||||
expect(Array.from(derivedMesh.colliderVertices).every(Number.isFinite)).toBe(
|
||||
true
|
||||
);
|
||||
expect(Array.from(derivedMesh.colliderIndices).every(Number.isFinite)).toBe(
|
||||
true
|
||||
);
|
||||
expect(deriveBrushSizeFromGeometry(brush.geometry)).toEqual(brush.size);
|
||||
});
|
||||
|
||||
it("builds deterministic torus topology and finite collider buffers", () => {
|
||||
const brush = createTorusBrush({
|
||||
id: "brush-torus-test",
|
||||
majorSegmentCount: 16,
|
||||
tubeSegmentCount: 8
|
||||
});
|
||||
const derivedMesh = buildBoxBrushDerivedMeshData(brush);
|
||||
|
||||
expect(getBrushFaceIds(brush)).toHaveLength(128);
|
||||
expect(getBrushEdgeIds(brush)).toHaveLength(256);
|
||||
expect(getBrushVertexIds(brush)).toHaveLength(128);
|
||||
expect(validateBoxBrushGeometry(brush)).toEqual([]);
|
||||
expect(derivedMesh.faceIdsInOrder).toEqual(getBrushFaceIds(brush));
|
||||
expect(Array.from(derivedMesh.colliderVertices).every(Number.isFinite)).toBe(
|
||||
true
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user