From 6587f59cda0d549db37c91a573c5b762dd269fa3 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 6 Apr 2026 20:55:10 +0200 Subject: [PATCH] Update createFaceMaterial to include staticContactPatches in runtime-host.js and .ts, adjust tests in water-material.test.ts --- src/runtime-three/runtime-host.js | 14 +++++++------- src/runtime-three/runtime-host.ts | 15 ++++++++------- tests/domain/water-material.test.ts | 4 ++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/runtime-three/runtime-host.js b/src/runtime-three/runtime-host.js index 20026238..abd2448b 100644 --- a/src/runtime-three/runtime-host.js +++ b/src/runtime-three/runtime-host.js @@ -371,12 +371,12 @@ export class RuntimeHost { ? this.mergeRuntimeWaterContactPatches(staticContactPatches, this.collectRuntimePlayerWaterContactPatches(brush)) : []; const materials = [ - this.createFaceMaterial(brush, "posX", brush.faces.posX.material, volumeRenderPaths, contactPatches), - this.createFaceMaterial(brush, "negX", brush.faces.negX.material, volumeRenderPaths, contactPatches), - this.createFaceMaterial(brush, "posY", brush.faces.posY.material, volumeRenderPaths, contactPatches), - this.createFaceMaterial(brush, "negY", brush.faces.negY.material, volumeRenderPaths, contactPatches), - this.createFaceMaterial(brush, "posZ", brush.faces.posZ.material, volumeRenderPaths, contactPatches), - this.createFaceMaterial(brush, "negZ", brush.faces.negZ.material, volumeRenderPaths, contactPatches) + this.createFaceMaterial(brush, "posX", brush.faces.posX.material, volumeRenderPaths, contactPatches, staticContactPatches), + this.createFaceMaterial(brush, "negX", brush.faces.negX.material, volumeRenderPaths, contactPatches, staticContactPatches), + this.createFaceMaterial(brush, "posY", brush.faces.posY.material, volumeRenderPaths, contactPatches, staticContactPatches), + this.createFaceMaterial(brush, "negY", brush.faces.negY.material, volumeRenderPaths, contactPatches, staticContactPatches), + this.createFaceMaterial(brush, "posZ", brush.faces.posZ.material, volumeRenderPaths, contactPatches, staticContactPatches), + this.createFaceMaterial(brush, "negZ", brush.faces.negZ.material, volumeRenderPaths, contactPatches, staticContactPatches) ]; const mesh = new Mesh(geometry, materials); mesh.position.set(brush.center.x, brush.center.y, brush.center.z); @@ -420,7 +420,7 @@ export class RuntimeHost { } this.applyShadowState(); } - createFaceMaterial(brush, faceId, material, volumeRenderPaths, contactPatches) { + createFaceMaterial(brush, faceId, material, volumeRenderPaths, contactPatches, staticContactPatches) { if (brush.volume.mode === "water") { const baseOpacity = Math.max(0.05, Math.min(1, brush.volume.water.surfaceOpacity)); const waterMaterial = createWaterMaterial({ diff --git a/src/runtime-three/runtime-host.ts b/src/runtime-three/runtime-host.ts index 10bea91d..c4a03e57 100644 --- a/src/runtime-three/runtime-host.ts +++ b/src/runtime-three/runtime-host.ts @@ -535,12 +535,12 @@ export class RuntimeHost { const contactPatches = brush.volume.mode === "water" ? this.mergeRuntimeWaterContactPatches(staticContactPatches, this.collectRuntimePlayerWaterContactPatches(brush)) : []; const materials = [ - this.createFaceMaterial(brush, "posX", brush.faces.posX.material, volumeRenderPaths, contactPatches), - this.createFaceMaterial(brush, "negX", brush.faces.negX.material, volumeRenderPaths, contactPatches), - this.createFaceMaterial(brush, "posY", brush.faces.posY.material, volumeRenderPaths, contactPatches), - this.createFaceMaterial(brush, "negY", brush.faces.negY.material, volumeRenderPaths, contactPatches), - this.createFaceMaterial(brush, "posZ", brush.faces.posZ.material, volumeRenderPaths, contactPatches), - this.createFaceMaterial(brush, "negZ", brush.faces.negZ.material, volumeRenderPaths, contactPatches) + this.createFaceMaterial(brush, "posX", brush.faces.posX.material, volumeRenderPaths, contactPatches, staticContactPatches), + this.createFaceMaterial(brush, "negX", brush.faces.negX.material, volumeRenderPaths, contactPatches, staticContactPatches), + this.createFaceMaterial(brush, "posY", brush.faces.posY.material, volumeRenderPaths, contactPatches, staticContactPatches), + this.createFaceMaterial(brush, "negY", brush.faces.negY.material, volumeRenderPaths, contactPatches, staticContactPatches), + this.createFaceMaterial(brush, "posZ", brush.faces.posZ.material, volumeRenderPaths, contactPatches, staticContactPatches), + this.createFaceMaterial(brush, "negZ", brush.faces.negZ.material, volumeRenderPaths, contactPatches, staticContactPatches) ]; const mesh = new Mesh(geometry, materials); @@ -606,7 +606,8 @@ export class RuntimeHost { faceId: "posX" | "negX" | "posY" | "negY" | "posZ" | "negZ", material: RuntimeBoxBrushInstance["faces"]["posX"]["material"], volumeRenderPaths: { fog: "performance" | "quality"; water: "performance" | "quality" }, - contactPatches: ReturnType + contactPatches: ReturnType, + staticContactPatches: ReturnType ): Material { if (brush.volume.mode === "water") { const baseOpacity = Math.max(0.05, Math.min(1, brush.volume.water.surfaceOpacity)); diff --git a/tests/domain/water-material.test.ts b/tests/domain/water-material.test.ts index 2dcb0c7d..326a69db 100644 --- a/tests/domain/water-material.test.ts +++ b/tests/domain/water-material.test.ts @@ -42,8 +42,8 @@ describe("water material helpers", () => { expect(patches).toHaveLength(1); expect(patches[0]?.x).toBeCloseTo(0, 5); expect(patches[0]?.z).toBeCloseTo(0, 5); - expect(patches[0]?.radius).toBeGreaterThan(0.9); - expect(patches[0]?.intensity).toBeGreaterThan(0.5); + expect(patches[0]?.halfWidth).toBeGreaterThan(0.9); + expect(patches[0]?.halfDepth).toBeGreaterThan(0.7); }); it("ignores bounds that do not overlap the water surface band", () => {