Builds KiCad's 3D viewer for the browser (opt in with BUILD_3D_VIEWER=ON) and wires up the legacy-GL emulation it needs. - build-kicad-target.sh / docker/build.sh: BUILD_3D_VIEWER → -DKICAD_BUILD_3D_VIEWER_WASM=ON + -sLEGACY_GL_EMULATION + the GL js-library. - wasm/shims/gl_immediate_shim.js: display-list emulation (record/replay board layers), fixed-function + GLU stubs, throw-guards for unsupported pnames, and per-context GLImmediate init for the viewer's SECOND WebGL context. - tests/kicad/3d-viewer.spec.ts + utils/pcbnew-ready.ts: open View → 3D Viewer. - bumps the kicad submodule (EMSCRIPTEN-guarded GL changes). WIP: the viewer window + UI render and geometry draws (glError=0x0), but the board is not yet visibly rendered — GLImmediate's FFP shader program isn't linked on the viewer's 2nd WebGL context. Full status + next steps in features/feat/add-3d-view/notes.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
import type { Page } from '@playwright/test';
|
|
import { expect } from '../fixtures';
|
|
import { clickByLabel } from '../../e2e/utils/element-tracker';
|
|
|
|
/**
|
|
* Shared pcbnew bring-up helpers. Mirrors the bring-up sequence proven in
|
|
* load-pcb.spec.ts so multiple kicad specs (load-pcb, 3d-viewer, ...) can wait
|
|
* for a ready pcbnew the same way without duplicating the timing logic.
|
|
*/
|
|
|
|
/**
|
|
* KiCad first-run setup wizard. Click "Next >" until it's gone, then "Finish".
|
|
* If no wizard is present, both clicks no-op immediately.
|
|
*/
|
|
export async function dismissWizardIfPresent(page: Page): Promise<void> {
|
|
for (let i = 0; i < 12; i++) {
|
|
const advanced = await clickByLabel(page, 'Next >');
|
|
if (!advanced) break;
|
|
await page.waitForTimeout(400);
|
|
}
|
|
await clickByLabel(page, 'Finish');
|
|
await page.waitForTimeout(800);
|
|
}
|
|
|
|
/**
|
|
* Wait for pcbnew to boot: 2D canvas visible, element registry populated, the
|
|
* first-run wizard dismissed, and the main PcbFrame registered & visible.
|
|
*/
|
|
export async function waitForPcbnew(page: Page): Promise<void> {
|
|
await expect(page.locator('#canvas')).toBeVisible({ timeout: 90000 });
|
|
await page.waitForFunction(() => !!window.wxElementRegistry, null, { timeout: 90000 });
|
|
// Registry object ≠ app booted: wait for real UI entries (wizard or main
|
|
// frame) before dismissing — CI boots slower and the dismiss loop is bounded.
|
|
await page.waitForFunction(() => {
|
|
const registry = window.wxElementRegistry;
|
|
return !!registry && registry.findAll({}).length > 0;
|
|
}, null, { timeout: 150000 });
|
|
await page.waitForTimeout(2500);
|
|
await dismissWizardIfPresent(page);
|
|
await page.waitForFunction(() => {
|
|
const registry = window.wxElementRegistry;
|
|
if (!registry) return false;
|
|
return registry.findAll({ visible: true })
|
|
.some((el) => el.name === 'PcbFrame');
|
|
}, null, { timeout: 90000 });
|
|
await page.waitForTimeout(1500);
|
|
}
|