62 lines
2.7 KiB
JavaScript
62 lines
2.7 KiB
JavaScript
// Visual probe for dev/surface-test.html screenshots (headless geckodriver):
|
|
// boots the real scenes, lands, and HOLDS — one marker per stage so the
|
|
// driver can grab a screenshot at exactly the moment we want:
|
|
// __SHOT__ = 'landing' — the one-shot landing clip, full screen
|
|
// __SHOT__ = 'surface' — looping surface clip + the surface deck
|
|
// __SHOT__ = 'takeoff' — the one-shot take-off clip (deck hidden)
|
|
// (dev/surface-flow.mjs is the assertion suite; this one just parks.)
|
|
import Phaser from '../js/vendor/phaser.js';
|
|
import { config } from '../js/config/Config.js';
|
|
import { ConfigLoader } from '../js/config/ConfigLoader.js';
|
|
import { createGameConfig } from '../js/config/GameConfig.js';
|
|
import { GameScene } from '../js/scenes/GameScene.js';
|
|
import { SurfaceScene } from '../js/scenes/SurfaceScene.js';
|
|
|
|
(async () => {
|
|
const data = await ConfigLoader.load();
|
|
config.init(data);
|
|
const gameConfig = createGameConfig();
|
|
gameConfig.scene = [GameScene, SurfaceScene];
|
|
const game = new Phaser.Game(gameConfig);
|
|
window.game = game;
|
|
window.__SHOT__ = 'booting';
|
|
|
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
let gs = null;
|
|
for (let i = 0; i < 300; i++) {
|
|
gs = game.scene?.getScene?.('GameScene') ?? null;
|
|
if (gs && gs.ship) break;
|
|
await sleep(100);
|
|
}
|
|
if (!gs || !gs.ship) { window.__SHOT__ = 'FAILED: no GameScene'; return; }
|
|
|
|
gs.startLanding(gs.commsTargetFor(gs.planet));
|
|
await sleep(900);
|
|
const ss = game.scene.getScene('SurfaceScene');
|
|
if (!ss || !ss.sys.isActive()) { window.__SHOT__ = 'FAILED: no surface'; return; }
|
|
// Headless autoplay policy: force the clip visible (muted) for the shot.
|
|
if (ss.landVideo && ss.landVideo.video) {
|
|
ss.landVideo.video.muted = true;
|
|
ss.landVideo.video.play().catch(() => {});
|
|
}
|
|
await sleep(700);
|
|
window.__SHOT__ = 'landing'; // ← screenshot #1 (landing clip)
|
|
await sleep(800);
|
|
ss.startSurface(); // force the loop stage (don't wait the clip out)
|
|
if (ss.surfaceVideo && ss.surfaceVideo.video) {
|
|
ss.surfaceVideo.video.muted = true;
|
|
ss.surfaceVideo.video.play().catch(() => {});
|
|
}
|
|
await sleep(1200);
|
|
window.__SHOT__ = 'surface'; // ← screenshot #2 (loop + deck)
|
|
await sleep(600);
|
|
ss.takeOff(); // the take-off clip owns the screen now
|
|
if (ss.takeoffVideo && ss.takeoffVideo.video) {
|
|
ss.takeoffVideo.video.muted = true;
|
|
ss.takeoffVideo.video.play().catch(() => {});
|
|
}
|
|
await sleep(1200);
|
|
window.__SHOT__ = 'takeoff'; // ← screenshot #3 (take-off clip), stays here
|
|
window.__SURFACE_TEST__ = { pass: true, parked: true };
|
|
})().catch((err) => { window.__SHOT__ = 'FAILED: ' + String(err); window.__SURFACE_TEST__ = { pass: false, error: String(err) }; });
|