Add polygon clipping and area calculation to water contact patch collection
This commit is contained in:
@@ -130,6 +130,96 @@ describe("water material helpers", () => {
|
||||
expect(Math.abs(patches[0]?.axisZ ?? 0)).toBeGreaterThan(0.65);
|
||||
});
|
||||
|
||||
it("clips rotated contact regions to the water footprint", () => {
|
||||
const centeredPatch = collectWaterContactPatches(
|
||||
{
|
||||
center: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
rotationDegrees: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
size: {
|
||||
x: 4,
|
||||
y: 2,
|
||||
z: 4
|
||||
}
|
||||
},
|
||||
[
|
||||
{
|
||||
kind: "orientedBox",
|
||||
center: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
z: 0
|
||||
},
|
||||
rotationDegrees: {
|
||||
x: 0,
|
||||
y: 45,
|
||||
z: 0
|
||||
},
|
||||
size: {
|
||||
x: 3,
|
||||
y: 0.4,
|
||||
z: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
)[0];
|
||||
const clippedPatch = collectWaterContactPatches(
|
||||
{
|
||||
center: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
rotationDegrees: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
size: {
|
||||
x: 4,
|
||||
y: 2,
|
||||
z: 4
|
||||
}
|
||||
},
|
||||
[
|
||||
{
|
||||
kind: "orientedBox",
|
||||
center: {
|
||||
x: 2.2,
|
||||
y: 1,
|
||||
z: 0
|
||||
},
|
||||
rotationDegrees: {
|
||||
x: 0,
|
||||
y: 45,
|
||||
z: 0
|
||||
},
|
||||
size: {
|
||||
x: 3,
|
||||
y: 0.4,
|
||||
z: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
)[0];
|
||||
|
||||
expect(centeredPatch).toBeDefined();
|
||||
expect(clippedPatch).toBeDefined();
|
||||
expect(clippedPatch?.x ?? 999).toBeLessThan(2);
|
||||
expect((clippedPatch?.halfWidth ?? 0) * (clippedPatch?.halfDepth ?? 0)).toBeLessThan(
|
||||
(centeredPatch?.halfWidth ?? 0) * (centeredPatch?.halfDepth ?? 0)
|
||||
);
|
||||
expect(Math.abs(clippedPatch?.axisX ?? 0)).toBeGreaterThan(0.65);
|
||||
expect(Math.abs(clippedPatch?.axisZ ?? 0)).toBeGreaterThan(0.65);
|
||||
});
|
||||
|
||||
it("builds a shared quality shader material for visible tinted water", () => {
|
||||
const result = createWaterMaterial({
|
||||
colorHex: "#4da6d9",
|
||||
|
||||
Reference in New Issue
Block a user