feat: interactions plus lisibles (messages, carnet, tiroir, vase, lampe UV)
- Messages en haut de l'écran, fermés au clic suivant (ou Échap). - Difficile : plus aucun changement de curseur sur les objets. - Annonce centrale « Objet obtenu » et case d'inventaire qui clignote. - Carnet d'indices : bouton « Noter dans le carnet » sous les messages porteurs d'indice (action clue), bouton Carnet / touche C. - Tiroir du bureau qui s'ouvre, vue rapprochée, lampe UV sous les factures. - Vase : fleurs écartées, vue dans le vase, piles à attraper. - Lampe UV : halo sous la souris, encre invisible révélée uniquement dans le halo (shader), puis fixée au clic. - Tests : walkthrough mis à jour, étape note, test du carnet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UJ9HPtCegSPg9vCFM1EyfT
This commit is contained in:
parent
54f5ae5622
commit
3eff83a603
|
|
@ -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` |
|
| 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 |
|
| 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 |
|
| 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` |
|
| 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"` |
|
| 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) :
|
**Difficulté** (au lancement d'une partie) :
|
||||||
|
|
||||||
- **Facile** : les objets interactifs s'entourent d'un contour doré et affichent leur nom au survol ;
|
- **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
|
## Le chapitre 1 : le bureau du professeur
|
||||||
|
|
||||||
|
|
@ -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.
|
- **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.
|
- **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.
|
- **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
|
### Choix structurants
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { isMuted, playSound, setMuted } from './audio';
|
import { isMuted, playSound, setMuted } from './audio';
|
||||||
import { cursorCss } from './cursors';
|
import { cursorCss } from './cursors';
|
||||||
import type { Engine, MessageKind, Transition, View } from './Engine';
|
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';
|
import { getPuzzleFactory, type PuzzleContext, type PuzzleInstance } from '../puzzles/registry';
|
||||||
|
|
||||||
export interface RendererOptions {
|
export interface RendererOptions {
|
||||||
|
|
@ -49,6 +49,13 @@ export abstract class BaseRenderer implements View {
|
||||||
protected debugEl: HTMLElement;
|
protected debugEl: HTMLElement;
|
||||||
protected debug = false;
|
protected debug = false;
|
||||||
private messageEl: HTMLElement;
|
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 tooltipEl: HTMLElement;
|
||||||
private puzzleLayer: HTMLElement;
|
private puzzleLayer: HTMLElement;
|
||||||
private inventoryEl: HTMLElement;
|
private inventoryEl: HTMLElement;
|
||||||
|
|
@ -75,6 +82,9 @@ export abstract class BaseRenderer implements View {
|
||||||
this.sceneLayer = el('div', 'scenes', this.stage);
|
this.sceneLayer = el('div', 'scenes', this.stage);
|
||||||
this.hotspotsEl = el('div', 'hotspots', this.stage);
|
this.hotspotsEl = el('div', 'hotspots', this.stage);
|
||||||
this.messageEl = el('div', 'message', 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.tooltipEl = el('div', 'tooltip', this.stage);
|
||||||
this.puzzleLayer = el('div', 'puzzle-layer', this.stage);
|
this.puzzleLayer = el('div', 'puzzle-layer', this.stage);
|
||||||
this.debugEl = el('div', 'debug-info', 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);
|
this.inventoryEl = el('div', 'inventory', hud);
|
||||||
const right = el('div', 'hud-right', hud);
|
const right = el('div', 'hud-right', hud);
|
||||||
this.timerEl = el('div', 'timer', right);
|
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);
|
const hintBtn = el('button', 'hud-btn', right);
|
||||||
hintBtn.innerHTML = '<span>?</span> Indice';
|
hintBtn.innerHTML = '<span>?</span> Indice';
|
||||||
hintBtn.title = 'Obtenir un indice (H)';
|
hintBtn.title = 'Obtenir un indice (H)';
|
||||||
|
|
@ -99,6 +112,15 @@ export abstract class BaseRenderer implements View {
|
||||||
|
|
||||||
this.heldEl = el('div', 'held-item', this.root);
|
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) => {
|
this.stage.addEventListener('contextmenu', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!this.puzzle) engine.goBack();
|
if (!this.puzzle) engine.goBack();
|
||||||
|
|
@ -139,8 +161,12 @@ export abstract class BaseRenderer implements View {
|
||||||
|
|
||||||
private onKey = (e: KeyboardEvent): void => {
|
private onKey = (e: KeyboardEvent): void => {
|
||||||
if (e.key === 'Escape') {
|
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 this.engine.goBack();
|
||||||
|
} else if ((e.key === 'c' || e.key === 'C') && !this.debug) {
|
||||||
|
this.toggleNotebook();
|
||||||
} else if (e.key === 'h' || e.key === 'H') {
|
} else if (e.key === 'h' || e.key === 'H') {
|
||||||
this.engine.nextHint();
|
this.engine.nextHint();
|
||||||
} else if (e.key === 'd' || e.key === 'D') {
|
} else if (e.key === 'd' || e.key === 'D') {
|
||||||
|
|
@ -163,6 +189,9 @@ export abstract class BaseRenderer implements View {
|
||||||
this.refreshStage(instant);
|
this.refreshStage(instant);
|
||||||
this.renderRectHotspots();
|
this.renderRectHotspots();
|
||||||
this.renderInventory();
|
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. */
|
/** 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 {
|
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';
|
let kind: CursorKind = 'look';
|
||||||
if (hs.cursor) kind = hs.cursor;
|
if (hs.cursor) kind = hs.cursor;
|
||||||
else {
|
else {
|
||||||
|
|
@ -250,12 +282,15 @@ export abstract class BaseRenderer implements View {
|
||||||
slot.title = item ? `${item.name}${item.description ? ' — ' + item.description : ''}` : id;
|
slot.title = item ? `${item.name}${item.description ? ' — ' + item.description : ''}` : id;
|
||||||
slot.dataset.item = id;
|
slot.dataset.item = id;
|
||||||
slot.classList.toggle('selected', state.selected === id);
|
slot.classList.toggle('selected', state.selected === id);
|
||||||
|
if (id === this.freshItem) slot.classList.add('fresh');
|
||||||
slot.onclick = () => {
|
slot.onclick = () => {
|
||||||
const sel = this.engine.state.selected;
|
const sel = this.engine.state.selected;
|
||||||
if (sel && sel !== id) this.engine.combine(sel, id);
|
if (sel && sel !== id) this.engine.combine(sel, id);
|
||||||
else this.engine.selectItem(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;
|
const held = state.selected ? this.engine.getItem(state.selected) : undefined;
|
||||||
if (held) {
|
if (held) {
|
||||||
this.heldEl.style.backgroundImage = `url("${this.opts.resolveImage(held.icon)}")`;
|
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 {
|
showMessage(text: string, kind: MessageKind): void {
|
||||||
window.clearTimeout(this.messageTimer);
|
window.clearTimeout(this.messageTimer);
|
||||||
this.messageEl.className = `message visible ${kind}`;
|
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');
|
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 {
|
protected hideMessage(): void {
|
||||||
|
window.clearTimeout(this.messageTimer);
|
||||||
this.messageEl.classList.remove('visible');
|
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 ------------------------------------------------------------------------
|
// --- Puzzles ------------------------------------------------------------------------
|
||||||
|
|
||||||
openPuzzle(def: PuzzleDef, ctx: PuzzleContext): void {
|
openPuzzle(def: PuzzleDef, ctx: PuzzleContext): void {
|
||||||
|
|
@ -325,6 +437,7 @@ export abstract class BaseRenderer implements View {
|
||||||
protected onMouseMove(e: MouseEvent): void {
|
protected onMouseMove(e: MouseEvent): void {
|
||||||
this.heldEl.style.transform = `translate(${e.clientX + 14}px, ${e.clientY + 14}px)`;
|
this.heldEl.style.transform = `translate(${e.clientX + 14}px, ${e.clientY + 14}px)`;
|
||||||
const r = this.stage.getBoundingClientRect();
|
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.
|
// 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 dy = this.engine.state.selected ? 62 : 22;
|
||||||
const tx = Math.min(e.clientX - r.left + 18, r.width - this.tooltipEl.offsetWidth - 8);
|
const tx = Math.min(e.clientX - r.left + 18, r.width - this.tooltipEl.offsetWidth - 8);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { playSound } from './audio';
|
import { playSound } from './audio';
|
||||||
import { checkAll, saveState, type GameState } from './state';
|
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';
|
import type { PuzzleContext } from '../puzzles/registry';
|
||||||
|
|
||||||
export type MessageKind = 'info' | 'hint' | 'item';
|
export type MessageKind = 'info' | 'hint' | 'item';
|
||||||
|
|
@ -14,6 +14,10 @@ export interface View {
|
||||||
showScene(scene: Scene, transition: Transition): void;
|
showScene(scene: Scene, transition: Transition): void;
|
||||||
refresh(): void;
|
refresh(): void;
|
||||||
showMessage(text: string, kind: MessageKind): 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;
|
openPuzzle(def: PuzzleDef, ctx: PuzzleContext): void;
|
||||||
closePuzzle(): void;
|
closePuzzle(): void;
|
||||||
showWin(): void;
|
showWin(): void;
|
||||||
|
|
@ -80,6 +84,20 @@ export class Engine {
|
||||||
return this.items.get(id);
|
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. */
|
/** Zones actives de la scène, y compris les bandes de navigation générées. */
|
||||||
activeHotspots(scene: Scene): Hotspot[] {
|
activeHotspots(scene: Scene): Hotspot[] {
|
||||||
const [w, h] = this.scenario.resolution;
|
const [w, h] = this.scenario.resolution;
|
||||||
|
|
@ -211,7 +229,11 @@ export class Engine {
|
||||||
} else if ('clearFlag' in action) {
|
} else if ('clearFlag' in action) {
|
||||||
delete this.state.flags[action.clearFlag];
|
delete this.state.flags[action.clearFlag];
|
||||||
} else if ('give' in action) {
|
} 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');
|
playSound('pickup');
|
||||||
} else if ('remove' in action) {
|
} else if ('remove' in action) {
|
||||||
this.state.inventory = this.state.inventory.filter((i) => i !== action.remove);
|
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;
|
this.state.vars[action.set] = action.value;
|
||||||
} else if ('if' in action) {
|
} else if ('if' in action) {
|
||||||
for (const a of checkAll(this.state, action.if) ? action.then : (action.else ?? [])) this.exec(a);
|
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) {
|
} else if ('win' in action) {
|
||||||
this.state.won = true;
|
this.state.won = true;
|
||||||
this.state.selected = null;
|
this.state.selected = null;
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,10 @@ export function analyzeScenario(s: Scenario): string[] {
|
||||||
trig.add(t.id);
|
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
|
// Scènes accessibles depuis le départ
|
||||||
const edges = new Map<string, string[]>();
|
const edges = new Map<string, string[]>();
|
||||||
for (const sc of s.scenes) {
|
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 scenes = new Set(s.scenes.map((x) => x.id));
|
||||||
const items = new Set(s.items.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 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[]) =>
|
const checkConds = (where: string, conds?: Condition[]) =>
|
||||||
conds?.forEach((c) => {
|
conds?.forEach((c) => {
|
||||||
|
|
@ -61,6 +62,7 @@ export function validateScenario(s: Scenario, imageExists: (p: string) => boolea
|
||||||
checkActions(where, a.then);
|
checkActions(where, a.then);
|
||||||
checkActions(where, a.else ?? []);
|
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 ('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 ('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}"`);
|
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 (!scenes.has(s.startScene)) errors.push(`startScene inconnue "${s.startScene}"`);
|
||||||
if (!s.world) errors.push(`"world" manquant`);
|
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) {
|
for (const sc of s.scenes) {
|
||||||
if (!sc.camera) errors.push(`scène ${sc.id} : "camera" manquante`);
|
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`);
|
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. */
|
/** Déclencheurs déjà exécutés. */
|
||||||
fired: Record<string, boolean>;
|
fired: Record<string, boolean>;
|
||||||
difficulty: Difficulty;
|
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 {
|
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,
|
scenarioId,
|
||||||
vars: {},
|
vars: {},
|
||||||
fired: {},
|
fired: {},
|
||||||
|
notebook: [],
|
||||||
difficulty,
|
difficulty,
|
||||||
scene: startScene,
|
scene: startScene,
|
||||||
flags: {},
|
flags: {},
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import type { Engine, Transition } from '../Engine';
|
||||||
import { checkAll } from '../state';
|
import { checkAll } from '../state';
|
||||||
import type { CameraView, Hotspot, Scene } from '../types';
|
import type { CameraView, Hotspot, Scene } from '../types';
|
||||||
import { buildWorld, type World } from '../../worlds';
|
import { buildWorld, type World } from '../../worlds';
|
||||||
import { PICK_LAYER } from '../../worlds/common';
|
import { PICK_LAYER, UV_LIGHT } from '../../worlds/common';
|
||||||
|
|
||||||
interface CamPose {
|
interface CamPose {
|
||||||
pos: THREE.Vector3;
|
pos: THREE.Vector3;
|
||||||
|
|
@ -26,6 +26,8 @@ interface PropEntry {
|
||||||
baseVisible: boolean;
|
baseVisible: boolean;
|
||||||
/** Lumière : on ne la masque jamais (changer le nombre de lumières recompile tous les shaders), on l'éteint. */
|
/** 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 };
|
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 }[];
|
mats: { mat: THREE.MeshStandardMaterial; color: THREE.Color; emissive: THREE.Color; intensity: number }[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,6 +79,7 @@ export class ThreeRenderer extends BaseRenderer {
|
||||||
/** Rendu à la demande : on ne redessine que si quelque chose a changé. */
|
/** Rendu à la demande : on ne redessine que si quelque chose a changé. */
|
||||||
private dirty = true;
|
private dirty = true;
|
||||||
private hoveredObj: THREE.Object3D | null = null;
|
private hoveredObj: THREE.Object3D | null = null;
|
||||||
|
private lastHitPoint: THREE.Vector3 | null = null;
|
||||||
readonly quality: 'high' | 'low';
|
readonly quality: 'high' | 'low';
|
||||||
/** ?test=1 : basse qualité, caméra et objets sans animation (tests automatisés). */
|
/** ?test=1 : basse qualité, caméra et objets sans animation (tests automatisés). */
|
||||||
readonly testMode: boolean;
|
readonly testMode: boolean;
|
||||||
|
|
@ -185,7 +188,8 @@ export class ThreeRenderer extends BaseRenderer {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const light = (obj as THREE.Light).isLight ? { obj: obj as THREE.Light, intensity: (obj as THREE.Light).intensity } : undefined;
|
const light = (obj as THREE.Light).isLight ? { obj: obj as THREE.Light, intensity: (obj as THREE.Light).intensity } : undefined;
|
||||||
this.props.set(rule.object, { obj, basePos: obj.position.clone(), baseQuat: obj.quaternion.clone(), baseVisible: obj.visible, mats, light });
|
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 scene of scenario.scenes)
|
||||||
for (const hs of scene.hotspots)
|
for (const hs of scene.hotspots)
|
||||||
|
|
@ -323,6 +327,9 @@ export class ThreeRenderer extends BaseRenderer {
|
||||||
|
|
||||||
protected refreshStage(instant: boolean): void {
|
protected refreshStage(instant: boolean): void {
|
||||||
this.dirty = true;
|
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;
|
const state = this.engine.state;
|
||||||
// Zones 3D actives de la scène courante
|
// Zones 3D actives de la scène courante
|
||||||
this.hotspotByName.clear();
|
this.hotspotByName.clear();
|
||||||
|
|
@ -337,12 +344,14 @@ export class ThreeRenderer extends BaseRenderer {
|
||||||
const quat = p.baseQuat.clone();
|
const quat = p.baseQuat.clone();
|
||||||
let visible = p.baseVisible;
|
let visible = p.baseVisible;
|
||||||
let emissive: string | null = null;
|
let emissive: string | null = null;
|
||||||
|
let revealed = false;
|
||||||
for (const rule of this.engine.scenario.props ?? []) {
|
for (const rule of this.engine.scenario.props ?? []) {
|
||||||
if (rule.object !== name || !checkAll(state, rule.when)) continue;
|
if (rule.object !== name || !checkAll(state, rule.when)) continue;
|
||||||
if (rule.visible !== undefined) visible = rule.visible;
|
if (rule.visible !== undefined) visible = rule.visible;
|
||||||
if (rule.offset) pos.add(new THREE.Vector3(...rule.offset));
|
if (rule.offset) pos.add(new THREE.Vector3(...rule.offset));
|
||||||
if (rule.rotation) quat.setFromEuler(new THREE.Euler(...rule.rotation));
|
if (rule.rotation) quat.setFromEuler(new THREE.Euler(...rule.rotation));
|
||||||
if (rule.emissive) emissive = rule.emissive;
|
if (rule.emissive) emissive = rule.emissive;
|
||||||
|
if (rule.reveal !== undefined) revealed = rule.reveal;
|
||||||
if (rule.spin) {
|
if (rule.spin) {
|
||||||
const angle = (state.vars[rule.spin.var] ?? 0) * rule.spin.step;
|
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));
|
quat.multiply(new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(...rule.spin.axis).normalize(), angle));
|
||||||
|
|
@ -352,6 +361,7 @@ export class ThreeRenderer extends BaseRenderer {
|
||||||
p.light.obj.visible = true;
|
p.light.obj.visible = true;
|
||||||
p.light.obj.intensity = visible ? p.light.intensity : 0;
|
p.light.obj.intensity = visible ? p.light.intensity : 0;
|
||||||
} else p.obj.visible = visible;
|
} else p.obj.visible = visible;
|
||||||
|
if (p.ink) p.ink.value = revealed ? 1 : 0;
|
||||||
for (const m of p.mats) {
|
for (const m of p.mats) {
|
||||||
if (emissive) {
|
if (emissive) {
|
||||||
m.mat.emissive.set(emissive);
|
m.mat.emissive.set(emissive);
|
||||||
|
|
@ -395,6 +405,7 @@ export class ThreeRenderer extends BaseRenderer {
|
||||||
const hits = this.raycaster.intersectObject(this.world.root, true);
|
const hits = this.raycaster.intersectObject(this.world.root, true);
|
||||||
const hit = hits.find((h) => this.isVisibleDeep(h.object));
|
const hit = hits.find((h) => this.isVisibleDeep(h.object));
|
||||||
if (!hit) {
|
if (!hit) {
|
||||||
|
this.lastHitPoint = null;
|
||||||
this.debugHit = '';
|
this.debugHit = '';
|
||||||
return { hs: null, obj: null };
|
return { hs: null, obj: null };
|
||||||
}
|
}
|
||||||
|
|
@ -404,6 +415,7 @@ export class ThreeRenderer extends BaseRenderer {
|
||||||
if (o.name) chain.push(o.name);
|
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 };
|
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;
|
const p = hit.point;
|
||||||
this.debugHit = `objet : ${chain.join(' ‹ ') || '(sans nom)'} · point : [${round(p.x)}, ${round(p.y)}, ${round(p.z)}]`;
|
this.debugHit = `objet : ${chain.join(' ‹ ') || '(sans nom)'} · point : [${round(p.x)}, ${round(p.y)}, ${round(p.z)}]`;
|
||||||
return found;
|
return found;
|
||||||
|
|
@ -427,6 +439,16 @@ export class ThreeRenderer extends BaseRenderer {
|
||||||
if (this.puzzleOpen) return;
|
if (this.puzzleOpen) return;
|
||||||
const { hs, obj } = this.pick(e);
|
const { hs, obj } = this.pick(e);
|
||||||
this.setHovered(this.camAnim ? null : hs, this.camAnim ? null : obj);
|
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 {
|
private onClick(e: MouseEvent): void {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,9 @@ export type Action =
|
||||||
| { add: string; value?: number; mod?: number }
|
| { add: string; value?: number; mod?: number }
|
||||||
| { set: string; value: number }
|
| { set: string; value: number }
|
||||||
/** Action conditionnelle. */
|
/** 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';
|
export type SoundName = 'click' | 'step' | 'success' | 'error' | 'unlock' | 'drawer' | 'pickup' | 'beep' | 'dial' | 'switch' | 'power' | 'reveal';
|
||||||
|
|
||||||
|
|
@ -81,6 +83,8 @@ export interface PropRule {
|
||||||
rotation?: Vec3;
|
rotation?: Vec3;
|
||||||
/** Couleur émissive (allume un voyant, une lampe...). */
|
/** Couleur émissive (allume un voyant, une lampe...). */
|
||||||
emissive?: string;
|
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)
|
* Rotation pilotée par une variable : angle = valeur × step (radians)
|
||||||
* autour de `axis`, ajoutée à la rotation initiale. Ex. une molette de cadenas.
|
* 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';
|
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 {
|
export interface Scene {
|
||||||
id: string;
|
id: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
|
@ -159,4 +176,6 @@ export interface Scenario {
|
||||||
combinations?: Combination[];
|
combinations?: Combination[];
|
||||||
/** Valeurs initiales des variables (ex. position de départ des molettes). */
|
/** Valeurs initiales des variables (ex. position de départ des molettes). */
|
||||||
vars?: Record<string, number>;
|
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
|
* { "use": "key", "on": "lock" } sélectionner un objet puis cliquer sur une zone
|
||||||
* { "combine": ["uvlamp", "batteries"] } combiner deux objets de l'inventaire
|
* { "combine": ["uvlamp", "batteries"] } combiner deux objets de l'inventaire
|
||||||
* { "solve": "cipher" } résoudre le mini-jeu ouvert à l'écran
|
* { "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"].
|
* 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[];
|
expect?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -35,12 +36,17 @@ export interface WalkResult {
|
||||||
|
|
||||||
class HeadlessView implements View {
|
class HeadlessView implements View {
|
||||||
messages: string[] = [];
|
messages: string[] = [];
|
||||||
|
offered: string | null = null;
|
||||||
puzzle: { def: PuzzleDef; ctx: PuzzleContext } | null = null;
|
puzzle: { def: PuzzleDef; ctx: PuzzleContext } | null = null;
|
||||||
won = false;
|
won = false;
|
||||||
showScene(): void {}
|
showScene(): void {}
|
||||||
refresh(): void {}
|
refresh(): void {}
|
||||||
showMessage(text: string): void {
|
showMessage(text: string): void {
|
||||||
this.messages.push(text);
|
this.messages.push(text);
|
||||||
|
this.offered = null;
|
||||||
|
}
|
||||||
|
offerClue(clue: { id: string }): void {
|
||||||
|
this.offered = clue.id;
|
||||||
}
|
}
|
||||||
openPuzzle(def: PuzzleDef, ctx: PuzzleContext): void {
|
openPuzzle(def: PuzzleDef, ctx: PuzzleContext): void {
|
||||||
this.puzzle = { def, ctx };
|
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));
|
const missing = step.combine.filter((it) => !state.inventory.includes(it));
|
||||||
if (missing.length) err = `objets absents de l'inventaire : ${missing.join(', ')}`;
|
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 (!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) {
|
} 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'})`;
|
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();
|
else view.puzzle.ctx.solve();
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ function showMenu(): void {
|
||||||
<h1>ESCAPE</h1>
|
<h1>ESCAPE</h1>
|
||||||
<p class="tagline">Prototype · moteur point & click</p>
|
<p class="tagline">Prototype · moteur point & click</p>
|
||||||
<div class="chapters"></div>
|
<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>`;
|
<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')!;
|
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).",
|
"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": [
|
"steps": [
|
||||||
{ "click": "desk", "expect": ["scene:desk"] },
|
{
|
||||||
{ "click": "drawersLeft", "expect": ["item:uvlamp"] },
|
"click": "desk",
|
||||||
{ "click": "__back" },
|
"expect": [
|
||||||
{ "click": "__right", "expect": ["scene:east"] },
|
"scene:desk"
|
||||||
{ "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": "drawerL1",
|
||||||
{ "click": "uvText" },
|
"expect": [
|
||||||
{ "solve": "cipher", "expect": ["solved:cipher"] },
|
"scene:drawerLeft",
|
||||||
{ "click": "__back" },
|
"flag:drawerL1_open"
|
||||||
{ "click": "__left", "expect": ["scene:north"] },
|
]
|
||||||
{ "click": "clock", "expect": ["scene:clock"] },
|
},
|
||||||
{ "click": "__back" },
|
{
|
||||||
{ "click": "__left", "expect": ["scene:west"] },
|
"click": "uvlamp",
|
||||||
{ "click": "safe", "expect": ["scene:safe"] },
|
"expect": [
|
||||||
{ "click": "dial1", "times": 8 },
|
"item:uvlamp"
|
||||||
{ "click": "dial2", "times": 3 },
|
]
|
||||||
{ "click": "dial3", "times": 2 },
|
},
|
||||||
{ "click": "dial4", "times": 5, "expect": ["flag:safe_open"] },
|
{
|
||||||
{ "click": "lever", "expect": ["item:lever"] },
|
"click": "__back",
|
||||||
{ "click": "__back" },
|
"expect": [
|
||||||
{ "click": "breaker", "expect": ["scene:breaker"] },
|
"scene:desk"
|
||||||
{ "use": "lever", "on": "breakerBox", "expect": ["flag:lever_installed", "!item:lever"] },
|
]
|
||||||
{ "click": "breakerLever", "expect": ["flag:power_on"] },
|
},
|
||||||
{ "click": "__back" },
|
{
|
||||||
{ "click": "__left", "expect": ["scene:south"] },
|
"click": "__back",
|
||||||
{ "click": "panel" },
|
"expect": [
|
||||||
{ "solve": "colorPanel", "expect": ["flag:drawer_open"] },
|
"scene:north"
|
||||||
{ "click": "__right" },
|
]
|
||||||
{ "click": "__right", "expect": ["scene:north"] },
|
},
|
||||||
{ "click": "desk" },
|
{
|
||||||
{ "click": "key", "expect": ["item:key"] },
|
"click": "__right",
|
||||||
{ "click": "__back" },
|
"expect": [
|
||||||
{ "click": "__left" },
|
"scene:east"
|
||||||
{ "click": "__left", "expect": ["scene:south"] },
|
]
|
||||||
{ "click": "door" },
|
},
|
||||||
{ "use": "key", "on": "lock", "expect": ["won"] }
|
{
|
||||||
|
"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 {
|
.message {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
bottom: 14%;
|
top: 14px;
|
||||||
transform: translate(-50%, 12px);
|
transform: translate(-50%, -12px);
|
||||||
max-width: min(760px, 86%);
|
max-width: min(700px, 80%);
|
||||||
padding: 14px 22px;
|
padding: 12px 20px;
|
||||||
background: rgba(8, 9, 10, .86);
|
background: rgba(8, 9, 10, .86);
|
||||||
border: 1px solid rgba(201, 162, 74, .35);
|
border: 1px solid rgba(201, 162, 74, .35);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
font-family: var(--serif);
|
font-family: var(--serif);
|
||||||
font-size: clamp(14px, 1.6vw, 18px);
|
font-size: clamp(13px, 1.45vw, 17px);
|
||||||
line-height: 1.55;
|
line-height: 1.5;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
@ -217,6 +217,90 @@ button.primary:hover { background: #dbb55c; }
|
||||||
.message.visible { opacity: 1; transform: translate(-50%, 0); }
|
.message.visible { opacity: 1; transform: translate(-50%, 0); }
|
||||||
.message.hint { border-color: #5aa0d8; }
|
.message.hint { border-color: #5aa0d8; }
|
||||||
.message.hint::before { content: 'Indice — '; color: #7fbaea; font-style: italic; }
|
.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 {
|
.tooltip {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
import * as T from './textures';
|
import * as T from './textures';
|
||||||
import type { World } from './index';
|
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
|
* 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);
|
const g = group(name, x, 0, 0);
|
||||||
g.add(box(0.5, 0.68, 0.72, M.woodDark, 0, 0.42, 0));
|
g.add(box(0.5, 0.68, 0.72, M.woodDark, 0, 0.42, 0));
|
||||||
for (const y of [0.6, 0.26]) {
|
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);
|
const handle = new THREE.Mesh(new THREE.CylinderGeometry(0.008, 0.008, 0.1, 12), M.brass);
|
||||||
handle.rotation.z = Math.PI / 2;
|
handle.rotation.z = Math.PI / 2;
|
||||||
handle.position.set(0, y, 0.39);
|
handle.position.set(0, 0, 0.39);
|
||||||
g.add(handle);
|
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));
|
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;
|
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.
|
// Tiroir secret : façade sans poignée, identique au bandeau du bureau.
|
||||||
const drawerInside = new THREE.MeshStandardMaterial({ color: '#2a1a0e', roughness: 1 });
|
const drawerInside = new THREE.MeshStandardMaterial({ color: '#2a1a0e', roughness: 1 });
|
||||||
const keyGroup = key();
|
const keyGroup = key();
|
||||||
|
|
@ -343,18 +392,11 @@ function eastWall(): THREE.Group {
|
||||||
canvas,
|
canvas,
|
||||||
pickZone(0.12, 0.14, 0.33, 0.24, 0.025, 'digit1'),
|
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é.
|
// Message à l'encre invisible : n'apparaît que dans le halo de la lampe UV,
|
||||||
const uv = plane(
|
// puis reste visible une fois révélé. Enfant de la toile : un clic dessus = clic sur la toile.
|
||||||
0.92,
|
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');
|
||||||
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',
|
|
||||||
);
|
|
||||||
uv.userData.noShadow = true;
|
uv.userData.noShadow = true;
|
||||||
painting.add(uv);
|
canvas.add(uv);
|
||||||
g.add(painting);
|
g.add(painting);
|
||||||
// Applique de tableau
|
// Applique de tableau
|
||||||
const bar = new THREE.Mesh(new THREE.CylinderGeometry(0.02, 0.02, 0.36, 16), M.brass);
|
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
|
// Console et vase
|
||||||
const vase = new THREE.Mesh(
|
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.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 }),
|
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],
|
['#c84a5a', -0.05, 0.25],
|
||||||
['#e0b84a', 0.07, 0.2],
|
['#e0b84a', 0.07, 0.2],
|
||||||
|
|
@ -392,7 +449,7 @@ function eastWall(): THREE.Group {
|
||||||
0.22,
|
0.22,
|
||||||
box(0.8, 0.04, 0.34, M.woodLight, 0, 0.8, 0),
|
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))),
|
...[-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);
|
g.add(consoleTable);
|
||||||
return g;
|
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. */
|
/** Calque des zones cliquables invisibles : ignoré par la caméra, vu par le raycast. */
|
||||||
export const PICK_LAYER = 1;
|
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']);
|
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();
|
const { engine, state, hs } = makeEngine();
|
||||||
engine.click(hs('__right'));
|
engine.click(hs('__right'));
|
||||||
expect(state.scene).toBe('b');
|
expect(state.scene).toBe('b');
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,9 @@ function check(state, c) {
|
||||||
} else if ('combine' in step) {
|
} else if ('combine' in step) {
|
||||||
await slot(step.combine[0]);
|
await slot(step.combine[0]);
|
||||||
await slot(step.combine[1]);
|
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) {
|
} else if ('solve' in step) {
|
||||||
const def = await page.evaluate((id) => window.__escape.engine.scenario.puzzles.find((p) => p.id === id), step.solve);
|
const def = await page.evaluate((id) => window.__escape.engine.scenario.puzzles.find((p) => p.id === id), step.solve);
|
||||||
if (def.type === 'colorCode') {
|
if (def.type === 'colorCode') {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue