Update createFaceMaterial to include staticContactPatches in runtime-host.js and .ts, adjust tests in water-material.test.ts
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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<typeof collectWaterContactPatches>
|
||||
contactPatches: ReturnType<typeof collectWaterContactPatches>,
|
||||
staticContactPatches: ReturnType<typeof collectWaterContactPatches>
|
||||
): Material {
|
||||
if (brush.volume.mode === "water") {
|
||||
const baseOpacity = Math.max(0.05, Math.min(1, brush.volume.water.surfaceOpacity));
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user