Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

test(viewport): compare the selected legacy widget and run existing gizmo checks

yhhd69d6efa9371
diff --git a/.github/workflows/editor-spatial.yml b/.github/workflows/editor-spatial.yml
index 4a6f2571b..cfee0d5df 100644
--- a/.github/workflows/editor-spatial.yml
+++ b/.github/workflows/editor-spatial.yml
@@ -26,6 +26,8 @@ jobs:
artifact: gizmo-interaction-editor-checks
- suite: legacy-2d
artifact: gizmo-legacy-2d-editor-checks
+ - suite: regression
+ artifact: gizmo-regression-editor-checks
env:
ESTELLA_WIN_W: '1480'
ESTELLA_WIN_H: '920'
@@ -74,6 +76,16 @@ jobs:
- name: Compare legacy 2D project widgets with their previous editor
if: matrix.suite == 'legacy-2d'
run: node tools/verify-gizmo-legacy-2d.mjs
+ - name: Run existing gizmo authoring checks
+ if: matrix.suite == 'regression'
+ working-directory: desktop
+ env:
+ ELECTRON_DISABLE_SANDBOX: '1'
+ ESTELLA_MCP_EDITOR_VISIBLE: '1'
+ OUT: ${{ github.workspace }}/output/gizmo-regression-ci
+ run: |
+ mkdir -p "$OUT"
+ xvfb-run -a --server-args="-screen 0 1920x1080x24" node scripts/editor-checks/run.mjs gizmo- | tee "$OUT/checks.log"
- name: Keep spatial acceptance evidence
if: always()
uses: actions/upload-artifact@v7
@@ -85,5 +97,6 @@ jobs:
output/gizmo-hover-ci
output/gizmo-origins-ci
output/gizmo-legacy-2d-ci
+ output/gizmo-regression-ci
if-no-files-found: warn
retention-days: 3
diff --git a/tools/lib/gizmoLegacyCompare.mjs b/tools/lib/gizmoLegacyCompare.mjs
new file mode 100644
index 000000000..5b69e21a1
--- /dev/null
+++ b/tools/lib/gizmoLegacyCompare.mjs
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+import fs from 'node:fs';
+import path from 'node:path';
+import assert from 'node:assert/strict';
+import { readPNG } from './png.mjs';
+
+/** Compare captured legacy widgets at their selected world pivot, without an editor. */
+export function compareLegacyGizmoFrames(directory) {
+ const evidence = JSON.parse(fs.readFileSync(path.join(directory, 'observations.json'), 'utf8'));
+ const comparisons = [];
+ for (const mode of ['move', 'rotate', 'scale']) {
+ const a = evidence.records.find(r => r.label === 'baseline' && r.mode === mode);
+ const b = evidence.records.find(r => r.label === 'current' && r.mode === mode);
+ assert(a && b, 'Missing legacy observation: ' + mode);
+ assert.deepEqual(b.pose, a.pose, 'Legacy project transform changed');
+ assert.deepEqual(b.view, a.view, 'Legacy project framing changed');
+ const before = readPNG(fs.readFileSync(path.join(directory, 'baseline-' + mode + '.png')));
+ const after = readPNG(fs.readFileSync(path.join(directory, 'current-' + mode + '.png')));
+ assert.equal(before.w, after.w); assert.equal(before.h, after.h);
+ const pixelsPerUnit = before.h / (2 * a.view.orthoSize);
+ const anchor = { x: before.w / 2 + (a.pose.position.x - a.view.x) * pixelsPerUnit,
+ y: before.h / 2 - (a.pose.position.y - a.view.y) * pixelsPerUnit };
+ assert(anchor.x >= 90 && anchor.x + 90 < before.w && anchor.y >= 90 && anchor.y + 90 < before.h,
+ 'Legacy widget is outside the comparison region');
+ const probeX = Math.round(anchor.x + (mode === 'rotate' ? 42 : 35));
+ const probeY = Math.round(anchor.y);
+ for (const image of [before, after]) {
+ let ink = false;
+ for (let dy = -1; dy <= 1; dy++) for (let dx = -1; dx <= 1; dx++) {
+ const [r, g, blue] = image.px(probeX + dx, probeY + dy);
+ ink ||= mode === 'rotate' ? blue > 120 && blue > r * 1.5 && g > 100
+ : r > 120 && r > g * 1.3 && r > blue * 1.3;
+ }
+ assert(ink, 'Missing visible transform handle in ' + mode + ' comparison');
+ }
+ let changed = 0, error = 0, pixels = 0;
+ for (let y = Math.floor(anchor.y) - 90; y <= Math.floor(anchor.y) + 90; y++) {
+ for (let x = Math.floor(anchor.x) - 90; x <= Math.floor(anchor.x) + 90; x++) {
+ const p = before.px(x, y), q = after.px(x, y);
+ const delta = p.reduce((n, v, i) => n + Math.abs(v - q[i]), 0);
+ if (delta) changed++;
+ error += delta; pixels++;
+ }
+ }
+ const result = { mode, anchor, probe: { x: probeX, y: probeY }, pixels, changedPixels: changed,
+ changedFraction: changed / pixels, meanError: error / (pixels * 3) };
+ comparisons.push(result);
+ assert.equal(changed, 0, 'Flat 2D widget differs from pre-RM-117 baseline: ' + JSON.stringify(result));
+ }
+ return { status: 'checks-passed', ...evidence, comparisons };
+}
diff --git a/tools/verify-gizmo-legacy-2d.mjs b/tools/verify-gizmo-legacy-2d.mjs
index 4e994863c..be6fc9cfe 100644
--- a/tools/verify-gizmo-legacy-2d.mjs
+++ b/tools/verify-gizmo-legacy-2d.mjs
@@ -6,7 +6,12 @@ import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { runElectron } from './lib/electronRun.mjs';
-import { readPNG } from './lib/png.mjs';
+import { compareLegacyGizmoFrames } from './lib/gizmoLegacyCompare.mjs';
+
+if (process.argv[2] === '--compare-only') {
+ console.log(JSON.stringify(compareLegacyGizmoFrames(path.resolve(process.argv[3])), null, 2));
+ process.exit(0);
+}
if (!process.env.CI) throw Error('Editor acceptance runs only in CI; do not launch the local editor.');
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
@@ -63,30 +68,7 @@ try {
fs.writeFileSync(path.join(out, 'observations.json'), JSON.stringify({ baselineRoot, baseline, original, records }, null, 2));
}
}
- const comparisons = [];
- for (const mode of ['move', 'rotate', 'scale']) {
- const a = records.find(r => r.label === 'baseline' && r.mode === mode);
- const b = records.find(r => r.label === 'current' && r.mode === mode);
- assert.deepEqual(b.pose, a.pose, 'Legacy project transform changed');
- assert.deepEqual(b.view, a.view, 'Legacy project framing changed');
- const before = readPNG(fs.readFileSync(path.join(out, 'baseline-' + mode + '.png')));
- const after = readPNG(fs.readFileSync(path.join(out, 'current-' + mode + '.png')));
- assert.equal(before.w, after.w); assert.equal(before.h, after.h);
- let changed = 0, error = 0, pixels = 0;
- // Frame places the selected pivot at canvas center; cover the complete widget.
- for (let y = Math.floor(before.h / 2) - 90; y <= Math.floor(before.h / 2) + 90; y++) {
- for (let x = Math.floor(before.w / 2) - 90; x <= Math.floor(before.w / 2) + 90; x++) {
- const p = before.px(x, y), q = after.px(x, y);
- const delta = Math.max(...p.map((v, i) => Math.abs(v - q[i])));
- if (delta > 8) changed++;
- error += p.reduce((n, v, i) => n + Math.abs(v - q[i]), 0); pixels++;
- }
- }
- const result = { mode, changedFraction: changed / pixels, meanError: error / (pixels * 3) };
- comparisons.push(result);
- assert(result.changedFraction < 0.01 && result.meanError < 1, 'Flat 2D widget differs from pre-RM-117 baseline: ' + JSON.stringify(result));
- }
- fs.writeFileSync(path.join(out, 'checks.json'), JSON.stringify({ status: 'checks-passed', baselineRoot, baseline, original, records, comparisons }, null, 2));
+ fs.writeFileSync(path.join(out, 'checks.json'), JSON.stringify(compareLegacyGizmoFrames(out), null, 2));
console.log('Legacy Hello World: move, rotate and scale widgets match the pre-RM-117 2D editor.');
} finally {
if (git(['rev-parse', 'HEAD'], desktop).toString().trim() !== original) build(original);