feat: configure outdoor texture scale and rotation per area

This commit is contained in:
jhartworks committed 2026-11-16 13:57:52 +01:00
1 parent d8cf076019
commit c56f1a5ba9
26 files changed
+1958 -1778

No files matched your search

+38 -5
View File
@@ -76,13 +76,33 @@ try {
}, { type, label, id: drawn.id });
assert.equal(stored, type);
}
const textureEdit = await page.evaluate(async (id) => {
const e = window.outdoorEditor;
const setNumber = async (label, value) => {
const field = [...e.shadowRoot.querySelectorAll("label.nf-field")].find((l) => l.textContent.trim().startsWith(label));
const input = field?.querySelector("input"); if (!input) throw new Error(`Missing ${label}`);
input.value = String(value); input.dispatchEvent(new Event("change", { bubbles: true })); await e.updateComplete;
};
await setNumber("Texturmaßstab", 250); await setNumber("Texturdrehung", -90);
let a = e._doc.floors[0].outdoor.find((a) => a.id === id);
const custom = [a.texture_scale, a.texture_rotation];
await setNumber("Texturmaßstab", 0); const minimum = e._doc.floors[0].outdoor.find((a) => a.id === id).texture_scale;
await setNumber("Texturmaßstab", 100); await setNumber("Texturdrehung", 360);
a = e._doc.floors[0].outdoor.find((a) => a.id === id);
const reset = [a.texture_scale, a.texture_rotation];
await setNumber("Texturmaßstab", 250); await setNumber("Texturdrehung", 45);
const doc = JSON.parse(JSON.stringify(e._doc)); e.setDoc(doc); await e.updateComplete;
const saved = doc.floors[0].outdoor.find((a) => a.id === id);
return { custom, minimum, reset, saved: [saved.texture_scale, saved.texture_rotation], neighbor: doc.floors[0].outdoor.find((a) => a.id === "neighbor").texture_scale ?? null };
}, drawn.id);
assert.deepEqual(textureEdit, { custom: [2.5, 270], minimum: 0.05, reset: [null, null], saved: [2.5, 45], neighbor: null });
await page.screenshot({ path: join(out, "symcon-outdoor-editor.png") });
await page.evaluate(async () => {
const p = window.nfPanel, b = structuredClone(window.outdoorEditor._doc), f = b.floors[0];
const types = ["lawn", "terrace", "path", "driveway", "street", "sidewalk", "gravel", "river", "stream", "pool", "bed", "wild", "hedge", "fence", "pergola"];
f.outdoor = types.map((type, i) => {
const x = (i % 5) * 5, z = Math.floor(i / 5) * 4;
return { id: type, type, points: [[x, z], [x + 4, z], [x + 4, z + 3], [x, z + 3]], ...(type === "sidewalk" ? { slope: 0.25 } : {}), ...(type === "stream" ? { opacity: 0.6 } : {}) };
return { id: type, type, points: [[x, z], [x + 4, z], [x + 4, z + 3], [x, z + 3]], ...(type === "terrace" ? { texture_scale: 2.5, texture_rotation: 45 } : {}), ...(type === "sidewalk" ? { slope: 0.25, texture_scale: 0.5, texture_rotation: 90 } : {}), ...(type === "stream" ? { opacity: 0.6, texture_scale: 1.5, texture_rotation: 330 } : {}) };
});
f.rooms = [{ id: "reference", name: "Referenz", points: [[-2, -2], [-1, -2], [-1, -1], [-2, -1]], area_id: null, floor_material: "plain" }];
f.furniture = []; p.data.edit(b); await p.updateComplete;
@@ -101,7 +121,7 @@ try {
await page.evaluate(() => new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done))));
await page.screenshot({ path: join(out, `symcon-outdoor-${theme}.png`) });
}
for (const [name, x, z] of [["street", 22, 1.5], ["gravel", 7, 5.5], ["lawn", 2, 1.5]]) {
for (const [name, x, z] of [["street", 22, 1.5], ["gravel", 7, 5.5], ["lawn", 2, 1.5], ["terrace", 7, 1.5]]) {
await page.evaluate(({ x, z }) => {
const v = window.outdoorView.viewer; v.setTheme("day"); v.showView({ target: { x, y: 0, z }, radius: 5, phi: 0.65, theta: 0.1 }, 0);
}, { x, z });
@@ -111,14 +131,27 @@ try {
const gpu = await page.evaluate(() => {
const v = window.outdoorView.viewer;
let textured = 0, neutral = 0;
const transforms = {};
v.scene.traverse((o) => {
const ids = o.geometry?.getAttribute("surface");
if (ids) { for (const kind of ids.array) kind > 0 ? textured++ : neutral++; }
if (ids) {
const settings = o.geometry.getAttribute("surfaceTransform");
if (!settings || settings.count !== ids.count) throw new Error("Outdoor texture transform buffer mismatch");
for (let i = 0; i < ids.count; i++) {
const kind = ids.getX(i); kind > 0 ? textured++ : neutral++;
if (kind > 0) (transforms[kind] ??= []).push([settings.getX(i), settings.getY(i)]);
}
}
});
return { textured, neutral, programs: v.renderer.info.programs.map((p) => p.diagnostics?.runnable !== false) };
return { textured, neutral, transforms, programs: v.renderer.info.programs.map((p) => p.diagnostics?.runnable !== false) };
});
for (const [id, scale, rotation] of [[2, 2.5, Math.PI / 4], [11, 0.5, Math.PI / 2], [14, 1.5, 330 * Math.PI / 180]]) {
assert.ok(gpu.transforms[id]?.length > 0);
assert.ok(gpu.transforms[id].every(([s, r]) => s === scale && Math.abs(r - rotation) < 1e-6));
}
assert.ok(gpu.textured > 0); assert.ok(gpu.programs.every(Boolean)); assert.deepEqual(errors, []);
console.log("OK: pointer drawing/moving/corner snapping, Alt bypass, five persisted surface types, metre-scaled textures compiled in all three themes, sloped and transparent surfaces", gpu);
delete gpu.transforms;
console.log("OK: outdoor snapping, surface types, per-area texture size/rotation/reset/persistence, independent GPU transforms in all three themes including sloped and transparent surfaces", gpu);
} finally {
await browser?.close(); await new Promise((done) => server.close(done));
}