Compare commits
3 Commits
d2b777d8d1
...
3eff83a603
| Author | SHA1 | Date |
|---|---|---|
|
|
3eff83a603 | |
|
|
54f5ae5622 | |
|
|
5cdceb4ecd |
15
CLAUDE.md
15
CLAUDE.md
|
|
@ -2,6 +2,20 @@
|
|||
|
||||
Escape game point & click 3D (three.js, caméras fixes), piloté par `src/scenarios/<chapitre>/scenario.json`. Voir le README pour le format.
|
||||
|
||||
## Versionnage Git (règle n° 1)
|
||||
|
||||
Le dépôt de référence est le dossier de l'utilisateur (`D:\Code\claude\escape_game`, branche `main`, remote `origin` en SSH).
|
||||
|
||||
- **Avant toute modification**, lancer `git status` :
|
||||
- si l'arbre est propre, on commence ;
|
||||
- si des changements sont en cours **et** que la demande est un fix ou un ajustement de la fonctionnalité ou du bug en cours, on continue sur ces changements ;
|
||||
- sinon, **on ne commence pas** : on signale les changements en cours et on demande de les versionner (commit) ou de les abandonner.
|
||||
- **Une modification = un commit**, avec un message en français au format `type: résumé`. Types : `feat`, `fix`, `perf`, `refactor`, `test`, `docs`, `chore`.
|
||||
- **Avant de commiter** : `npm run check` doit être vert, et `npm run smoke` aussi si la 3D, le rendu ou l'UI ont changé.
|
||||
- **Essais risqués** : sur une branche dédiée `essai/<nom>`, pour revenir facilement en arrière.
|
||||
- **Interdit sans accord explicite** : `git push`, ainsi que toute réécriture d'historique (`reset --hard`, `rebase`, `push --force`).
|
||||
- `dist/` n'est pas versionné : il se régénère avec `npm run build`.
|
||||
|
||||
## Vérifier une modification (du plus rapide au plus lent)
|
||||
|
||||
1. `npm run check` (~5 s) : typage, tests de logique, build. À lancer **après chaque modification**.
|
||||
|
|
@ -16,3 +30,4 @@ Escape game point & click 3D (three.js, caméras fixes), piloté par `src/scenar
|
|||
- Si l'enchaînement des énigmes change, mettre à jour `walkthrough.json` dans le même changement.
|
||||
- Un nouveau type de mini-jeu doit avoir un contrôle dans `tests/scenarios.test.ts` (`checkPuzzle`) et une résolution dans `tests/smoke.cjs`.
|
||||
- Le jugement visuel final (lumière, ombres, fluidité) revient à l'utilisateur, sur sa machine.
|
||||
- Performance : tout est préparé au chargement par `ThreeRenderer.warmUp()` (shaders, textures, géométries). Une lumière pilotée par les props s'éteint (intensité 0) au lieu d'être masquée, car changer le nombre de lumières recompile tous les shaders. Le smoke test échoue si un shader ou une texture est préparé en cours de partie.
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ Le moteur est piloté par les données : tout le contenu d'un chapitre (points d
|
|||
| Reculer | flèche en bas de l'écran, clic droit ou `Échap` |
|
||||
| Utiliser un objet | clic sur l'objet dans l'inventaire, puis sur la cible |
|
||||
| Combiner deux objets | clic sur un objet de l'inventaire, puis sur un autre objet de l'inventaire |
|
||||
| Fermer un message | clic n'importe où (ou `Échap`) |
|
||||
| Carnet d'indices | bouton **Carnet** ou `C` ; « Noter dans le carnet » sous les messages qui révèlent un indice |
|
||||
| Indice progressif | bouton **Indice** ou `H` |
|
||||
| Mode debug | `D` : caméra libre (glisser = orbiter, molette = zoom). Affiche l'objet visé et le point 3D. `C` copie le point de vue en JSON `"camera"` |
|
||||
|
||||
|
|
@ -32,7 +34,7 @@ La partie est sauvegardée automatiquement dans le navigateur (bouton « Continu
|
|||
**Difficulté** (au lancement d'une partie) :
|
||||
|
||||
- **Facile** : les objets interactifs s'entourent d'un contour doré et affichent leur nom au survol ;
|
||||
- **Difficile** : seul le curseur change, et les flèches de navigation restent indiquées.
|
||||
- **Difficile** : aucun indice visuel sur les objets (ni contour, ni nom, ni changement de curseur). Seules les flèches de navigation restent indiquées.
|
||||
|
||||
## Le chapitre 1 : le bureau du professeur
|
||||
|
||||
|
|
@ -55,7 +57,7 @@ Cinq énigmes enchaînées, pour 15 à 20 minutes de jeu. Attention, la solution
|
|||
|---|---|---|
|
||||
| `npm test` | ~1 s | Moteur et scénarios sans navigateur : références, cohérence logique, paramètres des mini-jeux, et la solution de référence (`walkthrough.json`) rejouée jusqu'à la victoire |
|
||||
| `npm run check` | ~5 s | Typage + `npm test` + build |
|
||||
| `npm run smoke` | ~1 min | Rejoue la solution avec de vrais clics dans le jeu 3D construit (mode `?test=1`) : objets 3D introuvables, zones masquées, erreurs console, écran de victoire |
|
||||
| `npm run smoke` | ~1 min | Rejoue la solution avec de vrais clics dans le jeu 3D construit (mode `?test=1`) : objets 3D introuvables, zones masquées, erreurs console, écran de victoire, et aucun shader ni texture préparé en cours de partie (sinon, à-coups) |
|
||||
|
||||
Options du smoke test : `npm run smoke -- --shots` (une capture par scène dans `tests/shots/`), `--hard`, `--chapter chapitre1`, `--headed`. Il a besoin de Playwright (`npm i -D playwright && npx playwright install chromium`).
|
||||
|
||||
|
|
@ -115,6 +117,9 @@ tests/
|
|||
- **Déclencheurs** (`triggers`) : des actions exécutées une seule fois, dès que leurs conditions deviennent vraies. Par exemple, le coffret s'ouvre quand les 4 molettes affichent le bon code.
|
||||
- **Combinaisons** (`combinations`) : deux objets d'inventaire et les actions à exécuter quand on les combine.
|
||||
- **Variables initiales** (`vars`) : par exemple, la position de départ des molettes.
|
||||
- **Indices** (`clues`) : textes que le joueur peut noter dans son carnet. L'action `{ "clue": "id" }`, placée après un message, ajoute le bouton « Noter dans le carnet ».
|
||||
- **Lampe UV** (`uvLight`) : objet qui, tenu en main, projette un halo sous la souris. Les surfaces en encre invisible (`invisibleInk()` dans le monde) n'apparaissent que dans ce halo, jusqu'à leur révélation par la prop `reveal`.
|
||||
- **Objet obtenu** : toute action `give` déclenche l'annonce centrale « Objet obtenu » et fait clignoter la case.
|
||||
|
||||
### Choix structurants
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { isMuted, playSound, setMuted } from './audio';
|
||||
import { cursorCss } from './cursors';
|
||||
import type { Engine, MessageKind, Transition, View } from './Engine';
|
||||
import type { CursorKind, Hotspot, PuzzleDef, Scene } from './types';
|
||||
import type { Clue, CursorKind, Hotspot, Item, PuzzleDef, Scene } from './types';
|
||||
import { getPuzzleFactory, type PuzzleContext, type PuzzleInstance } from '../puzzles/registry';
|
||||
|
||||
export interface RendererOptions {
|
||||
|
|
@ -49,6 +49,13 @@ export abstract class BaseRenderer implements View {
|
|||
protected debugEl: HTMLElement;
|
||||
protected debug = false;
|
||||
private messageEl: HTMLElement;
|
||||
private messageText: HTMLElement;
|
||||
private toastEl: HTMLElement;
|
||||
private uvHaloEl: HTMLElement;
|
||||
private notebookBtn: HTMLButtonElement;
|
||||
private notebookEl: HTMLElement | null = null;
|
||||
/** Dernier objet obtenu : sa case clignote dans l'inventaire. */
|
||||
private freshItem: string | null = null;
|
||||
private tooltipEl: HTMLElement;
|
||||
private puzzleLayer: HTMLElement;
|
||||
private inventoryEl: HTMLElement;
|
||||
|
|
@ -75,6 +82,9 @@ export abstract class BaseRenderer implements View {
|
|||
this.sceneLayer = el('div', 'scenes', this.stage);
|
||||
this.hotspotsEl = el('div', 'hotspots', this.stage);
|
||||
this.messageEl = el('div', 'message', this.stage);
|
||||
this.messageText = el('span', 'message-text', this.messageEl);
|
||||
this.toastEl = el('div', 'item-toast', this.stage);
|
||||
this.uvHaloEl = el('div', 'uv-halo', this.stage);
|
||||
this.tooltipEl = el('div', 'tooltip', this.stage);
|
||||
this.puzzleLayer = el('div', 'puzzle-layer', this.stage);
|
||||
this.debugEl = el('div', 'debug-info', this.stage);
|
||||
|
|
@ -83,6 +93,9 @@ export abstract class BaseRenderer implements View {
|
|||
this.inventoryEl = el('div', 'inventory', hud);
|
||||
const right = el('div', 'hud-right', hud);
|
||||
this.timerEl = el('div', 'timer', right);
|
||||
this.notebookBtn = el('button', 'hud-btn notebook-btn', right);
|
||||
this.notebookBtn.title = 'Carnet d’indices (C)';
|
||||
this.notebookBtn.onclick = () => this.toggleNotebook();
|
||||
const hintBtn = el('button', 'hud-btn', right);
|
||||
hintBtn.innerHTML = '<span>?</span> Indice';
|
||||
hintBtn.title = 'Obtenir un indice (H)';
|
||||
|
|
@ -99,6 +112,15 @@ export abstract class BaseRenderer implements View {
|
|||
|
||||
this.heldEl = el('div', 'held-item', this.root);
|
||||
|
||||
// Le message en cours se ferme au clic suivant, n'importe où dans la scène.
|
||||
this.stage.addEventListener(
|
||||
'pointerdown',
|
||||
(e) => {
|
||||
if ((e.target as HTMLElement).closest('.message button')) return;
|
||||
this.hideMessage();
|
||||
},
|
||||
true,
|
||||
);
|
||||
this.stage.addEventListener('contextmenu', (e) => {
|
||||
e.preventDefault();
|
||||
if (!this.puzzle) engine.goBack();
|
||||
|
|
@ -139,8 +161,12 @@ export abstract class BaseRenderer implements View {
|
|||
|
||||
private onKey = (e: KeyboardEvent): void => {
|
||||
if (e.key === 'Escape') {
|
||||
if (this.puzzle) this.closePuzzle();
|
||||
if (this.notebookEl) this.toggleNotebook(false);
|
||||
else if (this.puzzle) this.closePuzzle();
|
||||
else if (this.messageEl.classList.contains('visible')) this.hideMessage();
|
||||
else this.engine.goBack();
|
||||
} else if ((e.key === 'c' || e.key === 'C') && !this.debug) {
|
||||
this.toggleNotebook();
|
||||
} else if (e.key === 'h' || e.key === 'H') {
|
||||
this.engine.nextHint();
|
||||
} else if (e.key === 'd' || e.key === 'D') {
|
||||
|
|
@ -163,6 +189,9 @@ export abstract class BaseRenderer implements View {
|
|||
this.refreshStage(instant);
|
||||
this.renderRectHotspots();
|
||||
this.renderInventory();
|
||||
const n = this.engine.state.notebook.length;
|
||||
this.notebookBtn.innerHTML = `Carnet${n ? ` <b>${n}</b>` : ''}`;
|
||||
if (this.notebookEl) this.renderNotebook();
|
||||
}
|
||||
|
||||
/** Zones écran (rect) : flèches de navigation et zones écran éventuelles. */
|
||||
|
|
@ -204,7 +233,10 @@ export abstract class BaseRenderer implements View {
|
|||
}
|
||||
|
||||
protected cursorFor(hs: Hotspot): string {
|
||||
if (this.engine.state.selected && !hs.id.startsWith('__')) return cursorCss('use');
|
||||
const isNav = hs.id.startsWith('__');
|
||||
// En Difficile, aucun indice visuel sur les objets : au joueur de tester.
|
||||
if (!isNav && this.engine.state.difficulty === 'hard') return 'default';
|
||||
if (this.engine.state.selected && !isNav) return cursorCss('use');
|
||||
let kind: CursorKind = 'look';
|
||||
if (hs.cursor) kind = hs.cursor;
|
||||
else {
|
||||
|
|
@ -250,12 +282,15 @@ export abstract class BaseRenderer implements View {
|
|||
slot.title = item ? `${item.name}${item.description ? ' — ' + item.description : ''}` : id;
|
||||
slot.dataset.item = id;
|
||||
slot.classList.toggle('selected', state.selected === id);
|
||||
if (id === this.freshItem) slot.classList.add('fresh');
|
||||
slot.onclick = () => {
|
||||
const sel = this.engine.state.selected;
|
||||
if (sel && sel !== id) this.engine.combine(sel, id);
|
||||
else this.engine.selectItem(id);
|
||||
};
|
||||
}
|
||||
const uv = this.engine.scenario.uvLight;
|
||||
this.uvHaloEl.classList.toggle('visible', !!uv && state.selected === uv.item);
|
||||
const held = state.selected ? this.engine.getItem(state.selected) : undefined;
|
||||
if (held) {
|
||||
this.heldEl.style.backgroundImage = `url("${this.opts.resolveImage(held.icon)}")`;
|
||||
|
|
@ -270,15 +305,92 @@ export abstract class BaseRenderer implements View {
|
|||
showMessage(text: string, kind: MessageKind): void {
|
||||
window.clearTimeout(this.messageTimer);
|
||||
this.messageEl.className = `message visible ${kind}`;
|
||||
this.messageEl.textContent = text;
|
||||
this.messageText.textContent = text;
|
||||
this.messageEl.querySelector('.clue-btn')?.remove();
|
||||
if (kind === 'hint') playSound('beep');
|
||||
this.messageTimer = window.setTimeout(() => this.hideMessage(), Math.max(3500, text.length * 60));
|
||||
// Fermeture automatique (le clic suivant le ferme aussi).
|
||||
this.messageTimer = window.setTimeout(() => this.hideMessage(), Math.max(5000, text.length * 70));
|
||||
}
|
||||
|
||||
protected hideMessage(): void {
|
||||
window.clearTimeout(this.messageTimer);
|
||||
this.messageEl.classList.remove('visible');
|
||||
}
|
||||
|
||||
/** Bouton « Noter dans le carnet » sous le message courant. */
|
||||
offerClue(clue: Clue): void {
|
||||
this.messageEl.querySelector('.clue-btn')?.remove();
|
||||
const btn = el('button', 'clue-btn', this.messageEl);
|
||||
btn.textContent = 'Noter dans le carnet';
|
||||
btn.title = clue.text;
|
||||
btn.onclick = (e) => {
|
||||
e.stopPropagation();
|
||||
this.engine.noteClue(clue.id);
|
||||
btn.textContent = 'Noté ✓';
|
||||
btn.disabled = true;
|
||||
this.notebookBtn.classList.remove('pulse');
|
||||
void this.notebookBtn.offsetWidth;
|
||||
this.notebookBtn.classList.add('pulse');
|
||||
window.setTimeout(() => this.hideMessage(), 700);
|
||||
};
|
||||
// Laisse le temps de cliquer : la fermeture automatique est repoussée.
|
||||
window.clearTimeout(this.messageTimer);
|
||||
this.messageTimer = window.setTimeout(() => this.hideMessage(), 9000);
|
||||
}
|
||||
|
||||
/** Annonce centrale « Objet obtenu » + case de l'inventaire qui clignote. */
|
||||
itemGained(item: Item): void {
|
||||
this.toastEl.innerHTML = '';
|
||||
const img = el('img', '', this.toastEl);
|
||||
img.src = this.opts.resolveImage(item.icon);
|
||||
img.alt = '';
|
||||
el('div', 'item-toast-label', this.toastEl).textContent = 'Objet obtenu';
|
||||
el('div', 'item-toast-name', this.toastEl).textContent = item.name;
|
||||
this.toastEl.classList.remove('show');
|
||||
void this.toastEl.offsetWidth;
|
||||
this.toastEl.classList.add('show');
|
||||
this.freshItem = item.id;
|
||||
window.setTimeout(() => {
|
||||
if (this.freshItem === item.id) this.freshItem = null;
|
||||
}, 2600);
|
||||
}
|
||||
|
||||
// --- Carnet ----------------------------------------------------------------------
|
||||
|
||||
private toggleNotebook(open = !this.notebookEl): void {
|
||||
if (!open) {
|
||||
this.notebookEl?.remove();
|
||||
this.notebookEl = null;
|
||||
return;
|
||||
}
|
||||
if (this.notebookEl) return;
|
||||
this.hideTooltip();
|
||||
const overlay = el('div', 'puzzle-overlay visible notebook-overlay', this.puzzleLayer);
|
||||
overlay.addEventListener('click', (e) => {
|
||||
if (e.target === overlay) this.toggleNotebook(false);
|
||||
});
|
||||
this.notebookEl = overlay;
|
||||
this.renderNotebook();
|
||||
}
|
||||
|
||||
private renderNotebook(): void {
|
||||
if (!this.notebookEl) return;
|
||||
const ids = this.engine.state.notebook;
|
||||
this.notebookEl.innerHTML = '';
|
||||
const book = el('div', 'notebook', this.notebookEl);
|
||||
const close = el('button', 'puzzle-close', book);
|
||||
close.textContent = '×';
|
||||
close.title = 'Fermer (Échap)';
|
||||
close.onclick = () => this.toggleNotebook(false);
|
||||
el('h3', '', book).textContent = 'Carnet';
|
||||
if (!ids.length) {
|
||||
el('p', 'notebook-empty', book).textContent = 'Aucune note pour l’instant. Quand vous découvrez un indice, choisissez « Noter dans le carnet ».';
|
||||
return;
|
||||
}
|
||||
const list = el('ol', '', book);
|
||||
for (const id of ids) el('li', '', list).textContent = this.engine.getClue(id)?.text ?? id;
|
||||
}
|
||||
|
||||
// --- Puzzles ------------------------------------------------------------------------
|
||||
|
||||
openPuzzle(def: PuzzleDef, ctx: PuzzleContext): void {
|
||||
|
|
@ -325,6 +437,7 @@ export abstract class BaseRenderer implements View {
|
|||
protected onMouseMove(e: MouseEvent): void {
|
||||
this.heldEl.style.transform = `translate(${e.clientX + 14}px, ${e.clientY + 14}px)`;
|
||||
const r = this.stage.getBoundingClientRect();
|
||||
this.uvHaloEl.style.transform = `translate(${e.clientX - r.left}px, ${e.clientY - r.top}px) translate(-50%, -50%)`;
|
||||
// Décalage plus grand quand un objet est tenu, pour ne pas masquer son icône.
|
||||
const dy = this.engine.state.selected ? 62 : 22;
|
||||
const tx = Math.min(e.clientX - r.left + 18, r.width - this.tooltipEl.offsetWidth - 8);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { playSound } from './audio';
|
||||
import { checkAll, saveState, type GameState } from './state';
|
||||
import type { Action, Hotspot, Interaction, Item, PuzzleDef, Scenario, Scene } from './types';
|
||||
import type { Action, Clue, Hotspot, Interaction, Item, PuzzleDef, Scenario, Scene } from './types';
|
||||
import type { PuzzleContext } from '../puzzles/registry';
|
||||
|
||||
export type MessageKind = 'info' | 'hint' | 'item';
|
||||
|
|
@ -14,6 +14,10 @@ export interface View {
|
|||
showScene(scene: Scene, transition: Transition): void;
|
||||
refresh(): void;
|
||||
showMessage(text: string, kind: MessageKind): void;
|
||||
/** Ajoute au message courant la proposition de noter cet indice. */
|
||||
offerClue?(clue: Clue): void;
|
||||
/** Annonce d'un objet obtenu. */
|
||||
itemGained?(item: Item): void;
|
||||
openPuzzle(def: PuzzleDef, ctx: PuzzleContext): void;
|
||||
closePuzzle(): void;
|
||||
showWin(): void;
|
||||
|
|
@ -80,6 +84,20 @@ export class Engine {
|
|||
return this.items.get(id);
|
||||
}
|
||||
|
||||
getClue(id: string): Clue | undefined {
|
||||
return this.scenario.clues?.find((c) => c.id === id);
|
||||
}
|
||||
|
||||
/** Note un indice dans le carnet. Renvoie false s'il y était déjà ou n'existe pas. */
|
||||
noteClue(id: string): boolean {
|
||||
if (!this.getClue(id) || this.state.notebook.includes(id)) return false;
|
||||
this.state.notebook.push(id);
|
||||
playSound('pickup');
|
||||
saveState(this.state);
|
||||
this.view.refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Zones actives de la scène, y compris les bandes de navigation générées. */
|
||||
activeHotspots(scene: Scene): Hotspot[] {
|
||||
const [w, h] = this.scenario.resolution;
|
||||
|
|
@ -211,7 +229,11 @@ export class Engine {
|
|||
} else if ('clearFlag' in action) {
|
||||
delete this.state.flags[action.clearFlag];
|
||||
} else if ('give' in action) {
|
||||
if (!this.state.inventory.includes(action.give)) this.state.inventory.push(action.give);
|
||||
if (!this.state.inventory.includes(action.give)) {
|
||||
this.state.inventory.push(action.give);
|
||||
const item = this.getItem(action.give);
|
||||
if (item) this.view.itemGained?.(item);
|
||||
}
|
||||
playSound('pickup');
|
||||
} else if ('remove' in action) {
|
||||
this.state.inventory = this.state.inventory.filter((i) => i !== action.remove);
|
||||
|
|
@ -228,6 +250,9 @@ export class Engine {
|
|||
this.state.vars[action.set] = action.value;
|
||||
} else if ('if' in action) {
|
||||
for (const a of checkAll(this.state, action.if) ? action.then : (action.else ?? [])) this.exec(a);
|
||||
} else if ('clue' in action) {
|
||||
const clue = this.getClue(action.clue);
|
||||
if (clue && !this.state.notebook.includes(clue.id)) this.view.offerClue?.(clue);
|
||||
} else if ('win' in action) {
|
||||
this.state.won = true;
|
||||
this.state.selected = null;
|
||||
|
|
|
|||
|
|
@ -95,6 +95,10 @@ export function analyzeScenario(s: Scenario): string[] {
|
|||
trig.add(t.id);
|
||||
}
|
||||
|
||||
// Indices : chacun doit pouvoir être proposé au joueur
|
||||
const offered = new Set(actions.flatMap(({ a }) => ('clue' in a ? [a.clue] : [])));
|
||||
for (const c of s.clues ?? []) if (!offered.has(c.id)) errors.push(`indice "${c.id}" : jamais proposé (action clue)`);
|
||||
|
||||
// Scènes accessibles depuis le départ
|
||||
const edges = new Map<string, string[]>();
|
||||
for (const sc of s.scenes) {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ export function validateScenario(s: Scenario, imageExists: (p: string) => boolea
|
|||
const scenes = new Set(s.scenes.map((x) => x.id));
|
||||
const items = new Set(s.items.map((x) => x.id));
|
||||
const puzzles = new Set(s.puzzles.map((x) => x.id));
|
||||
const clues = new Set((s.clues ?? []).map((x) => x.id));
|
||||
|
||||
const checkConds = (where: string, conds?: Condition[]) =>
|
||||
conds?.forEach((c) => {
|
||||
|
|
@ -61,6 +62,7 @@ export function validateScenario(s: Scenario, imageExists: (p: string) => boolea
|
|||
checkActions(where, a.then);
|
||||
checkActions(where, a.else ?? []);
|
||||
}
|
||||
if ('clue' in a && !clues.has(a.clue)) errors.push(`${where} : indice inconnu "${a.clue}"`);
|
||||
if ('remove' in a && !items.has(a.remove)) errors.push(`${where} : objet inconnu "${a.remove}"`);
|
||||
if ('goto' in a && !scenes.has(a.goto)) errors.push(`${where} : scène inconnue "${a.goto}"`);
|
||||
if ('give' in a && !items.has(a.give)) errors.push(`${where} : objet inconnu "${a.give}"`);
|
||||
|
|
@ -72,6 +74,7 @@ export function validateScenario(s: Scenario, imageExists: (p: string) => boolea
|
|||
|
||||
if (!scenes.has(s.startScene)) errors.push(`startScene inconnue "${s.startScene}"`);
|
||||
if (!s.world) errors.push(`"world" manquant`);
|
||||
if (s.uvLight && !items.has(s.uvLight.item)) errors.push(`uvLight : objet inconnu "${s.uvLight.item}"`);
|
||||
for (const sc of s.scenes) {
|
||||
if (!sc.camera) errors.push(`scène ${sc.id} : "camera" manquante`);
|
||||
for (const nav of [sc.left, sc.right, sc.back]) if (nav && !scenes.has(nav)) errors.push(`scène ${sc.id} : navigation vers "${nav}" inconnue`);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ export interface GameState {
|
|||
/** Déclencheurs déjà exécutés. */
|
||||
fired: Record<string, boolean>;
|
||||
difficulty: Difficulty;
|
||||
/** Indices notés dans le carnet (identifiants, dans l'ordre). */
|
||||
notebook: string[];
|
||||
}
|
||||
|
||||
export function newState(scenarioId: string, startScene: string, difficulty: Difficulty = 'easy'): GameState {
|
||||
|
|
@ -26,6 +28,7 @@ export function newState(scenarioId: string, startScene: string, difficulty: Dif
|
|||
scenarioId,
|
||||
vars: {},
|
||||
fired: {},
|
||||
notebook: [],
|
||||
difficulty,
|
||||
scene: startScene,
|
||||
flags: {},
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import type { Engine, Transition } from '../Engine';
|
|||
import { checkAll } from '../state';
|
||||
import type { CameraView, Hotspot, Scene } from '../types';
|
||||
import { buildWorld, type World } from '../../worlds';
|
||||
import { PICK_LAYER } from '../../worlds/common';
|
||||
import { PICK_LAYER, UV_LIGHT } from '../../worlds/common';
|
||||
|
||||
interface CamPose {
|
||||
pos: THREE.Vector3;
|
||||
|
|
@ -24,6 +24,10 @@ interface PropEntry {
|
|||
basePos: THREE.Vector3;
|
||||
baseQuat: THREE.Quaternion;
|
||||
baseVisible: boolean;
|
||||
/** Lumière : on ne la masque jamais (changer le nombre de lumières recompile tous les shaders), on l'éteint. */
|
||||
light?: { obj: THREE.Light; intensity: number };
|
||||
/** Encre invisible : uniforme « révélée en permanence ». */
|
||||
ink?: { value: number };
|
||||
mats: { mat: THREE.MeshStandardMaterial; color: THREE.Color; emissive: THREE.Color; intensity: number }[];
|
||||
}
|
||||
|
||||
|
|
@ -70,9 +74,12 @@ export class ThreeRenderer extends BaseRenderer {
|
|||
private downAt: [number, number] = [0, 0];
|
||||
private debugHit = '';
|
||||
private loadingEl: HTMLElement;
|
||||
/** Préchargement GPU en cours (écran de chargement affiché). */
|
||||
private warming = true;
|
||||
/** Rendu à la demande : on ne redessine que si quelque chose a changé. */
|
||||
private dirty = true;
|
||||
private hoveredObj: THREE.Object3D | null = null;
|
||||
private lastHitPoint: THREE.Vector3 | null = null;
|
||||
readonly quality: 'high' | 'low';
|
||||
/** ?test=1 : basse qualité, caméra et objets sans animation (tests automatisés). */
|
||||
readonly testMode: boolean;
|
||||
|
|
@ -125,6 +132,7 @@ export class ThreeRenderer extends BaseRenderer {
|
|||
this.composer.addPass(new OutputPass());
|
||||
|
||||
this.indexWorld();
|
||||
void this.warmUp();
|
||||
this.raycaster.layers.enable(PICK_LAYER);
|
||||
|
||||
const canvas = this.gl.domElement;
|
||||
|
|
@ -179,7 +187,9 @@ export class ThreeRenderer extends BaseRenderer {
|
|||
if (sm.emissive) mats.push({ mat: sm, color: sm.color.clone(), emissive: sm.emissive.clone(), intensity: sm.emissiveIntensity });
|
||||
}
|
||||
});
|
||||
this.props.set(rule.object, { obj, basePos: obj.position.clone(), baseQuat: obj.quaternion.clone(), baseVisible: obj.visible, mats });
|
||||
const light = (obj as THREE.Light).isLight ? { obj: obj as THREE.Light, intensity: (obj as THREE.Light).intensity } : undefined;
|
||||
const ink = ((obj as THREE.Mesh).material as THREE.Material | undefined)?.userData?.uRevealed as { value: number } | undefined;
|
||||
this.props.set(rule.object, { obj, basePos: obj.position.clone(), baseQuat: obj.quaternion.clone(), baseVisible: obj.visible, mats, light, ink });
|
||||
}
|
||||
for (const scene of scenario.scenes)
|
||||
for (const hs of scene.hotspots)
|
||||
|
|
@ -238,18 +248,88 @@ export class ThreeRenderer extends BaseRenderer {
|
|||
}
|
||||
|
||||
protected canInteract(): boolean {
|
||||
return !this.camAnim;
|
||||
return !this.camAnim && !this.warming;
|
||||
}
|
||||
|
||||
/** Vrai pendant un mouvement de caméra ou d'objet (utile aux tests). */
|
||||
/** Vrai pendant le préchargement ou un mouvement de caméra/d'objet (utile aux tests). */
|
||||
get busy(): boolean {
|
||||
return !!this.camAnim || this.tweens.length > 0;
|
||||
return this.warming || !!this.camAnim || this.tweens.length > 0;
|
||||
}
|
||||
|
||||
/** Statistiques GPU (tests de performance : aucune compilation de shader ne doit survenir en jeu). */
|
||||
renderStats(): { programs: number; textures: number; geometries: number } {
|
||||
return { programs: this.gl.info.programs?.length ?? 0, textures: this.gl.info.memory.textures, geometries: this.gl.info.memory.geometries };
|
||||
}
|
||||
|
||||
/**
|
||||
* Préchargement GPU, derrière l'écran « Chargement de la pièce… ».
|
||||
* Sans lui, three.js compile les shaders et envoie textures et géométries
|
||||
* au GPU au premier affichage de chaque objet : d'où un gros à-coup la
|
||||
* première fois qu'on se tourne vers un mur.
|
||||
*/
|
||||
private async warmUp(): Promise<void> {
|
||||
const t0 = performance.now();
|
||||
// Tous les objets visibles le temps du préchargement (y compris ceux encore cachés : clé, message UV...).
|
||||
const hidden: THREE.Object3D[] = [];
|
||||
const showAll = () =>
|
||||
this.world.root.traverse((o) => {
|
||||
if (!o.visible) {
|
||||
hidden.push(o);
|
||||
o.visible = true;
|
||||
}
|
||||
});
|
||||
const restore = () => {
|
||||
hidden.forEach((o) => (o.visible = false));
|
||||
hidden.length = 0;
|
||||
};
|
||||
|
||||
// 1. Compilation de tous les shaders (en parallèle si le pilote le permet)
|
||||
showAll();
|
||||
if (this.gl.extensions.has('KHR_parallel_shader_compile')) await this.gl.compileAsync(this.scene3d, this.camera);
|
||||
else this.gl.compile(this.scene3d, this.camera);
|
||||
restore();
|
||||
|
||||
// 2. Envoi de toutes les textures au GPU
|
||||
const textures = new Set<THREE.Texture>();
|
||||
this.world.root.traverse((o) => {
|
||||
const mesh = o as THREE.Mesh;
|
||||
if (!mesh.isMesh) return;
|
||||
for (const m of Array.isArray(mesh.material) ? mesh.material : [mesh.material]) {
|
||||
for (const v of Object.values(m)) if ((v as THREE.Texture)?.isTexture) textures.add(v as THREE.Texture);
|
||||
}
|
||||
});
|
||||
textures.forEach((t) => this.gl.initTexture(t));
|
||||
|
||||
// 3. Un rendu complet depuis chaque point de vue (géométries, ombres, passes de post-traitement)
|
||||
showAll();
|
||||
const saved = { pos: this.camera.position.clone(), quat: this.camera.quaternion.clone(), fov: this.camera.fov };
|
||||
const firstHotspotObj = this.world.root.getObjectByName('desk') ?? null;
|
||||
for (const scene of this.engine.scenario.scenes) {
|
||||
this.applyPose(this.poseOf(scene.camera));
|
||||
// Le contour (OutlinePass) a ses propres shaders : on le déclenche une fois.
|
||||
this.outline.selectedObjects = firstHotspotObj ? [firstHotspotObj] : [];
|
||||
this.composer.render(0);
|
||||
await new Promise((r) => requestAnimationFrame(r));
|
||||
}
|
||||
this.outline.selectedObjects = [];
|
||||
restore();
|
||||
this.applyPose(saved);
|
||||
|
||||
this.warming = false;
|
||||
this.refresh(true);
|
||||
this.dirty = true;
|
||||
this.loadingEl.classList.add('done');
|
||||
window.setTimeout(() => this.loadingEl.remove(), 700);
|
||||
console.info(`[escape] préchargement GPU : ${Math.round(performance.now() - t0)} ms, ${textures.size} textures, ${this.renderStats().programs} shaders`);
|
||||
}
|
||||
|
||||
// --- État du monde ------------------------------------------------------------------------
|
||||
|
||||
protected refreshStage(instant: boolean): void {
|
||||
this.dirty = true;
|
||||
UV_LIGHT.uUvActive.value = this.uvActive ? 1 : 0;
|
||||
UV_LIGHT.uUvRadius.value = this.engine.scenario.uvLight?.radius ?? 0.14;
|
||||
if (!this.uvActive) UV_LIGHT.uUvPoint.value.set(0, -100, 0);
|
||||
const state = this.engine.state;
|
||||
// Zones 3D actives de la scène courante
|
||||
this.hotspotByName.clear();
|
||||
|
|
@ -264,18 +344,24 @@ export class ThreeRenderer extends BaseRenderer {
|
|||
const quat = p.baseQuat.clone();
|
||||
let visible = p.baseVisible;
|
||||
let emissive: string | null = null;
|
||||
let revealed = false;
|
||||
for (const rule of this.engine.scenario.props ?? []) {
|
||||
if (rule.object !== name || !checkAll(state, rule.when)) continue;
|
||||
if (rule.visible !== undefined) visible = rule.visible;
|
||||
if (rule.offset) pos.add(new THREE.Vector3(...rule.offset));
|
||||
if (rule.rotation) quat.setFromEuler(new THREE.Euler(...rule.rotation));
|
||||
if (rule.emissive) emissive = rule.emissive;
|
||||
if (rule.reveal !== undefined) revealed = rule.reveal;
|
||||
if (rule.spin) {
|
||||
const angle = (state.vars[rule.spin.var] ?? 0) * rule.spin.step;
|
||||
quat.multiply(new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(...rule.spin.axis).normalize(), angle));
|
||||
}
|
||||
}
|
||||
p.obj.visible = visible;
|
||||
if (p.light) {
|
||||
p.light.obj.visible = true;
|
||||
p.light.obj.intensity = visible ? p.light.intensity : 0;
|
||||
} else p.obj.visible = visible;
|
||||
if (p.ink) p.ink.value = revealed ? 1 : 0;
|
||||
for (const m of p.mats) {
|
||||
if (emissive) {
|
||||
m.mat.emissive.set(emissive);
|
||||
|
|
@ -319,6 +405,7 @@ export class ThreeRenderer extends BaseRenderer {
|
|||
const hits = this.raycaster.intersectObject(this.world.root, true);
|
||||
const hit = hits.find((h) => this.isVisibleDeep(h.object));
|
||||
if (!hit) {
|
||||
this.lastHitPoint = null;
|
||||
this.debugHit = '';
|
||||
return { hs: null, obj: null };
|
||||
}
|
||||
|
|
@ -328,6 +415,7 @@ export class ThreeRenderer extends BaseRenderer {
|
|||
if (o.name) chain.push(o.name);
|
||||
if (!found.hs && o.name && this.hotspotByName.has(o.name)) found = { hs: this.hotspotByName.get(o.name)!, obj: o };
|
||||
}
|
||||
this.lastHitPoint = hit.point.clone();
|
||||
const p = hit.point;
|
||||
this.debugHit = `objet : ${chain.join(' ‹ ') || '(sans nom)'} · point : [${round(p.x)}, ${round(p.y)}, ${round(p.z)}]`;
|
||||
return found;
|
||||
|
|
@ -351,6 +439,16 @@ export class ThreeRenderer extends BaseRenderer {
|
|||
if (this.puzzleOpen) return;
|
||||
const { hs, obj } = this.pick(e);
|
||||
this.setHovered(this.camAnim ? null : hs, this.camAnim ? null : obj);
|
||||
// Lampe UV en main : le halo suit le point visé et révèle l'encre invisible.
|
||||
if (this.uvActive) {
|
||||
UV_LIGHT.uUvPoint.value.copy(this.lastHitPoint ?? new THREE.Vector3(0, -100, 0));
|
||||
this.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
private get uvActive(): boolean {
|
||||
const uv = this.engine.scenario.uvLight;
|
||||
return !!uv && this.engine.state.selected === uv.item;
|
||||
}
|
||||
|
||||
private onClick(e: MouseEvent): void {
|
||||
|
|
@ -478,9 +576,5 @@ export class ThreeRenderer extends BaseRenderer {
|
|||
this.dirty = false;
|
||||
this.composer.render(dt);
|
||||
|
||||
if (!this.loadingEl.classList.contains('done')) {
|
||||
this.loadingEl.classList.add('done');
|
||||
window.setTimeout(() => this.loadingEl.remove(), 700);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@ export type Action =
|
|||
| { add: string; value?: number; mod?: number }
|
||||
| { set: string; value: number }
|
||||
/** Action conditionnelle. */
|
||||
| { if: Condition[]; then: Action[]; else?: Action[] };
|
||||
| { if: Condition[]; then: Action[]; else?: Action[] }
|
||||
/** Propose de noter un indice dans le carnet (bouton dans le message affiché). */
|
||||
| { clue: string };
|
||||
|
||||
export type SoundName = 'click' | 'step' | 'success' | 'error' | 'unlock' | 'drawer' | 'pickup' | 'beep' | 'dial' | 'switch' | 'power' | 'reveal';
|
||||
|
||||
|
|
@ -81,6 +83,8 @@ export interface PropRule {
|
|||
rotation?: Vec3;
|
||||
/** Couleur émissive (allume un voyant, une lampe...). */
|
||||
emissive?: string;
|
||||
/** Encre invisible : true = révélée en permanence (sinon visible seulement sous la lampe UV). */
|
||||
reveal?: boolean;
|
||||
/**
|
||||
* Rotation pilotée par une variable : angle = valeur × step (radians)
|
||||
* autour de `axis`, ajoutée à la rotation initiale. Ex. une molette de cadenas.
|
||||
|
|
@ -103,6 +107,19 @@ export interface Combination {
|
|||
|
||||
export type Difficulty = 'easy' | 'hard';
|
||||
|
||||
/** Indice que le joueur peut noter dans son carnet. */
|
||||
export interface Clue {
|
||||
id: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
/** Objet d'inventaire qui, tenu en main, éclaire en UV sous la souris (révèle l'encre invisible). */
|
||||
export interface UvLight {
|
||||
item: string;
|
||||
/** Rayon du halo dans le monde, en mètres. */
|
||||
radius?: number;
|
||||
}
|
||||
|
||||
export interface Scene {
|
||||
id: string;
|
||||
title?: string;
|
||||
|
|
@ -159,4 +176,6 @@ export interface Scenario {
|
|||
combinations?: Combination[];
|
||||
/** Valeurs initiales des variables (ex. position de départ des molettes). */
|
||||
vars?: Record<string, number>;
|
||||
clues?: Clue[];
|
||||
uvLight?: UvLight;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,10 @@ import type { PuzzleContext } from '../puzzles/registry';
|
|||
* { "use": "key", "on": "lock" } sélectionner un objet puis cliquer sur une zone
|
||||
* { "combine": ["uvlamp", "batteries"] } combiner deux objets de l'inventaire
|
||||
* { "solve": "cipher" } résoudre le mini-jeu ouvert à l'écran
|
||||
* { "note": "digit3" } noter l'indice proposé par le dernier message
|
||||
* Chaque étape peut vérifier l'état après coup : "expect": ["item:key", "scene:desk", "won"].
|
||||
*/
|
||||
export type WalkStep = ({ click: string; times?: number } | { use: string; on: string } | { combine: [string, string] } | { solve: string }) & {
|
||||
export type WalkStep = ({ click: string; times?: number } | { use: string; on: string } | { combine: [string, string] } | { solve: string } | { note: string }) & {
|
||||
expect?: string[];
|
||||
};
|
||||
|
||||
|
|
@ -35,12 +36,17 @@ export interface WalkResult {
|
|||
|
||||
class HeadlessView implements View {
|
||||
messages: string[] = [];
|
||||
offered: string | null = null;
|
||||
puzzle: { def: PuzzleDef; ctx: PuzzleContext } | null = null;
|
||||
won = false;
|
||||
showScene(): void {}
|
||||
refresh(): void {}
|
||||
showMessage(text: string): void {
|
||||
this.messages.push(text);
|
||||
this.offered = null;
|
||||
}
|
||||
offerClue(clue: { id: string }): void {
|
||||
this.offered = clue.id;
|
||||
}
|
||||
openPuzzle(def: PuzzleDef, ctx: PuzzleContext): void {
|
||||
this.puzzle = { def, ctx };
|
||||
|
|
@ -89,6 +95,9 @@ export function runWalkthrough(scenario: Scenario, wt: Walkthrough): WalkResult
|
|||
const missing = step.combine.filter((it) => !state.inventory.includes(it));
|
||||
if (missing.length) err = `objets absents de l'inventaire : ${missing.join(', ')}`;
|
||||
else if (!engine.combine(step.combine[0], step.combine[1])) err = `combinaison ${step.combine.join(' + ')} sans effet`;
|
||||
} else if ('note' in step) {
|
||||
if (view.offered !== step.note) err = `l'indice "${step.note}" n'est pas proposé par le dernier message (proposé : ${view.offered ?? 'aucun'})`;
|
||||
else engine.noteClue(step.note);
|
||||
} else if ('solve' in step) {
|
||||
if (view.puzzle?.def.id !== step.solve) err = `le mini-jeu "${step.solve}" n'est pas ouvert (ouvert : ${view.puzzle?.def.id ?? 'aucun'})`;
|
||||
else view.puzzle.ctx.solve();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ function showMenu(): void {
|
|||
<h1>ESCAPE</h1>
|
||||
<p class="tagline">Prototype · moteur point & click</p>
|
||||
<div class="chapters"></div>
|
||||
<p class="keys">Clic : examiner · flèches : tourner / reculer (ou clic droit, Échap) · objet en main + autre objet : combiner · H : indice · D : mode debug</p>
|
||||
<p class="keys">Clic : examiner · flèches : tourner / reculer (ou clic droit, Échap) · objet en main + autre objet : combiner · C : carnet · H : indice · D : mode debug</p>
|
||||
<p class="keys"><b>Facile</b> : objets surlignés et nommés au survol · <b>Difficile</b> : seul le curseur vous guide</p>`;
|
||||
const list = screen.querySelector('.chapters')!;
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,43 +1,240 @@
|
|||
{
|
||||
"description": "Solution de référence du chapitre 1. Rejouée automatiquement par `npm test` (moteur seul) et `npm run smoke` (vrais clics dans le navigateur).",
|
||||
"steps": [
|
||||
{ "click": "desk", "expect": ["scene:desk"] },
|
||||
{ "click": "drawersLeft", "expect": ["item:uvlamp"] },
|
||||
{ "click": "__back" },
|
||||
{ "click": "__right", "expect": ["scene:east"] },
|
||||
{ "click": "vase", "expect": ["item:batteries"] },
|
||||
{ "combine": ["uvlamp", "batteries"], "expect": ["item:uvlampOn", "!item:uvlamp"] },
|
||||
{ "click": "painting", "expect": ["scene:painting"] },
|
||||
{ "use": "uvlampOn", "on": "canvas", "expect": ["flag:uv_painting"] },
|
||||
{ "click": "uvText" },
|
||||
{ "solve": "cipher", "expect": ["solved:cipher"] },
|
||||
{ "click": "__back" },
|
||||
{ "click": "__left", "expect": ["scene:north"] },
|
||||
{ "click": "clock", "expect": ["scene:clock"] },
|
||||
{ "click": "__back" },
|
||||
{ "click": "__left", "expect": ["scene:west"] },
|
||||
{ "click": "safe", "expect": ["scene:safe"] },
|
||||
{ "click": "dial1", "times": 8 },
|
||||
{ "click": "dial2", "times": 3 },
|
||||
{ "click": "dial3", "times": 2 },
|
||||
{ "click": "dial4", "times": 5, "expect": ["flag:safe_open"] },
|
||||
{ "click": "lever", "expect": ["item:lever"] },
|
||||
{ "click": "__back" },
|
||||
{ "click": "breaker", "expect": ["scene:breaker"] },
|
||||
{ "use": "lever", "on": "breakerBox", "expect": ["flag:lever_installed", "!item:lever"] },
|
||||
{ "click": "breakerLever", "expect": ["flag:power_on"] },
|
||||
{ "click": "__back" },
|
||||
{ "click": "__left", "expect": ["scene:south"] },
|
||||
{ "click": "panel" },
|
||||
{ "solve": "colorPanel", "expect": ["flag:drawer_open"] },
|
||||
{ "click": "__right" },
|
||||
{ "click": "__right", "expect": ["scene:north"] },
|
||||
{ "click": "desk" },
|
||||
{ "click": "key", "expect": ["item:key"] },
|
||||
{ "click": "__back" },
|
||||
{ "click": "__left" },
|
||||
{ "click": "__left", "expect": ["scene:south"] },
|
||||
{ "click": "door" },
|
||||
{ "use": "key", "on": "lock", "expect": ["won"] }
|
||||
{
|
||||
"click": "desk",
|
||||
"expect": [
|
||||
"scene:desk"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "drawerL1",
|
||||
"expect": [
|
||||
"scene:drawerLeft",
|
||||
"flag:drawerL1_open"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "uvlamp",
|
||||
"expect": [
|
||||
"item:uvlamp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "__back",
|
||||
"expect": [
|
||||
"scene:desk"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "__back",
|
||||
"expect": [
|
||||
"scene:north"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "__right",
|
||||
"expect": [
|
||||
"scene:east"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "vase",
|
||||
"expect": [
|
||||
"scene:vase"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "batteries",
|
||||
"expect": [
|
||||
"item:batteries"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "__back",
|
||||
"expect": [
|
||||
"scene:east"
|
||||
]
|
||||
},
|
||||
{
|
||||
"combine": [
|
||||
"uvlamp",
|
||||
"batteries"
|
||||
],
|
||||
"expect": [
|
||||
"item:uvlampOn",
|
||||
"!item:uvlamp"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "painting",
|
||||
"expect": [
|
||||
"scene:painting"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "digit1"
|
||||
},
|
||||
{
|
||||
"note": "digit1"
|
||||
},
|
||||
{
|
||||
"use": "uvlampOn",
|
||||
"on": "canvas",
|
||||
"expect": [
|
||||
"flag:uv_painting"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "uvText"
|
||||
},
|
||||
{
|
||||
"solve": "cipher",
|
||||
"expect": [
|
||||
"solved:cipher"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "__back"
|
||||
},
|
||||
{
|
||||
"click": "__left",
|
||||
"expect": [
|
||||
"scene:north"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "clock",
|
||||
"expect": [
|
||||
"scene:clock"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "clockFace"
|
||||
},
|
||||
{
|
||||
"note": "clock"
|
||||
},
|
||||
{
|
||||
"click": "__back"
|
||||
},
|
||||
{
|
||||
"click": "__left",
|
||||
"expect": [
|
||||
"scene:west"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "safe",
|
||||
"expect": [
|
||||
"scene:safe"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "dial1",
|
||||
"times": 8
|
||||
},
|
||||
{
|
||||
"click": "dial2",
|
||||
"times": 3
|
||||
},
|
||||
{
|
||||
"click": "dial3",
|
||||
"times": 2
|
||||
},
|
||||
{
|
||||
"click": "dial4",
|
||||
"times": 5,
|
||||
"expect": [
|
||||
"flag:safe_open"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "lever",
|
||||
"expect": [
|
||||
"item:lever"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "__back"
|
||||
},
|
||||
{
|
||||
"click": "breaker",
|
||||
"expect": [
|
||||
"scene:breaker"
|
||||
]
|
||||
},
|
||||
{
|
||||
"use": "lever",
|
||||
"on": "breakerBox",
|
||||
"expect": [
|
||||
"flag:lever_installed",
|
||||
"!item:lever"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "breakerLever",
|
||||
"expect": [
|
||||
"flag:power_on"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "__back"
|
||||
},
|
||||
{
|
||||
"click": "__left",
|
||||
"expect": [
|
||||
"scene:south"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "panel"
|
||||
},
|
||||
{
|
||||
"solve": "colorPanel",
|
||||
"expect": [
|
||||
"flag:drawer_open"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "__right"
|
||||
},
|
||||
{
|
||||
"click": "__right",
|
||||
"expect": [
|
||||
"scene:north"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "desk"
|
||||
},
|
||||
{
|
||||
"click": "key",
|
||||
"expect": [
|
||||
"item:key"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "__back"
|
||||
},
|
||||
{
|
||||
"click": "__left"
|
||||
},
|
||||
{
|
||||
"click": "__left",
|
||||
"expect": [
|
||||
"scene:south"
|
||||
]
|
||||
},
|
||||
{
|
||||
"click": "door"
|
||||
},
|
||||
{
|
||||
"use": "key",
|
||||
"on": "lock",
|
||||
"expect": [
|
||||
"won"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,16 +196,16 @@ button.primary:hover { background: #dbb55c; }
|
|||
.message {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: 14%;
|
||||
transform: translate(-50%, 12px);
|
||||
max-width: min(760px, 86%);
|
||||
padding: 14px 22px;
|
||||
top: 14px;
|
||||
transform: translate(-50%, -12px);
|
||||
max-width: min(700px, 80%);
|
||||
padding: 12px 20px;
|
||||
background: rgba(8, 9, 10, .86);
|
||||
border: 1px solid rgba(201, 162, 74, .35);
|
||||
border-radius: 8px;
|
||||
font-family: var(--serif);
|
||||
font-size: clamp(14px, 1.6vw, 18px);
|
||||
line-height: 1.55;
|
||||
font-size: clamp(13px, 1.45vw, 17px);
|
||||
line-height: 1.5;
|
||||
text-align: center;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
|
|
@ -217,6 +217,90 @@ button.primary:hover { background: #dbb55c; }
|
|||
.message.visible { opacity: 1; transform: translate(-50%, 0); }
|
||||
.message.hint { border-color: #5aa0d8; }
|
||||
.message.hint::before { content: 'Indice — '; color: #7fbaea; font-style: italic; }
|
||||
.message-text { display: block; }
|
||||
.clue-btn {
|
||||
pointer-events: auto;
|
||||
margin-top: 10px;
|
||||
font: 600 13px/1 system-ui, sans-serif;
|
||||
padding: 8px 14px;
|
||||
background: #2a2214;
|
||||
border-color: var(--brass-dark);
|
||||
color: #f1d58e;
|
||||
}
|
||||
.clue-btn::before { content: ''; display: inline-block; width: 12px; height: 14px; margin-right: 8px; vertical-align: -2px; background: linear-gradient(#e9dec4, #cdb88a); border-left: 3px solid #8a3a2a; border-radius: 1px; }
|
||||
.clue-btn:disabled { opacity: .8; cursor: default; }
|
||||
|
||||
/* Halo de la lampe UV (le révélateur d'encre est calculé en 3D, ceci est l'effet lumineux) */
|
||||
.uv-halo {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: clamp(140px, 17vw, 230px);
|
||||
aspect-ratio: 1;
|
||||
border-radius: 50%;
|
||||
background: radial-gradient(circle, rgba(180, 120, 255, .5) 0%, rgba(140, 80, 255, .28) 40%, rgba(90, 40, 220, 0) 70%);
|
||||
mix-blend-mode: screen;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
transition: opacity .25s;
|
||||
z-index: 12;
|
||||
}
|
||||
.uv-halo.visible { opacity: 1; }
|
||||
|
||||
/* Annonce « Objet obtenu » */
|
||||
.item-toast {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 46%;
|
||||
transform: translate(-50%, -50%);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 18px 34px 16px;
|
||||
border-radius: 14px;
|
||||
background: radial-gradient(ellipse at center, rgba(20, 16, 8, .92), rgba(8, 7, 4, .85));
|
||||
border: 1px solid rgba(201, 162, 74, .55);
|
||||
box-shadow: 0 0 60px rgba(201, 162, 74, .25), 0 20px 50px rgba(0, 0, 0, .7);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
z-index: 24;
|
||||
}
|
||||
.item-toast img { width: 72px; height: 72px; filter: drop-shadow(0 0 14px rgba(255, 215, 130, .45)); }
|
||||
.item-toast-label { font: 600 11px/1 system-ui, sans-serif; letter-spacing: .25em; text-transform: uppercase; color: var(--brass); }
|
||||
.item-toast-name { font-family: var(--serif); font-size: clamp(20px, 2.4vw, 28px); color: #f4e6c8; }
|
||||
.item-toast.show { animation: toast 2.4s ease forwards; }
|
||||
@keyframes toast {
|
||||
0% { opacity: 0; transform: translate(-50%, -40%) scale(.9); }
|
||||
12% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
|
||||
70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
|
||||
100% { opacity: 0; transform: translate(-50%, -62%) scale(.98); }
|
||||
}
|
||||
.slot.fresh { animation: fresh 0.8s ease 3; border-color: var(--brass); }
|
||||
@keyframes fresh { 50% { box-shadow: 0 0 0 3px rgba(201, 162, 74, .6), 0 0 22px rgba(201, 162, 74, .6); } }
|
||||
|
||||
/* Carnet d'indices */
|
||||
.notebook-btn b { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 4px; border-radius: 9px; background: var(--brass); color: #1a1408; font-size: 11px; }
|
||||
.notebook-btn.pulse { animation: fresh .8s ease 2; }
|
||||
.notebook {
|
||||
position: relative;
|
||||
width: min(560px, 84%);
|
||||
max-height: 80%;
|
||||
overflow: auto;
|
||||
padding: 26px 34px 30px 52px;
|
||||
border-radius: 6px;
|
||||
background:
|
||||
repeating-linear-gradient(transparent 0 31px, rgba(90, 120, 160, .28) 31px 32px),
|
||||
linear-gradient(90deg, transparent 38px, rgba(200, 70, 60, .45) 38px 40px, transparent 40px),
|
||||
#efe6cf;
|
||||
color: #2a2a4a;
|
||||
box-shadow: 0 25px 60px rgba(0, 0, 0, .8);
|
||||
font-family: 'Segoe Script', 'Bradley Hand', 'Comic Sans MS', cursive;
|
||||
}
|
||||
.notebook h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 24px; color: #3a2a1a; }
|
||||
.notebook ol { margin: 0; padding-left: 18px; line-height: 32px; font-size: 16px; }
|
||||
.notebook-empty { font-family: var(--serif); font-style: italic; color: #6a5a4a; line-height: 1.6; }
|
||||
.notebook .puzzle-close { top: 10px; right: 10px; color: var(--text); }
|
||||
|
||||
.tooltip {
|
||||
position: absolute;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import * as THREE from 'three';
|
||||
import * as T from './textures';
|
||||
import type { World } from './index';
|
||||
import { PICK_LAYER } from './common';
|
||||
import { PICK_LAYER, invisibleInk } from './common';
|
||||
|
||||
/**
|
||||
* Le bureau du professeur, en 3D, construit par code (primitives + textures
|
||||
|
|
@ -149,16 +149,65 @@ function desk(): THREE.Group {
|
|||
const g = group(name, x, 0, 0);
|
||||
g.add(box(0.5, 0.68, 0.72, M.woodDark, 0, 0.42, 0));
|
||||
for (const y of [0.6, 0.26]) {
|
||||
g.add(box(0.46, 0.3, 0.02, M.woodMid, 0, y, 0.37));
|
||||
const front = box(0.46, 0.3, 0.02, M.woodMid, 0, 0, 0.37);
|
||||
const handle = new THREE.Mesh(new THREE.CylinderGeometry(0.008, 0.008, 0.1, 12), M.brass);
|
||||
handle.rotation.z = Math.PI / 2;
|
||||
handle.position.set(0, y, 0.39);
|
||||
g.add(handle);
|
||||
handle.position.set(0, 0, 0.39);
|
||||
const drawer = group(undefined, 0, y, 0, front, handle);
|
||||
// Le tiroir du haut à gauche s'ouvre réellement (contenu : factures + lampe UV).
|
||||
if (name === 'drawersLeft' && y === 0.6) {
|
||||
drawer.name = 'drawerL1';
|
||||
drawer.add(...drawerBody(), ...drawerContents());
|
||||
}
|
||||
g.add(drawer);
|
||||
}
|
||||
for (const fx of [-0.22, 0.22]) for (const fz of [-0.32, 0.32]) g.add(box(0.05, 0.08, 0.05, M.woodBlack, fx, 0.04, fz));
|
||||
return g;
|
||||
};
|
||||
|
||||
/** Caisson intérieur d'un tiroir (visible une fois tiré). */
|
||||
function drawerBody(): THREE.Object3D[] {
|
||||
const inside = new THREE.MeshStandardMaterial({ color: '#3a2414', map: grain, roughness: 0.9 });
|
||||
return [
|
||||
box(0.42, 0.01, 0.5, inside, 0, -0.12, 0.11),
|
||||
box(0.01, 0.2, 0.5, inside, -0.205, -0.03, 0.11),
|
||||
box(0.01, 0.2, 0.5, inside, 0.205, -0.03, 0.11),
|
||||
box(0.42, 0.2, 0.01, inside, 0, -0.03, -0.14),
|
||||
];
|
||||
}
|
||||
|
||||
/** Factures en vrac et lampe UV à moitié cachée dessous. */
|
||||
function drawerContents(): THREE.Object3D[] {
|
||||
const paper = (c: string) => new THREE.MeshStandardMaterial({ color: c, roughness: 0.95 });
|
||||
const sheets: THREE.Object3D[] = [];
|
||||
[
|
||||
['#e9e1cc', -0.07, 0.12, 0.15],
|
||||
['#ddd3b8', -0.05, 0.16, -0.1],
|
||||
['#efe8d6', -0.02, 0.1, 0.32],
|
||||
].forEach(([c, x, z, r], i) => {
|
||||
const s = box(0.17, 0.003, 0.12, paper(c as string), x as number, -0.113 + i * 0.004, z as number);
|
||||
s.rotation.y = r as number;
|
||||
sheets.push(s);
|
||||
});
|
||||
// Lampe UV : corps sombre, tête et lentille violette qui dépasse des factures
|
||||
const body = new THREE.Mesh(new THREE.CylinderGeometry(0.016, 0.016, 0.12, 16), new THREE.MeshStandardMaterial({ color: '#3d4247', metalness: 0.6, roughness: 0.4 }));
|
||||
body.rotation.z = Math.PI / 2;
|
||||
const head = new THREE.Mesh(new THREE.CylinderGeometry(0.024, 0.02, 0.035, 16), new THREE.MeshStandardMaterial({ color: '#2c2f33', metalness: 0.6, roughness: 0.4 }));
|
||||
head.rotation.z = Math.PI / 2;
|
||||
head.position.x = 0.075;
|
||||
const lens = new THREE.Mesh(new THREE.CircleGeometry(0.02, 16), new THREE.MeshStandardMaterial({ color: '#6a3fc0', emissive: '#4a2a90', emissiveIntensity: 0.6, roughness: 0.2 }));
|
||||
lens.rotation.y = Math.PI / 2;
|
||||
lens.position.x = 0.093;
|
||||
const zone = pickZone(0.18, 0.09, 0.02, 0, 0);
|
||||
zone.rotation.x = -Math.PI / 2;
|
||||
const lamp = group('uvlampItem', 0.085, -0.098, 0.15, body, head, lens, zone);
|
||||
lamp.rotation.y = 0.5;
|
||||
// Une facture posée en travers de la lampe
|
||||
const over = box(0.15, 0.003, 0.1, paper('#e4dcc4'), 0.02, -0.08, 0.16);
|
||||
over.rotation.set(0.12, -0.4, 0.05);
|
||||
return [...sheets, lamp, over];
|
||||
}
|
||||
|
||||
// Tiroir secret : façade sans poignée, identique au bandeau du bureau.
|
||||
const drawerInside = new THREE.MeshStandardMaterial({ color: '#2a1a0e', roughness: 1 });
|
||||
const keyGroup = key();
|
||||
|
|
@ -343,18 +392,11 @@ function eastWall(): THREE.Group {
|
|||
canvas,
|
||||
pickZone(0.12, 0.14, 0.33, 0.24, 0.025, 'digit1'),
|
||||
);
|
||||
// Message à l'encre invisible : caché tant que la lampe UV ne l'a pas révélé.
|
||||
const uv = plane(
|
||||
0.92,
|
||||
0.41,
|
||||
new THREE.MeshBasicMaterial({ map: T.uvMessage(["SL JVMMYL Z'VBCYL", "H S'OLBYL VB SL", "ALTWZ Z'LZA HYYLAL"]), transparent: true, depthWrite: false, blending: THREE.AdditiveBlending }),
|
||||
0,
|
||||
-0.08,
|
||||
0.024,
|
||||
'uvMessage',
|
||||
);
|
||||
// Message à l'encre invisible : n'apparaît que dans le halo de la lampe UV,
|
||||
// puis reste visible une fois révélé. Enfant de la toile : un clic dessus = clic sur la toile.
|
||||
const uv = plane(0.92, 0.41, invisibleInk(T.uvMessage(["SL JVMMYL Z'VBCYL", "H S'OLBYL VB SL", "ALTWZ Z'LZA HYYLAL"])), 0, -0.08, 0.004, 'uvMessage');
|
||||
uv.userData.noShadow = true;
|
||||
painting.add(uv);
|
||||
canvas.add(uv);
|
||||
g.add(painting);
|
||||
// Applique de tableau
|
||||
const bar = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.02, 0.36, 16), M.brass);
|
||||
|
|
@ -369,10 +411,25 @@ function eastWall(): THREE.Group {
|
|||
|
||||
// Console et vase
|
||||
const vase = new THREE.Mesh(
|
||||
new THREE.LatheGeometry([new THREE.Vector2(0.0, 0), new THREE.Vector2(0.06, 0.0), new THREE.Vector2(0.09, 0.08), new THREE.Vector2(0.06, 0.2), new THREE.Vector2(0.04, 0.26), new THREE.Vector2(0.05, 0.28)], 32),
|
||||
new THREE.MeshStandardMaterial({ color: '#2c4a5e', roughness: 0.25, metalness: 0.1 }),
|
||||
new THREE.LatheGeometry([new THREE.Vector2(0.0, 0), new THREE.Vector2(0.06, 0.0), new THREE.Vector2(0.09, 0.08), new THREE.Vector2(0.07, 0.2), new THREE.Vector2(0.065, 0.26), new THREE.Vector2(0.075, 0.28)], 32),
|
||||
new THREE.MeshStandardMaterial({ color: '#2c4a5e', roughness: 0.25, metalness: 0.1, side: THREE.DoubleSide }),
|
||||
);
|
||||
const flowers = group(undefined, 0, 0.28, 0);
|
||||
// Fond du vase (intérieur) et deux piles cachées dedans
|
||||
const vaseBottom = new THREE.Mesh(new THREE.CircleGeometry(0.06, 24), new THREE.MeshStandardMaterial({ color: '#1d3442', roughness: 0.6 }));
|
||||
vaseBottom.rotation.x = -Math.PI / 2;
|
||||
vaseBottom.position.y = 0.005;
|
||||
const battery = (x: number, z: number, r: number) => {
|
||||
const b = new THREE.Mesh(new THREE.CylinderGeometry(0.0075, 0.0075, 0.05, 16), new THREE.MeshStandardMaterial({ color: '#2a2d31', metalness: 0.5, roughness: 0.4 }));
|
||||
const cap = new THREE.Mesh(new THREE.CylinderGeometry(0.0076, 0.0076, 0.014, 16), new THREE.MeshStandardMaterial({ color: '#c9a24a', metalness: 0.7, roughness: 0.3, emissive: '#5a4210', emissiveIntensity: 0.6 }));
|
||||
cap.position.y = 0.019;
|
||||
const bg = group(undefined, x, 0.013, z, b, cap);
|
||||
bg.rotation.set(Math.PI / 2, 0, r);
|
||||
return bg;
|
||||
};
|
||||
const batteryZone = pickZone(0.1, 0.1, 0, 0.03, 0);
|
||||
batteryZone.rotation.x = -Math.PI / 2;
|
||||
const batteries = group('batteriesItem', 0, 0, 0, battery(-0.012, 0.004, 0.4), battery(0.012, -0.006, -0.3), batteryZone);
|
||||
const flowers = group('flowers', 0, 0.28, 0);
|
||||
[
|
||||
['#c84a5a', -0.05, 0.25],
|
||||
['#e0b84a', 0.07, 0.2],
|
||||
|
|
@ -392,7 +449,7 @@ function eastWall(): THREE.Group {
|
|||
0.22,
|
||||
box(0.8, 0.04, 0.34, M.woodLight, 0, 0.8, 0),
|
||||
...[-0.36, 0.36].flatMap((x) => [-0.14, 0.14].map((z) => box(0.035, 0.78, 0.035, M.woodDark, x, 0.39, z))),
|
||||
group('vase', 0, 0.82, 0, vase, flowers, pickZone(0.24, 0.6, 0, 0.27, 0.1)),
|
||||
group('vase', 0, 0.82, 0, vase, vaseBottom, batteries, flowers, pickZone(0.24, 0.6, 0, 0.27, 0.1)),
|
||||
);
|
||||
g.add(consoleTable);
|
||||
return g;
|
||||
|
|
|
|||
|
|
@ -1,2 +1,38 @@
|
|||
import * as THREE from 'three';
|
||||
|
||||
/** Calque des zones cliquables invisibles : ignoré par la caméra, vu par le raycast. */
|
||||
export const PICK_LAYER = 1;
|
||||
|
||||
/**
|
||||
* Lampe UV : uniformes partagés par tous les matériaux « encre invisible ».
|
||||
* Le rendu met à jour le point visé par la souris quand la lampe est en main.
|
||||
*/
|
||||
export const UV_LIGHT = {
|
||||
uUvPoint: { value: new THREE.Vector3(0, -100, 0) },
|
||||
uUvRadius: { value: 0.14 },
|
||||
uUvActive: { value: 0 },
|
||||
};
|
||||
|
||||
/**
|
||||
* Matériau d'encre invisible : rien n'apparaît, sauf dans le halo de la lampe UV
|
||||
* ou une fois l'encre « révélée » (prop `reveal`, uniforme uRevealed).
|
||||
*/
|
||||
export function invisibleInk(map: THREE.Texture): THREE.MeshBasicMaterial {
|
||||
const mat = new THREE.MeshBasicMaterial({ map, transparent: true, depthWrite: false, blending: THREE.AdditiveBlending });
|
||||
const uRevealed = { value: 0 };
|
||||
mat.userData.uRevealed = uRevealed;
|
||||
mat.onBeforeCompile = (shader) => {
|
||||
Object.assign(shader.uniforms, UV_LIGHT, { uRevealed });
|
||||
shader.vertexShader = shader.vertexShader
|
||||
.replace('#include <common>', '#include <common>\nvarying vec3 vInkWorld;')
|
||||
.replace('#include <project_vertex>', '#include <project_vertex>\nvInkWorld = (modelMatrix * vec4(transformed, 1.0)).xyz;');
|
||||
shader.fragmentShader = shader.fragmentShader
|
||||
.replace('#include <common>', '#include <common>\nvarying vec3 vInkWorld;\nuniform vec3 uUvPoint;\nuniform float uUvRadius;\nuniform float uUvActive;\nuniform float uRevealed;')
|
||||
.replace(
|
||||
'#include <dithering_fragment>',
|
||||
'#include <dithering_fragment>\nfloat inkD = distance(vInkWorld, uUvPoint);\nfloat ink = max(uRevealed, uUvActive * (1.0 - smoothstep(uUvRadius * 0.5, uUvRadius, inkD)));\ngl_FragColor.a *= ink;',
|
||||
);
|
||||
};
|
||||
mat.customProgramCacheKey = () => 'invisible-ink';
|
||||
return mat;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,15 @@ describe('moteur', () => {
|
|||
expect(state.inventory).toEqual(['x', 'xy']);
|
||||
});
|
||||
|
||||
it('navigation générée (flèches)', () => {
|
||||
it('carnet : un indice proposé peut être noté une seule fois', () => {
|
||||
const { engine, state } = makeEngine({ clues: [{ id: 'c1', text: 'indice' }] });
|
||||
expect(engine.noteClue('c1')).toBe(true);
|
||||
expect(engine.noteClue('c1')).toBe(false);
|
||||
expect(engine.noteClue('inconnu')).toBe(false);
|
||||
expect(state.notebook).toEqual(['c1']);
|
||||
});
|
||||
|
||||
it('navigation générée (flèches)', () => {
|
||||
const { engine, state, hs } = makeEngine();
|
||||
engine.click(hs('__right'));
|
||||
expect(state.scene).toBe('b');
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ function check(state, c) {
|
|||
await page.click(`.chapter[data-chapter="${chapter}"] button[data-difficulty="${difficulty}"]`);
|
||||
await idle();
|
||||
await shot('00-depart');
|
||||
const statsStart = await page.evaluate(() => window.__escape.renderer.renderStats());
|
||||
|
||||
for (const [i, step] of wt.steps.entries()) {
|
||||
const label = `étape ${String(i + 1).padStart(2)} ${JSON.stringify(step)}`;
|
||||
|
|
@ -144,6 +145,9 @@ function check(state, c) {
|
|||
} else if ('combine' in step) {
|
||||
await slot(step.combine[0]);
|
||||
await slot(step.combine[1]);
|
||||
} else if ('note' in step) {
|
||||
await page.click('.message .clue-btn');
|
||||
await page.waitForFunction((id) => window.__escape.engine.state.notebook.includes(id), step.note);
|
||||
} else if ('solve' in step) {
|
||||
const def = await page.evaluate((id) => window.__escape.engine.scenario.puzzles.find((p) => p.id === id), step.solve);
|
||||
if (def.type === 'colorCode') {
|
||||
|
|
@ -170,6 +174,13 @@ function check(state, c) {
|
|||
}
|
||||
|
||||
await page.waitForSelector('.screen.win', { timeout: 5000 });
|
||||
// Performance : tout doit avoir été préparé au chargement. Une compilation de shader
|
||||
// en cours de partie provoque un à-coup visible (ex. première rotation vers un mur).
|
||||
const statsEnd = await page.evaluate(() => window.__escape.renderer.renderStats());
|
||||
console.log(` GPU : ${statsStart.programs} shaders et ${statsStart.textures} textures au départ, ${statsEnd.programs} et ${statsEnd.textures} à la fin`);
|
||||
if (statsEnd.programs > statsStart.programs)
|
||||
problems.push(`${statsEnd.programs - statsStart.programs} shader(s) compilé(s) en cours de partie : à-coup probable, à précharger dans ThreeRenderer.warmUp()`);
|
||||
if (statsEnd.textures > statsStart.textures) problems.push(`${statsEnd.textures - statsStart.textures} texture(s) envoyée(s) au GPU en cours de partie`);
|
||||
await shot('99-victoire');
|
||||
if (problems.length) throw new Error(`problèmes détectés pendant la partie :\n ${problems.join('\n ')}`);
|
||||
console.log(`✔ ${chapter} : victoire en ${((Date.now() - t0) / 1000).toFixed(1)} s`);
|
||||
|
|
@ -179,7 +190,7 @@ function check(state, c) {
|
|||
const file = path.join(SHOTS, `${chapter}-ECHEC.png`);
|
||||
await page.screenshot({ path: file }).catch(() => undefined);
|
||||
console.error(`✘ ${chapter} : ${e.message}`);
|
||||
if (problems.length) console.error(` ${problems.join('\n ')}`);
|
||||
if (problems.length && !e.message.startsWith('problèmes détectés')) console.error(` ${problems.join('\n ')}`);
|
||||
console.error(` capture : ${path.relative(ROOT, file)}`);
|
||||
}
|
||||
await page.close();
|
||||
|
|
|
|||
Loading…
Reference in New Issue