Spaces:
Paused
Paused
github-actions[bot] commited on
Commit ·
29b5ac5
1
Parent(s): dfec6e1
Automated Deploy: 7f0b9920c5c5432385a8a8787f743aa949ea2f7d
Browse files
frontend/viz2d-demo/e2e/lighting-preservation.spec.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
| 1 |
-
import { expect, test, type Page } from "@playwright/test";
|
| 2 |
-
|
| 3 |
-
const WIDTH = 120;
|
| 4 |
-
const HEIGHT = 72;
|
| 5 |
-
const SHADE_MIN = 0.15;
|
| 6 |
-
const SHADE_MAX = 1.10;
|
| 7 |
-
|
| 8 |
-
for (const renderer of ["webgl", "canvas"] as const) {
|
| 9 |
-
test(`automatically transfers room shadows to light and dark tiles in ${renderer}`, async ({ page }) => {
|
| 10 |
-
if (renderer === "canvas") await disableWebGl(page);
|
| 11 |
-
|
| 12 |
-
const lightTile = await renderLightingBundle(page, "Light Marble", 0.70);
|
| 13 |
-
const darkTile = await renderLightingBundle(page, "Dark Marble", 0.70);
|
| 14 |
-
|
| 15 |
-
expect(lightTile.dark).toBeLessThan(lightTile.neutral * 0.78);
|
| 16 |
-
expect(darkTile.dark).toBeLessThan(darkTile.neutral * 0.82);
|
| 17 |
-
expect(lightTile.bright).toBeGreaterThan(lightTile.neutral);
|
| 18 |
-
expect(darkTile.bright).toBeGreaterThan(darkTile.neutral);
|
| 19 |
-
});
|
| 20 |
-
|
| 21 |
-
test(`uses bundle shadow strength in ${renderer}`, async ({ page }) => {
|
| 22 |
-
if (renderer === "canvas") await disableWebGl(page);
|
| 23 |
-
|
| 24 |
-
const subtle = await renderLightingBundle(page, "Light Marble", 0.35);
|
| 25 |
-
const natural = await renderLightingBundle(page, "Light Marble", 0.70);
|
| 26 |
-
|
| 27 |
-
expect(natural.dark).toBeLessThan(subtle.dark - 5);
|
| 28 |
-
expect(natural.neutral).toBeCloseTo(subtle.neutral, 0);
|
| 29 |
-
});
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
function buildLightingBundle(shadingStrength: number) {
|
| 33 |
-
const pixelCount = WIDTH * HEIGHT;
|
| 34 |
-
const pixels = new Uint8Array(pixelCount * 4);
|
| 35 |
-
const mask = new Uint32Array(pixelCount);
|
| 36 |
-
const shadeMap = new Uint8Array(pixelCount);
|
| 37 |
-
|
| 38 |
-
for (let index = 0; index < pixelCount; index += 1) {
|
| 39 |
-
const x = index % WIDTH;
|
| 40 |
-
const sourceValue = x < 40 ? 70 : x >= 80 ? 210 : 145;
|
| 41 |
-
const shade = x < 40 ? 0.30 : x >= 80 ? 1.08 : 1;
|
| 42 |
-
const pixelIndex = index * 4;
|
| 43 |
-
pixels[pixelIndex] = sourceValue;
|
| 44 |
-
pixels[pixelIndex + 1] = sourceValue;
|
| 45 |
-
pixels[pixelIndex + 2] = sourceValue;
|
| 46 |
-
pixels[pixelIndex + 3] = 255;
|
| 47 |
-
mask[index] = index;
|
| 48 |
-
shadeMap[index] = Math.round(((shade - SHADE_MIN) / (SHADE_MAX - SHADE_MIN)) * 255);
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
return {
|
| 52 |
-
format: "baetes-vizbundle",
|
| 53 |
-
bundleVersion: 3,
|
| 54 |
-
width: WIDTH,
|
| 55 |
-
height: HEIGHT,
|
| 56 |
-
pixels: Buffer.from(pixels).toString("base64"),
|
| 57 |
-
segments: [
|
| 58 |
-
{
|
| 59 |
-
id: 0,
|
| 60 |
-
className: "floor",
|
| 61 |
-
mask: Buffer.from(mask.buffer).toString("base64"),
|
| 62 |
-
homography: null,
|
| 63 |
-
plane: null,
|
| 64 |
-
shadeMap: Buffer.from(shadeMap).toString("base64"),
|
| 65 |
-
showroomShadeMap: null,
|
| 66 |
-
reflectionMap: null,
|
| 67 |
-
metadata: {
|
| 68 |
-
lightingSource: "luminance",
|
| 69 |
-
lightingTransferVersion: 4,
|
| 70 |
-
shadeMapEncoding: "linear-relative",
|
| 71 |
-
shadeMapRange: [SHADE_MIN, SHADE_MAX],
|
| 72 |
-
renderPresetDefaults: {
|
| 73 |
-
preset: "realistic",
|
| 74 |
-
shadingStrength,
|
| 75 |
-
},
|
| 76 |
-
},
|
| 77 |
-
},
|
| 78 |
-
],
|
| 79 |
-
};
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
async function renderLightingBundle(page: Page, textureName: string, shadingStrength: number) {
|
| 83 |
-
await page.goto("/visualizer");
|
| 84 |
-
await page.getByTestId("room-file-input").setInputFiles({
|
| 85 |
-
name: `lighting-${textureName}-${shadingStrength}.vizbundle.json`,
|
| 86 |
-
mimeType: "application/json",
|
| 87 |
-
buffer: Buffer.from(JSON.stringify(buildLightingBundle(shadingStrength))),
|
| 88 |
-
});
|
| 89 |
-
await expect(page.getByTestId("visualizer-editor")).toBeVisible();
|
| 90 |
-
await page.getByTestId("surface-card").click();
|
| 91 |
-
await expect(page.getByTestId("texture-selector")).toBeVisible();
|
| 92 |
-
await page.getByTestId("texture-card").filter({ hasText: textureName }).first().click();
|
| 93 |
-
await expect(page.getByTestId("texture-selector")).toBeHidden();
|
| 94 |
-
await expect(page.getByTestId("surface-card").filter({ hasText: textureName })).toBeVisible();
|
| 95 |
-
await page.mouse.move(4, 4);
|
| 96 |
-
return readLightingRegions(page);
|
| 97 |
-
}
|
| 98 |
-
|
| 99 |
-
async function readLightingRegions(page: Page) {
|
| 100 |
-
return page.getByTestId("visualizer-canvas").evaluate((node) => {
|
| 101 |
-
const canvas = node as HTMLCanvasElement;
|
| 102 |
-
const context = canvas.getContext("2d", { willReadFrequently: true });
|
| 103 |
-
if (!context) throw new Error("Canvas does not expose a 2D context.");
|
| 104 |
-
const image = context.getImageData(0, 0, canvas.width, canvas.height);
|
| 105 |
-
|
| 106 |
-
const meanLuminance = (startX: number, endX: number) => {
|
| 107 |
-
let total = 0;
|
| 108 |
-
let count = 0;
|
| 109 |
-
for (let y = 8; y < canvas.height - 8; y += 1) {
|
| 110 |
-
for (let x = startX; x < endX; x += 1) {
|
| 111 |
-
const index = (y * canvas.width + x) * 4;
|
| 112 |
-
total += (
|
| 113 |
-
image.data[index] * 0.2126
|
| 114 |
-
+ image.data[index + 1] * 0.7152
|
| 115 |
-
+ image.data[index + 2] * 0.0722
|
| 116 |
-
);
|
| 117 |
-
count += 1;
|
| 118 |
-
}
|
| 119 |
-
}
|
| 120 |
-
return total / Math.max(count, 1);
|
| 121 |
-
};
|
| 122 |
-
|
| 123 |
-
return {
|
| 124 |
-
dark: meanLuminance(8, 32),
|
| 125 |
-
neutral: meanLuminance(48, 72),
|
| 126 |
-
bright: meanLuminance(88, 112),
|
| 127 |
-
};
|
| 128 |
-
});
|
| 129 |
-
}
|
| 130 |
-
|
| 131 |
-
async function disableWebGl(page: Page) {
|
| 132 |
-
await page.addInitScript(() => {
|
| 133 |
-
const originalGetContext = HTMLCanvasElement.prototype.getContext;
|
| 134 |
-
HTMLCanvasElement.prototype.getContext = function getContext(
|
| 135 |
-
this: HTMLCanvasElement,
|
| 136 |
-
contextId: string,
|
| 137 |
-
...args: unknown[]
|
| 138 |
-
) {
|
| 139 |
-
if (contextId === "webgl2") return null;
|
| 140 |
-
return originalGetContext.call(this, contextId as "2d", ...args as []);
|
| 141 |
-
} as typeof HTMLCanvasElement.prototype.getContext;
|
| 142 |
-
});
|
| 143 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
frontend/viz2d-demo/playwright.config.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
| 1 |
-
import { defineConfig, devices } from "@playwright/test";
|
| 2 |
-
|
| 3 |
-
const port = Number(process.env.PLAYWRIGHT_PORT ?? 4173);
|
| 4 |
-
const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? `http://127.0.0.1:${port}`;
|
| 5 |
-
|
| 6 |
-
export default defineConfig({
|
| 7 |
-
testDir: "./e2e",
|
| 8 |
-
timeout: 60_000,
|
| 9 |
-
expect: {
|
| 10 |
-
timeout: 15_000,
|
| 11 |
-
},
|
| 12 |
-
fullyParallel: false,
|
| 13 |
-
workers: 1,
|
| 14 |
-
retries: process.env.CI ? 1 : 0,
|
| 15 |
-
reporter: [["list"], ["html", { open: "never", outputFolder: "playwright-report" }]],
|
| 16 |
-
use: {
|
| 17 |
-
baseURL,
|
| 18 |
-
actionTimeout: 15_000,
|
| 19 |
-
navigationTimeout: 30_000,
|
| 20 |
-
screenshot: "only-on-failure",
|
| 21 |
-
trace: "retain-on-failure",
|
| 22 |
-
viewport: {
|
| 23 |
-
width: 1440,
|
| 24 |
-
height: 1000,
|
| 25 |
-
},
|
| 26 |
-
},
|
| 27 |
-
projects: [
|
| 28 |
-
{
|
| 29 |
-
name: "chromium",
|
| 30 |
-
use: { ...devices["Desktop Chrome"] },
|
| 31 |
-
},
|
| 32 |
-
],
|
| 33 |
-
...(process.env.PLAYWRIGHT_BASE_URL
|
| 34 |
-
? {}
|
| 35 |
-
: {
|
| 36 |
-
webServer: {
|
| 37 |
-
command: `pnpm exec vite --host 127.0.0.1 --port ${port}`,
|
| 38 |
-
reuseExistingServer: !process.env.CI,
|
| 39 |
-
timeout: 120_000,
|
| 40 |
-
url: baseURL,
|
| 41 |
-
},
|
| 42 |
-
}),
|
| 43 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
services/pipeline/bundle_assembly.py
CHANGED
|
@@ -109,7 +109,7 @@ def build_floor_segment(
|
|
| 109 |
"showroomShadeMapRange": [SHOWROOM_SHADE_MAP_MIN, SHOWROOM_SHADE_MAP_MAX],
|
| 110 |
"renderPresetDefaults": {
|
| 111 |
"preset": "realistic",
|
| 112 |
-
"shadingStrength": 0.
|
| 113 |
"reflectionTransfer": True,
|
| 114 |
"edgeFeatherPixels": 2,
|
| 115 |
},
|
|
|
|
| 109 |
"showroomShadeMapRange": [SHOWROOM_SHADE_MAP_MIN, SHOWROOM_SHADE_MAP_MAX],
|
| 110 |
"renderPresetDefaults": {
|
| 111 |
"preset": "realistic",
|
| 112 |
+
"shadingStrength": 0.30,
|
| 113 |
"reflectionTransfer": True,
|
| 114 |
"edgeFeatherPixels": 2,
|
| 115 |
},
|
visualizer.gpu.toml
CHANGED
|
@@ -19,7 +19,7 @@ enable_plane_fit = true
|
|
| 19 |
enable_multi_plane_surfaces = true
|
| 20 |
enable_wall_segments = false
|
| 21 |
enable_intrinsic_shading = false
|
| 22 |
-
enable_shading_transfer =
|
| 23 |
enable_sam_refinement = false
|
| 24 |
enable_floor_mask_cleanup = true
|
| 25 |
warm_start_models = true
|
|
|
|
| 19 |
enable_multi_plane_surfaces = true
|
| 20 |
enable_wall_segments = false
|
| 21 |
enable_intrinsic_shading = false
|
| 22 |
+
enable_shading_transfer = false
|
| 23 |
enable_sam_refinement = false
|
| 24 |
enable_floor_mask_cleanup = true
|
| 25 |
warm_start_models = true
|
visualizer.hf.toml
CHANGED
|
@@ -19,7 +19,7 @@ enable_plane_fit = true
|
|
| 19 |
enable_multi_plane_surfaces = true
|
| 20 |
enable_wall_segments = false
|
| 21 |
enable_intrinsic_shading = false
|
| 22 |
-
enable_shading_transfer =
|
| 23 |
enable_sam_refinement = false
|
| 24 |
enable_floor_mask_cleanup = true
|
| 25 |
debug_artifacts_enabled = false
|
|
|
|
| 19 |
enable_multi_plane_surfaces = true
|
| 20 |
enable_wall_segments = false
|
| 21 |
enable_intrinsic_shading = false
|
| 22 |
+
enable_shading_transfer = false
|
| 23 |
enable_sam_refinement = false
|
| 24 |
enable_floor_mask_cleanup = true
|
| 25 |
debug_artifacts_enabled = false
|