Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 63c2b294c1 | |||
| 10b0d4fc16 | |||
| b1037d5107 | |||
| 18fb5e39e9 | |||
| ff4ead1d24 | |||
| 974f340d33 | |||
| c6283d492c | |||
| 83194df14f | |||
| 918ee49d7c | |||
| c0e7567849 | |||
| 931308c92c | |||
| 4e1ca708b2 | |||
| ca6c8e00b6 | |||
| 220a661d6d | |||
| 0a3966a339 | |||
| be5d03a30c | |||
| ed0683d814 | |||
| d9a92e336c | |||
| 89050331df | |||
| 0f211cc169 | |||
| 6a0215d1a6 | |||
| 2a6a028e1d | |||
| a609314411 | |||
| d1665891f4 | |||
| eb5d4076d1 | |||
| 5177f43d96 | |||
| ff1ec56729 | |||
| cd0afcda8c | |||
| 813c10f3f7 |
@@ -17,8 +17,10 @@ Implemented missions:
|
|||||||
## Main Files
|
## Main Files
|
||||||
|
|
||||||
| File | Responsibility |
|
| File | Responsibility |
|
||||||
| ---------------------------------------------- | ------------------------------------------------- |
|
| ----------------------------------------------------- | ------------------------------------------------- |
|
||||||
| `src/components/three/gameplay/RepairGame.tsx` | Orchestrates the repair step machine |
|
| `src/components/three/gameplay/RepairGame.tsx` | Orchestrates the repair step machine |
|
||||||
|
| `src/components/three/gameplay/RepairFocusBubble.tsx` | Dark sphere shroud + cocoon decor during focus |
|
||||||
|
| `src/managers/stores/useRepairFocusStore.ts` | Global flag + center for the repair focus bubble |
|
||||||
| `src/data/gameplay/repairMissions.ts` | Mission-specific data |
|
| `src/data/gameplay/repairMissions.ts` | Mission-specific data |
|
||||||
| `src/types/gameplay/repairMission.ts` | Mission ids, step ids, guards |
|
| `src/types/gameplay/repairMission.ts` | Mission ids, step ids, guards |
|
||||||
| `src/managers/stores/useGameStore.ts` | Global progression and mission transitions |
|
| `src/managers/stores/useGameStore.ts` | Global progression and mission transitions |
|
||||||
@@ -159,8 +161,6 @@ The repair case appears near the mission object. The player can:
|
|||||||
|
|
||||||
Both paths move to `fragmented`.
|
Both paths move to `fragmented`.
|
||||||
|
|
||||||
`useRepairMovementLocked()` locks player movement during focused repair steps and drives the repair movement indicator.
|
|
||||||
|
|
||||||
### Fragmented
|
### Fragmented
|
||||||
|
|
||||||
File:
|
File:
|
||||||
@@ -171,6 +171,10 @@ src/components/three/models/ExplodableModel.tsx
|
|||||||
|
|
||||||
The mission object is shown split apart. A timer then moves the mission to `scanning`.
|
The mission object is shown split apart. A timer then moves the mission to `scanning`.
|
||||||
|
|
||||||
|
`ExplodedModel.createParts` walks the GLTF tree recursively, descending through any single mesh-bearing wrapper node (e.g. `Scene > Moto > Eclatement` for the Ebike) until it reaches a node with multiple mesh-bearing children. Those children are the natural "explosion groups" authored by the modeler. This avoids exploding raw leaf meshes in local space when the model has extra empty wrapper nodes above the intended group.
|
||||||
|
|
||||||
|
When mounted, `RepairGame` applies `RepairMissionConfig.modelRotation` and `modelScale` to the fragmented model so it lines up with the source inspection model in world space (e.g. the parked Ebike using `EBIKE_WORLD_ROTATION_Y` / `EBIKE_WORLD_SCALE`).
|
||||||
|
|
||||||
The default delay comes from:
|
The default delay comes from:
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
@@ -256,6 +260,21 @@ The repaired object remains visible. The player validates the completion target,
|
|||||||
2. the case plays its exit animation
|
2. the case plays its exit animation
|
||||||
3. `completeMission(mission)` advances the global game progression
|
3. `completeMission(mission)` advances the global game progression
|
||||||
|
|
||||||
|
## Focus Bubble
|
||||||
|
|
||||||
|
While the player is in `fragmented`, `scanning`, `repairing` or `reassembling`, `RepairGame` flips `useRepairFocusStore.active = true` and publishes the snapped world center of the repair model.
|
||||||
|
|
||||||
|
`RepairFocusBubble` reads the store and:
|
||||||
|
|
||||||
|
- renders a `BackSide` sphere (radius 1, scaled 0 → 10m) tinted `#060814` at opacity 0.92
|
||||||
|
- grows the sphere with GSAP `expo.out` over 2.5 s when focus turns on
|
||||||
|
- shrinks back with `expo.in` over 1.2 s when focus turns off
|
||||||
|
- mounts a small "cocoon" decor pass inside (subtle grid floor + soft directional light + ambient) that fades in once the bubble is mostly grown
|
||||||
|
|
||||||
|
`Environment.tsx` and `GameStageContent.tsx` consume the same store flag to unmount the vegetation system and the zone debug visuals while the bubble is up, so trees and gizmos do not pierce the shroud. Terrain, water, sky, clouds and grass remain visible behind the bubble.
|
||||||
|
|
||||||
|
The bubble is mounted both in `GameStageContent` (production scene) and `TestMap` (physics test scene) so the behaviour matches in both contexts.
|
||||||
|
|
||||||
## Repair Case Details
|
## Repair Case Details
|
||||||
|
|
||||||
The case model implementation lives in:
|
The case model implementation lives in:
|
||||||
|
|||||||
+6
-12
@@ -2,24 +2,18 @@
|
|||||||
"version": 1,
|
"version": 1,
|
||||||
"cinematics": [
|
"cinematics": [
|
||||||
{
|
{
|
||||||
"id": "intro_overview",
|
"id": "outro_farm_drone",
|
||||||
"timecode": 0,
|
"timecode": 0,
|
||||||
"dialogueCues": [
|
|
||||||
{
|
|
||||||
"time": 0,
|
|
||||||
"dialogueId": "narrateur_bienvenueaaltera"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"cameraKeyframes": [
|
"cameraKeyframes": [
|
||||||
{
|
{
|
||||||
"time": 0,
|
"time": 0,
|
||||||
"position": [8, 5, 12],
|
"position": [-24, 5, 65],
|
||||||
"target": [0, 2, 0]
|
"target": [-24, 2, 42]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"time": 4,
|
"time": 10,
|
||||||
"position": [12, 4, -6],
|
"position": [-24, 90, 200],
|
||||||
"target": [10, 1.4, -8]
|
"target": [-24, 0, 42]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-32
@@ -39340,41 +39340,41 @@
|
|||||||
"rotation": [0, 0.0027, 0.0819],
|
"rotation": [0, 0.0027, 0.0819],
|
||||||
"scale": [1, 1, 1]
|
"scale": [1, 1, 1]
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pylone",
|
||||||
|
"type": "Object3D",
|
||||||
|
"position": [-22.8219, 6.7669, 28.1767],
|
||||||
|
"rotation": [0, 0.0027, 0.0819],
|
||||||
|
"scale": [1, 1, 1],
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"name": "pylone",
|
||||||
|
"type": "Mesh",
|
||||||
|
"position": [-22.8219, 6.7669, 28.1767],
|
||||||
|
"rotation": [0, 0.0027, 0.0819],
|
||||||
|
"scale": [1, 1, 1]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pylone",
|
||||||
|
"type": "Object3D",
|
||||||
|
"position": [-31.5396, 5.5095, 36.2489],
|
||||||
|
"rotation": [0, 0.0027, 0.0819],
|
||||||
|
"scale": [1, 1, 1],
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"name": "pylone",
|
||||||
|
"type": "Mesh",
|
||||||
|
"position": [-31.5396, 5.5095, 36.2489],
|
||||||
|
"rotation": [0, 0.0027, 0.0819],
|
||||||
|
"scale": [1, 1, 1]
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"id": "repair:pylon"
|
"id": "repair:pylon"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "pylone",
|
|
||||||
"type": "Object3D",
|
|
||||||
"position": [-22.8219, 6.7669, 28.1767],
|
|
||||||
"rotation": [0, 0.0027, 0.0819],
|
|
||||||
"scale": [1, 1, 1],
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"name": "pylone",
|
|
||||||
"type": "Mesh",
|
|
||||||
"position": [-22.8219, 6.7669, 28.1767],
|
|
||||||
"rotation": [0, 0.0027, 0.0819],
|
|
||||||
"scale": [1, 1, 1]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "pylone",
|
|
||||||
"type": "Object3D",
|
|
||||||
"position": [-31.5396, 5.5095, 36.2489],
|
|
||||||
"rotation": [0, 0.0027, 0.0819],
|
|
||||||
"scale": [1, 1, 1],
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"name": "pylone",
|
|
||||||
"type": "Mesh",
|
|
||||||
"position": [-31.5396, 5.5095, 36.2489],
|
|
||||||
"rotation": [0, 0.0027, 0.0819],
|
|
||||||
"scale": [1, 1, 1]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "pylone",
|
"name": "pylone",
|
||||||
"type": "Object3D",
|
"type": "Object3D",
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
+161
-646
File diff suppressed because it is too large
Load Diff
@@ -78,19 +78,19 @@
|
|||||||
{
|
{
|
||||||
"id": "narrateur_coupureelec",
|
"id": "narrateur_coupureelec",
|
||||||
"voice": "narrateur",
|
"voice": "narrateur",
|
||||||
"audio": "/sounds/dialogue/narrateur_coupureélec.mp3",
|
"audio": "/sounds/dialogue/narrateur_coupure_elec.mp3",
|
||||||
"subtitleCueIndex": 9
|
"subtitleCueIndex": 9
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "narrateur_poteaueleccasse",
|
"id": "narrateur_poteaueleccasse",
|
||||||
"voice": "narrateur",
|
"voice": "narrateur",
|
||||||
"audio": "/sounds/dialogue/narrateur_poteauéleccassé.mp3",
|
"audio": "/sounds/dialogue/narrateur_poteau_elec_casse.mp3",
|
||||||
"subtitleCueIndex": 10
|
"subtitleCueIndex": 10
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "narrateur_courantrepare",
|
"id": "narrateur_courantrepare",
|
||||||
"voice": "narrateur",
|
"voice": "narrateur",
|
||||||
"audio": "/sounds/dialogue/narrateur_courantréparé.mp3",
|
"audio": "/sounds/dialogue/narrateur_courant_repare.mp3",
|
||||||
"subtitleCueIndex": 11
|
"subtitleCueIndex": 11
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -163,7 +163,13 @@
|
|||||||
"id": "narrateur_histoireelectricienne",
|
"id": "narrateur_histoireelectricienne",
|
||||||
"voice": "narrateur",
|
"voice": "narrateur",
|
||||||
"audio": "/sounds/dialogue/narrateur_histoireelectricienne.mp3",
|
"audio": "/sounds/dialogue/narrateur_histoireelectricienne.mp3",
|
||||||
"subtitleCueIndex": 23
|
"subtitleCueIndices": [23, 25, 26, 27, 28]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "narrateur_demande_aide",
|
||||||
|
"voice": "narrateur",
|
||||||
|
"audio": "/sounds/dialogue/narrateur_demande_aide.mp3",
|
||||||
|
"subtitleCueIndex": 24
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "fermier_coupdemain",
|
"id": "fermier_coupdemain",
|
||||||
@@ -182,6 +188,24 @@
|
|||||||
"voice": "fermier",
|
"voice": "fermier",
|
||||||
"audio": "/sounds/dialogue/fermier_findemission.mp3",
|
"audio": "/sounds/dialogue/fermier_findemission.mp3",
|
||||||
"subtitleCueIndex": 3
|
"subtitleCueIndex": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "electricienne_welcome",
|
||||||
|
"voice": "electricienne",
|
||||||
|
"audio": "/sounds/dialogue/electricienne_welcome.mp3",
|
||||||
|
"subtitleCueIndex": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "electricienne_apresMontage",
|
||||||
|
"voice": "electricienne",
|
||||||
|
"audio": "/sounds/dialogue/electricienne_aprèsmontage.mp3",
|
||||||
|
"subtitleCueIndex": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "electricienne_aurevoir",
|
||||||
|
"voice": "electricienne",
|
||||||
|
"audio": "/sounds/dialogue/electricienne_aurevoir.mp3",
|
||||||
|
"subtitleCueIndex": 3
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,5 +87,21 @@ Welcome to your workshop!! So? Pretty impressive, right? Okay, quick tour of wha
|
|||||||
Here, this is a dashboard. You can imagine that if your fridge or oven breaks down, you won't be able to put it in the pipe haha! So here, it tells you when residents have a bulky item that broke down, or when there's a problem in the city. Uh oh... I've got an emergency, I'll have to leave you soon! So here, take your tools to repair most things: a mini 3D printer powered by electronic waste, Push-Parts gloves to disassemble objects, and a Relaunch pack!
|
Here, this is a dashboard. You can imagine that if your fridge or oven breaks down, you won't be able to put it in the pipe haha! So here, it tells you when residents have a bulky item that broke down, or when there's a problem in the city. Uh oh... I've got an emergency, I'll have to leave you soon! So here, take your tools to repair most things: a mini 3D printer powered by electronic waste, Push-Parts gloves to disassemble objects, and a Relaunch pack!
|
||||||
|
|
||||||
23
|
23
|
||||||
00:00:00,000 --> 00:00:54,000
|
00:00:00,000 --> 00:00:07,500
|
||||||
The electrician helped you at the Power Plant? Aaaaah, that's what I love here: everyone helps each other, nobody judges anyone, it's like a real little family. You should know the electrician has quite a special story. She was born in the north of the continent, in the city of Kalska. She grew up happily with her mother Edith, her father Jordan, and her two little brothers, Malo and Justin. A few years ago, as you know, the northern countries were, quite unexpectedly, the first ones forced to migrate. So they began their journey, country by country, city by city, village by village. On a day of walking like so many others after several months, a climate storm caught them off guard. Having split up to find food in the village, her father and one of her two brothers sadly disappeared. It's tragic. But one day, they happened upon this place during their journey. We welcomed them with open arms, and they were slowly able to rebuild their lives among us. Today, they are an integral part of the community.
|
The electrician helped you at the Power Plant? Aaaaah, that's what I love here: everyone helps each other, nobody judges anyone, it's like a real little family.
|
||||||
|
|
||||||
|
25
|
||||||
|
00:00:07,500 --> 00:00:19,100
|
||||||
|
You should know the electrician has quite a special story. She was born in the north of the continent, in the city of Kalska. She grew up happily with her mother Edith, her father Jordan, and her two little brothers, Malo and Justin.
|
||||||
|
|
||||||
|
26
|
||||||
|
00:00:19,100 --> 00:00:30,600
|
||||||
|
A few years ago, as you know, the northern countries were, quite unexpectedly, the first ones forced to migrate. So they began their journey, country by country, city by city, village by village.
|
||||||
|
|
||||||
|
27
|
||||||
|
00:00:30,600 --> 00:00:42,800
|
||||||
|
On a day of walking like so many others after several months, a climate storm caught them off guard. Having split up to find food in the village, her father and one of her two brothers sadly disappeared. It's tragic.
|
||||||
|
|
||||||
|
28
|
||||||
|
00:00:42,800 --> 00:00:54,000
|
||||||
|
But one day, they happened upon this place during their journey. We welcomed them with open arms, and they were slowly able to rebuild their lives among us. Today, they are an integral part of the community.
|
||||||
|
|||||||
@@ -87,5 +87,21 @@ Bienvenue dans ton atelier !! Alors ? Ça claque hein ? Bon je te présente en r
|
|||||||
Ici, c'est un tableau de bord. T'imagines bien que si ton frigo ou ton four tombe en panne, tu ne vas pas pouvoir le mettre dans le tuyau haha ! Donc ici, ça te signale quand des résidents ont un objet volumineux tombé en panne, ou quand il y a un problème dans la ville. Oh oh... j'ai une urgence, il va bientôt falloir que je te laisse ! Donc tiens, tes outils pour pouvoir réparer la plupart des choses : une mini imprimante 3D à base de déchets électroniques, des gants Pousse Pièces pour désassembler les objets, ainsi qu'un pack de Relance !
|
Ici, c'est un tableau de bord. T'imagines bien que si ton frigo ou ton four tombe en panne, tu ne vas pas pouvoir le mettre dans le tuyau haha ! Donc ici, ça te signale quand des résidents ont un objet volumineux tombé en panne, ou quand il y a un problème dans la ville. Oh oh... j'ai une urgence, il va bientôt falloir que je te laisse ! Donc tiens, tes outils pour pouvoir réparer la plupart des choses : une mini imprimante 3D à base de déchets électroniques, des gants Pousse Pièces pour désassembler les objets, ainsi qu'un pack de Relance !
|
||||||
|
|
||||||
23
|
23
|
||||||
00:00:00,000 --> 00:00:54,000
|
00:00:00,000 --> 00:00:07,500
|
||||||
L'électricienne t'a aidé à la Centrale ? Aaaaah c'est ça que j'adore ici, tout le monde s'entraide, personne se juge, une vraie petite famille. Sache que l'électricienne a une histoire assez particulière. Elle est née au nord du continent, dans la ville de Kalska. Elle a grandit heureuse, avec sa mère Edith, son père Jordan et ses deux petits frères Malo et Justin. Il y a quelques années de ça, comme tu le sais, c'est les pays du Nord, qui par grande surprise, ont été obligés de migrer en premier. Ils ont alors entamé leur périple, pays par pays, ville par ville, village par village. Un jour de marche comme les autres depuis plusieurs mois, une tempête climatique les a pris de court. S'étant séparés pour trouver des vivres dans le village, le père et un des deux frères sont malheureusement partis. C'est tragique. Mais un beau jour, ils sont tombés ici, par hasard dans leur périple. On les a accueillis les bras ouverts et ils ont pu se reconstruire doucement parmi nous et font partie intégrante de la communauté aujourd'hui.
|
L'électricienne t'a aidé à la Centrale ? Aaaaah c'est ça que j'adore ici, tout le monde s'entraide, personne se juge, une vraie petite famille.
|
||||||
|
|
||||||
|
25
|
||||||
|
00:00:07,500 --> 00:00:19,100
|
||||||
|
Sache que l'électricienne a une histoire assez particulière. Elle est née au nord du continent, dans la ville de Kalska. Elle a grandit heureuse, avec sa mère Edith, son père Jordan et ses deux petits frères Malo et Justin.
|
||||||
|
|
||||||
|
26
|
||||||
|
00:00:19,100 --> 00:00:30,600
|
||||||
|
Il y a quelques années de ça, comme tu le sais, c'est les pays du Nord, qui par grande surprise, ont été obligés de migrer en premier. Ils ont alors entamé leur périple, pays par pays, ville par ville, village par village.
|
||||||
|
|
||||||
|
27
|
||||||
|
00:00:30,600 --> 00:00:42,800
|
||||||
|
Un jour de marche comme les autres depuis plusieurs mois, une tempête climatique les a pris de court. S'étant séparés pour trouver des vivres dans le village, le père et un des deux frères sont malheureusement partis. C'est tragique.
|
||||||
|
|
||||||
|
28
|
||||||
|
00:00:42,800 --> 00:00:54,000
|
||||||
|
Mais un beau jour, ils sont tombés ici, par hasard dans leur périple. On les a accueillis les bras ouverts et ils ont pu se reconstruire doucement parmi nous et font partie intégrante de la communauté aujourd'hui.
|
||||||
|
|||||||
@@ -33,9 +33,19 @@ const _up = new THREE.Vector3(0, 1, 0);
|
|||||||
|
|
||||||
interface EbikeProps {
|
interface EbikeProps {
|
||||||
position: Vector3Tuple;
|
position: Vector3Tuple;
|
||||||
|
/**
|
||||||
|
* When true (default), the parked position is snapped to the world terrain
|
||||||
|
* height. Pass false in test scenes that don't render the world terrain so
|
||||||
|
* the bike stays at the explicit Y of {@link position} instead of floating
|
||||||
|
* at the (invisible) terrain height.
|
||||||
|
*/
|
||||||
|
snapToTerrain?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Ebike({ position }: EbikeProps): React.JSX.Element {
|
export function Ebike({
|
||||||
|
position,
|
||||||
|
snapToTerrain = true,
|
||||||
|
}: EbikeProps): React.JSX.Element {
|
||||||
const groupRef = useRef<THREE.Group>(null);
|
const groupRef = useRef<THREE.Group>(null);
|
||||||
const { scene } = useLoggedGLTF(EBIKE_MODEL_PATH, {
|
const { scene } = useLoggedGLTF(EBIKE_MODEL_PATH, {
|
||||||
scope: "Ebike",
|
scope: "Ebike",
|
||||||
@@ -45,7 +55,7 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
|
|||||||
const terrainHeight = useTerrainHeightSampler();
|
const terrainHeight = useTerrainHeightSampler();
|
||||||
const parkedPosition = useMemo<Vector3Tuple>(() => {
|
const parkedPosition = useMemo<Vector3Tuple>(() => {
|
||||||
const [x, y, z] = position;
|
const [x, y, z] = position;
|
||||||
const height = terrainHeight.getHeight(x, z) ?? y;
|
const height = snapToTerrain ? (terrainHeight.getHeight(x, z) ?? y) : y;
|
||||||
const bottomOffset = getObjectBottomOffset(model, [
|
const bottomOffset = getObjectBottomOffset(model, [
|
||||||
EBIKE_WORLD_SCALE,
|
EBIKE_WORLD_SCALE,
|
||||||
EBIKE_WORLD_SCALE,
|
EBIKE_WORLD_SCALE,
|
||||||
@@ -53,7 +63,7 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
return [x, height + bottomOffset, z];
|
return [x, height + bottomOffset, z];
|
||||||
}, [model, position, terrainHeight]);
|
}, [model, position, snapToTerrain, terrainHeight]);
|
||||||
const movementMode = useGameStore((state) => state.player.movementMode);
|
const movementMode = useGameStore((state) => state.player.movementMode);
|
||||||
const mainState = useGameStore((state) => state.mainState);
|
const mainState = useGameStore((state) => state.mainState);
|
||||||
const ebikeStep = useGameStore((state) => state.ebike.currentStep);
|
const ebikeStep = useGameStore((state) => state.ebike.currentStep);
|
||||||
@@ -119,12 +129,6 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
|
|||||||
|
|
||||||
// State for debug visualization (synced from refs during useFrame)
|
// State for debug visualization (synced from refs during useFrame)
|
||||||
const [showCameraPoints, setShowCameraPoints] = useState(true);
|
const [showCameraPoints, setShowCameraPoints] = useState(true);
|
||||||
const [debugRestingPosition, setDebugRestingPosition] =
|
|
||||||
useState<Vector3Tuple>([
|
|
||||||
parkedPosition[0],
|
|
||||||
parkedPosition[1],
|
|
||||||
parkedPosition[2],
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Keep movementModeRef in sync — useFrame closures capture React state at
|
// Keep movementModeRef in sync — useFrame closures capture React state at
|
||||||
// render time and can become stale between renders.
|
// render time and can become stale between renders.
|
||||||
@@ -135,7 +139,9 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
|
|||||||
// SpotLight target must be in the scene to define the cone direction.
|
// SpotLight target must be in the scene to define the cone direction.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
threeScene.add(headlightTarget);
|
threeScene.add(headlightTarget);
|
||||||
return () => { threeScene.remove(headlightTarget); };
|
return () => {
|
||||||
|
threeScene.remove(headlightTarget);
|
||||||
|
};
|
||||||
}, [threeScene, headlightTarget]);
|
}, [threeScene, headlightTarget]);
|
||||||
|
|
||||||
// Link the target to the SpotLight once it mounts.
|
// Link the target to the SpotLight once it mounts.
|
||||||
@@ -192,7 +198,9 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
|
|||||||
console.log("[Ebike] Fork found:", (forkNode as THREE.Object3D).name);
|
console.log("[Ebike] Fork found:", (forkNode as THREE.Object3D).name);
|
||||||
} else {
|
} else {
|
||||||
const names: string[] = [];
|
const names: string[] = [];
|
||||||
model.traverse((c) => { if (c.name) names.push(c.name); });
|
model.traverse((c) => {
|
||||||
|
if (c.name) names.push(c.name);
|
||||||
|
});
|
||||||
console.warn("[Ebike] Fork not found. All nodes:", names);
|
console.warn("[Ebike] Fork not found. All nodes:", names);
|
||||||
}
|
}
|
||||||
}, [model]);
|
}, [model]);
|
||||||
@@ -307,9 +315,7 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sync debug visualization state (throttled to avoid excessive re-renders)
|
// Sync debug visualization state (throttled to avoid excessive re-renders)
|
||||||
if (showCameraPoints) {
|
// Debug visualization positions are derived elsewhere when needed.
|
||||||
setDebugRestingPosition([...restingPositionRef.current]);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
updateEbikeSounds({ mounted: false, driving: false, breakdown: false });
|
updateEbikeSounds({ mounted: false, driving: false, breakdown: false });
|
||||||
groupRef.current.position.set(...restingPositionRef.current);
|
groupRef.current.position.set(...restingPositionRef.current);
|
||||||
@@ -326,24 +332,26 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Debug visualization positions computed from state (not refs)
|
|
||||||
const camPointPos: Vector3Tuple = [
|
|
||||||
debugRestingPosition[0] + EBIKE_CAMERA_TRANSFORM.position[0],
|
|
||||||
debugRestingPosition[1] + EBIKE_CAMERA_TRANSFORM.position[1],
|
|
||||||
debugRestingPosition[2] + EBIKE_CAMERA_TRANSFORM.position[2],
|
|
||||||
];
|
|
||||||
const dropPointPos: Vector3Tuple = [
|
|
||||||
debugRestingPosition[0] + EBIKE_DROP_PLAYER_TRANSFORM.position[0],
|
|
||||||
debugRestingPosition[1] + EBIKE_DROP_PLAYER_TRANSFORM.position[1],
|
|
||||||
debugRestingPosition[2] + EBIKE_DROP_PLAYER_TRANSFORM.position[2],
|
|
||||||
];
|
|
||||||
const interactionLabel =
|
const interactionLabel =
|
||||||
mainState === "ebike"
|
mainState === "ebike"
|
||||||
? "Réparer l'e-bike"
|
? "Lancer le repair game"
|
||||||
: movementMode === "walk"
|
: movementMode === "walk"
|
||||||
? "Monter sur le bike"
|
? "Monter sur le bike"
|
||||||
: "Descendre du bike";
|
: "Descendre du bike";
|
||||||
|
|
||||||
|
// Hide the interact prompt while the player is actively riding the bike
|
||||||
|
// (driving input pressed) so the "Descendre du bike" label doesn't
|
||||||
|
// pollute the view. The prompt comes back the moment the bike comes to
|
||||||
|
// a stop. window.ebikeDriveInputActive is published every frame by
|
||||||
|
// PlayerController based on whether a movement key is currently held.
|
||||||
|
const [isEbikeDriving, setIsEbikeDriving] = useState(false);
|
||||||
|
useFrame(() => {
|
||||||
|
const driving =
|
||||||
|
movementMode === "ebike" && window.ebikeDriveInputActive === true;
|
||||||
|
if (driving !== isEbikeDriving) setIsEbikeDriving(driving);
|
||||||
|
});
|
||||||
|
const showInteractPrompt = !isEbikeDriving;
|
||||||
|
|
||||||
const handleInteract = useCallback((): void => {
|
const handleInteract = useCallback((): void => {
|
||||||
if (window.ebikeBreakdownActive === true) return;
|
if (window.ebikeBreakdownActive === true) return;
|
||||||
|
|
||||||
@@ -382,9 +390,15 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
|
|||||||
EBIKE_CAMERA_TRANSFORM.rotation[2],
|
EBIKE_CAMERA_TRANSFORM.rotation[2],
|
||||||
];
|
];
|
||||||
|
|
||||||
animateCameraTransformTransition(targetCamPos, targetRotation, 1, () => {
|
animateCameraTransformTransition(
|
||||||
|
targetCamPos,
|
||||||
|
targetRotation,
|
||||||
|
1,
|
||||||
|
() => {
|
||||||
useGameStore.getState().setPlayerMovementMode("ebike");
|
useGameStore.getState().setPlayerMovementMode("ebike");
|
||||||
});
|
},
|
||||||
|
{ lockInput: false },
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
const currentPos = new THREE.Vector3();
|
const currentPos = new THREE.Vector3();
|
||||||
if (groupRef.current) {
|
if (groupRef.current) {
|
||||||
@@ -410,9 +424,15 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
|
|||||||
THREE.MathUtils.radToDeg(currentEuler.z),
|
THREE.MathUtils.radToDeg(currentEuler.z),
|
||||||
];
|
];
|
||||||
|
|
||||||
animateCameraTransformTransition(targetCamPos, targetRotation, 1, () => {
|
animateCameraTransformTransition(
|
||||||
|
targetCamPos,
|
||||||
|
targetRotation,
|
||||||
|
1,
|
||||||
|
() => {
|
||||||
useGameStore.getState().setPlayerMovementMode("walk");
|
useGameStore.getState().setPlayerMovementMode("walk");
|
||||||
});
|
},
|
||||||
|
{ lockInput: false },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [movementMode, mainState, ebikeStep, setMissionStep, camera, position]);
|
}, [movementMode, mainState, ebikeStep, setMissionStep, camera, position]);
|
||||||
|
|
||||||
@@ -451,6 +471,7 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
|
|||||||
{/* radius 20 → ~7 unités monde (scale 0.35).
|
{/* radius 20 → ~7 unités monde (scale 0.35).
|
||||||
Sphère omnidirectionnelle pour que le raycast fonctionne
|
Sphère omnidirectionnelle pour que le raycast fonctionne
|
||||||
quelle que soit l'orientation de la caméra (montée ou à pied). */}
|
quelle que soit l'orientation de la caméra (montée ou à pied). */}
|
||||||
|
{showInteractPrompt ? (
|
||||||
<InteractableObject
|
<InteractableObject
|
||||||
kind="trigger"
|
kind="trigger"
|
||||||
label={interactionLabel}
|
label={interactionLabel}
|
||||||
@@ -460,16 +481,26 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
|
|||||||
>
|
>
|
||||||
<mesh>
|
<mesh>
|
||||||
<sphereGeometry args={[8, 15, 12]} />
|
<sphereGeometry args={[8, 15, 12]} />
|
||||||
<meshBasicMaterial colorWrite={false} color={"red"} depthWrite={false} />
|
<meshBasicMaterial
|
||||||
|
colorWrite={false}
|
||||||
|
color={"red"}
|
||||||
|
depthWrite={false}
|
||||||
|
/>
|
||||||
</mesh>
|
</mesh>
|
||||||
</InteractableObject>
|
</InteractableObject>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{/* GPS + Speedmeter – same group so they are perfectly co-localised.
|
{/* GPS + Speedmeter – same group so they are perfectly co-localised.
|
||||||
GPS: full circle (Fresnel mask), renderOrder 10 000
|
GPS: full circle (Fresnel mask), renderOrder 10 000
|
||||||
Speedmeter: upper-half arc overlay, renderOrder 10 001
|
Speedmeter: upper-half arc overlay, renderOrder 10 001
|
||||||
rotation: Math.PI/2 radians = 90° (NOT the number 90 which = ~116.6°) */}
|
rotation: Math.PI/2 radians = 90° (NOT the number 90 which = ~116.6°) */}
|
||||||
<group position={[2, 6, 0]} rotation={[0, -80, 0]}>
|
<group position={[2, 6, 0]} rotation={[0, -80, 0]}>
|
||||||
<EbikeSpeedmeter width={3} height={1.5} position={[0, 0.4, 0]} gaugeInnerR={0.33} gaugeOuterR={0.445}
|
<EbikeSpeedmeter
|
||||||
|
width={3}
|
||||||
|
height={1.5}
|
||||||
|
position={[0, 0.4, 0]}
|
||||||
|
gaugeInnerR={0.33}
|
||||||
|
gaugeOuterR={0.445}
|
||||||
gaugeWidth={2.5}
|
gaugeWidth={2.5}
|
||||||
gaugeHeight={2.1}
|
gaugeHeight={2.1}
|
||||||
gaugeOffsetX={0}
|
gaugeOffsetX={0}
|
||||||
|
|||||||
@@ -181,6 +181,8 @@ export const EbikeGPSMap: React.FC<EbikeGPSMapProps> = ({
|
|||||||
|
|
||||||
// Sync texture into uniform when it changes (canvas resize)
|
// Sync texture into uniform when it changes (canvas resize)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// External Three.js material uniform sync — intentional side effect.
|
||||||
|
// eslint-disable-next-line react-hooks/immutability
|
||||||
shaderMat.uniforms.map.value = texture;
|
shaderMat.uniforms.map.value = texture;
|
||||||
}, [shaderMat, texture]);
|
}, [shaderMat, texture]);
|
||||||
|
|
||||||
@@ -196,6 +198,8 @@ export const EbikeGPSMap: React.FC<EbikeGPSMapProps> = ({
|
|||||||
// Resize the canvas whenever canvasSize changes (texture declared above)
|
// Resize the canvas whenever canvasSize changes (texture declared above)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Object.assign(offscreenCanvas, { width: canvasSize, height: canvasSize });
|
Object.assign(offscreenCanvas, { width: canvasSize, height: canvasSize });
|
||||||
|
// External Three.js texture invalidation — intentional side effect.
|
||||||
|
// eslint-disable-next-line react-hooks/immutability
|
||||||
texture.needsUpdate = true;
|
texture.needsUpdate = true;
|
||||||
}, [canvasSize, offscreenCanvas, texture]);
|
}, [canvasSize, offscreenCanvas, texture]);
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ export function EbikeSpeedmeter({
|
|||||||
);
|
);
|
||||||
|
|
||||||
// ── Frame loop ──────────────────────────────────────────────────────────────
|
// ── Frame loop ──────────────────────────────────────────────────────────────
|
||||||
|
/* External Three.js canvas+texture sync — intentional side effects in useFrame. */
|
||||||
|
/* eslint-disable react-hooks/immutability */
|
||||||
useFrame((_, delta) => {
|
useFrame((_, delta) => {
|
||||||
// 1. Smooth speed factor
|
// 1. Smooth speed factor
|
||||||
const target = THREE.MathUtils.clamp(window.ebikeSpeedFactor ?? 0, 0, 1);
|
const target = THREE.MathUtils.clamp(window.ebikeSpeedFactor ?? 0, 0, 1);
|
||||||
@@ -151,7 +153,7 @@ export function EbikeSpeedmeter({
|
|||||||
// Default centre: horizontal middle + needle-pivot height.
|
// Default centre: horizontal middle + needle-pivot height.
|
||||||
// gaugeOffsetX/Y shift the pivot so the arc aligns with cadran.png.
|
// gaugeOffsetX/Y shift the pivot so the arc aligns with cadran.png.
|
||||||
const cx = size * (0.5 + gaugeOffsetX);
|
const cx = size * (0.5 + gaugeOffsetX);
|
||||||
const cy = size * ((1 - NEEDLE_PIVOT_UV_Y) + gaugeOffsetY); // default ≈ 0.88 × size
|
const cy = size * (1 - NEEDLE_PIVOT_UV_Y + gaugeOffsetY); // default ≈ 0.88 × size
|
||||||
|
|
||||||
const outerR = size * gaugeOuterR;
|
const outerR = size * gaugeOuterR;
|
||||||
const innerR = size * gaugeInnerR;
|
const innerR = size * gaugeInnerR;
|
||||||
@@ -181,6 +183,7 @@ export function EbikeSpeedmeter({
|
|||||||
}
|
}
|
||||||
|
|
||||||
fillTexture.needsUpdate = true;
|
fillTexture.needsUpdate = true;
|
||||||
|
/* eslint-enable react-hooks/immutability */
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -212,11 +215,12 @@ export function EbikeSpeedmeter({
|
|||||||
</mesh>
|
</mesh>
|
||||||
|
|
||||||
{/* Needle — pivot at bottom-centre of the arc */}
|
{/* Needle — pivot at bottom-centre of the arc */}
|
||||||
<group ref={needleGroupRef} position={[0, -height * 0.38, 0.002]} rotation={[0, 0, 0]}>
|
<group
|
||||||
<mesh
|
ref={needleGroupRef}
|
||||||
position={[0, needleHeight / 2, 0]}
|
position={[0, -height * 0.38, 0.002]}
|
||||||
renderOrder={renderOrder + 1}
|
rotation={[0, 0, 0]}
|
||||||
>
|
>
|
||||||
|
<mesh position={[0, needleHeight / 2, 0]} renderOrder={renderOrder + 1}>
|
||||||
<planeGeometry args={[needleWidth, needleHeight]} />
|
<planeGeometry args={[needleWidth, needleHeight]} />
|
||||||
<meshBasicMaterial
|
<meshBasicMaterial
|
||||||
map={needleTexture}
|
map={needleTexture}
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ import { loadDialogueManifest } from "@/utils/dialogues/loadDialogueManifest";
|
|||||||
import { playDialogueById } from "@/utils/dialogues/playDialogue";
|
import { playDialogueById } from "@/utils/dialogues/playDialogue";
|
||||||
|
|
||||||
export function EbikeIntroSequence(): React.JSX.Element | null {
|
export function EbikeIntroSequence(): React.JSX.Element | null {
|
||||||
|
const mainState = useGameStore((state) => state.mainState);
|
||||||
const introStep = useGameStore((state) => state.intro.currentStep);
|
const introStep = useGameStore((state) => state.intro.currentStep);
|
||||||
const movementMode = useGameStore((state) => state.player.movementMode);
|
const movementMode = useGameStore((state) => state.player.movementMode);
|
||||||
|
const pylonStep = useGameStore((state) => state.pylon.currentStep);
|
||||||
const setIntroStep = useGameStore((state) => state.setIntroStep);
|
const setIntroStep = useGameStore((state) => state.setIntroStep);
|
||||||
const completeIntro = useGameStore((state) => state.completeIntro);
|
const completeIntro = useGameStore((state) => state.completeIntro);
|
||||||
const [breakdownDialogueDone, setBreakdownDialogueDone] = useState(false);
|
const [breakdownDialogueDone, setBreakdownDialogueDone] = useState(false);
|
||||||
@@ -134,6 +136,26 @@ export function EbikeIntroSequence(): React.JSX.Element | null {
|
|||||||
}
|
}
|
||||||
}, [introStep]);
|
}, [introStep]);
|
||||||
|
|
||||||
|
if (mainState === "pylon") {
|
||||||
|
if (pylonStep === "approaching") {
|
||||||
|
return <MissionNotification mission="pylon" visible />;
|
||||||
|
}
|
||||||
|
if (pylonStep === "narrator-outro") {
|
||||||
|
return <MissionNotification mission="farm" visible />;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mainState == "pylon") {
|
||||||
|
if (pylonStep === "approaching") {
|
||||||
|
return <MissionNotification mission="pylon" visible />;
|
||||||
|
}
|
||||||
|
if (pylonStep === "narrator-outro") {
|
||||||
|
return <MissionNotification mission="farm" visible />;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
introStep !== "reveal" &&
|
introStep !== "reveal" &&
|
||||||
introStep !== "await-ebike-mount" &&
|
introStep !== "await-ebike-mount" &&
|
||||||
|
|||||||
@@ -0,0 +1,165 @@
|
|||||||
|
import { useEffect, useRef } from "react";
|
||||||
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
|
import { useSubtitleStore } from "@/managers/stores/useSubtitleStore";
|
||||||
|
import { AudioManager } from "@/managers/AudioManager";
|
||||||
|
|
||||||
|
const HISTOIRE_AUDIO_PATH = "/sounds/dialogue/narrateur_histoireelectricienne.mp3";
|
||||||
|
const OUTRO_DELAY_MS = 5_000; // delay after audio ends before transitioning to outro
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text blocks for the electricienne history narration (max 5 lines each).
|
||||||
|
* Displayed sequentially — timings are calculated dynamically from the actual
|
||||||
|
* audio duration so they are always correct regardless of the mp3 length.
|
||||||
|
*/
|
||||||
|
const HISTOIRE_BLOCKS = [
|
||||||
|
"L'électricienne t'a aidé à la Centrale ? Aaaaah c'est ça que j'adore ici, tout le monde s'entraide, personne se juge, une vraie petite famille.",
|
||||||
|
"Sache que l'électricienne a une histoire assez particulière. Elle est née au nord du continent, dans la ville de Kalska. Elle a grandit heureuse, avec sa mère Edith, son père Jordan et ses deux petits frères Malo et Justin.",
|
||||||
|
"Il y a quelques années de ça, comme tu le sais, c'est les pays du Nord, qui par grande surprise, ont été obligés de migrer en premier. Ils ont alors entamé leur périple, pays par pays, ville par ville, village par village.",
|
||||||
|
"Un jour de marche comme les autres depuis plusieurs mois, une tempête climatique les a pris de court. S'étant séparés pour trouver des vivres dans le village, le père et un des deux frères sont malheureusement partis. C'est tragique.",
|
||||||
|
"Mais un beau jour, ils sont tombés ici, par hasard dans leur périple. On les a accueillis les bras ouverts et ils ont pu se reconstruire doucement parmi nous et font partie intégrante de la communauté aujourd'hui.",
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
const TOTAL_CHARS = HISTOIRE_BLOCKS.reduce((sum, b) => sum + b.length, 0);
|
||||||
|
|
||||||
|
/** Compute start/end times for each block based on actual audio duration. */
|
||||||
|
function buildBlockTimings(
|
||||||
|
duration: number,
|
||||||
|
): Array<{ start: number; end: number }> {
|
||||||
|
let t = 0;
|
||||||
|
return HISTOIRE_BLOCKS.map((block) => {
|
||||||
|
const blockDuration = (block.length / TOTAL_CHARS) * duration;
|
||||||
|
const start = t;
|
||||||
|
t += blockDuration;
|
||||||
|
return { start, end: t };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play the histoire audio and keep `useSubtitleStore` in sync with
|
||||||
|
* dynamically-computed block boundaries.
|
||||||
|
* Movement is intentionally NOT blocked so the player can explore while
|
||||||
|
* listening to the narration.
|
||||||
|
* `onAudioEnded` fires once when the audio element emits "ended".
|
||||||
|
*/
|
||||||
|
function useHistoireSubtitlePlayback(
|
||||||
|
enabled: boolean,
|
||||||
|
onAudioEnded?: () => void,
|
||||||
|
): void {
|
||||||
|
// Keep callback in a ref so the effect doesn't need it as a dependency.
|
||||||
|
const onAudioEndedRef = useRef(onAudioEnded);
|
||||||
|
useEffect(() => {
|
||||||
|
onAudioEndedRef.current = onAudioEnded;
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!enabled) return undefined;
|
||||||
|
|
||||||
|
let isCancelled = false;
|
||||||
|
|
||||||
|
const audio = AudioManager.getInstance().playSound(HISTOIRE_AUDIO_PATH, 1, {
|
||||||
|
category: "dialogue",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!audio) return undefined;
|
||||||
|
|
||||||
|
const { setActiveSubtitle, clearActiveSubtitle } =
|
||||||
|
useSubtitleStore.getState();
|
||||||
|
|
||||||
|
/** Wire up block-level subtitle sync once we know the audio duration. */
|
||||||
|
function startSync(): void {
|
||||||
|
const duration = audio.duration;
|
||||||
|
if (!duration || isNaN(duration) || isCancelled) return;
|
||||||
|
|
||||||
|
const timings = buildBlockTimings(duration);
|
||||||
|
|
||||||
|
function onTimeUpdate(): void {
|
||||||
|
const t = audio.currentTime;
|
||||||
|
const idx = timings.findIndex(
|
||||||
|
({ start, end }) => t >= start && t < end,
|
||||||
|
);
|
||||||
|
if (idx >= 0) {
|
||||||
|
setActiveSubtitle({
|
||||||
|
speaker: "Narrateur",
|
||||||
|
text: HISTOIRE_BLOCKS[idx],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onEnded(): void {
|
||||||
|
clearActiveSubtitle();
|
||||||
|
onAudioEndedRef.current?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
audio.addEventListener("timeupdate", onTimeUpdate);
|
||||||
|
audio.addEventListener("ended", onEnded, { once: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// If duration is already known (cached audio), start immediately.
|
||||||
|
if (audio.duration && !isNaN(audio.duration)) {
|
||||||
|
startSync();
|
||||||
|
} else {
|
||||||
|
audio.addEventListener("loadedmetadata", startSync, { once: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
isCancelled = true;
|
||||||
|
audio.pause();
|
||||||
|
useSubtitleStore.getState().clearActiveSubtitle();
|
||||||
|
};
|
||||||
|
}, [enabled]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the farm mission narrative intro:
|
||||||
|
* locked → (auto) → electricienne_history → plays audio with block subtitles
|
||||||
|
* → 5 s after audio ends → completeMission("farm") → outro
|
||||||
|
*/
|
||||||
|
export function FarmNarrativeFlow(): null {
|
||||||
|
const mainState = useGameStore((state) => state.mainState);
|
||||||
|
const step = useGameStore((state) => state.farm.currentStep);
|
||||||
|
const setMissionStep = useGameStore((state) => state.setMissionStep);
|
||||||
|
const completeMission = useGameStore((state) => state.completeMission);
|
||||||
|
|
||||||
|
// locked is purely a gate — transition immediately to electricienne_history.
|
||||||
|
useEffect(() => {
|
||||||
|
if (mainState !== "farm" || step !== "locked") return;
|
||||||
|
setMissionStep("farm", "electricienne_history");
|
||||||
|
}, [mainState, step, setMissionStep]);
|
||||||
|
|
||||||
|
// Ensure movement is always allowed during the electricienne_history narration,
|
||||||
|
// regardless of what the previous step may have blocked.
|
||||||
|
const setCanMove = useGameStore((state) => state.setCanMove);
|
||||||
|
useEffect(() => {
|
||||||
|
if (mainState !== "farm" || step !== "electricienne_history") return;
|
||||||
|
setCanMove(true);
|
||||||
|
}, [mainState, step, setCanMove]);
|
||||||
|
|
||||||
|
// After the audio finishes, wait 5 s then transition to outro.
|
||||||
|
// The timeout ID is kept in a ref so we can cancel on unmount.
|
||||||
|
const outroTimeoutRef = useRef<ReturnType<typeof window.setTimeout> | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (outroTimeoutRef.current !== null) {
|
||||||
|
window.clearTimeout(outroTimeoutRef.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleAudioEnded = (): void => {
|
||||||
|
if (outroTimeoutRef.current !== null) {
|
||||||
|
window.clearTimeout(outroTimeoutRef.current);
|
||||||
|
}
|
||||||
|
outroTimeoutRef.current = window.setTimeout(() => {
|
||||||
|
outroTimeoutRef.current = null;
|
||||||
|
completeMission("farm");
|
||||||
|
}, OUTRO_DELAY_MS);
|
||||||
|
};
|
||||||
|
|
||||||
|
useHistoireSubtitlePlayback(
|
||||||
|
mainState === "farm" && step === "electricienne_history",
|
||||||
|
handleAudioEnded,
|
||||||
|
);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import { useFrame } from "@react-three/fiber";
|
||||||
|
import { useGLTF } from "@react-three/drei";
|
||||||
|
import * as THREE from "three";
|
||||||
|
import { InteractableObject } from "@/components/three/interaction/InteractableObject";
|
||||||
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
|
import { useRepairMissionAnchorStore } from "@/managers/stores/useRepairMissionAnchorStore";
|
||||||
|
import { useTerrainSnappedPosition } from "@/hooks/three/useTerrainHeight";
|
||||||
|
import { loadDialogueManifest } from "@/utils/dialogues/loadDialogueManifest";
|
||||||
|
import { playDialogueById } from "@/utils/dialogues/playDialogue";
|
||||||
|
import {
|
||||||
|
PYLON_DOWNED_ROTATION,
|
||||||
|
PYLON_NARRATIVE_INTERACT_RADIUS,
|
||||||
|
PYLON_NARRATIVE_DIALOGUES,
|
||||||
|
PYLON_STRAIGHTEN_ANIMATION_DURATION_MS,
|
||||||
|
PYLON_UPRIGHT_ROTATION,
|
||||||
|
PYLON_WORLD_POSITION,
|
||||||
|
} from "@/data/gameplay/pylonConfig";
|
||||||
|
import { isRepairGameStep } from "@/types/gameplay/repairMission";
|
||||||
|
import { pylonStraighteningSignal } from "@/components/gameplay/pylon/pylonSignals";
|
||||||
|
|
||||||
|
const PYLON_MODEL_PATH = "/models/pylone/model.glb";
|
||||||
|
|
||||||
|
export function PylonDownedPylon(): React.JSX.Element | null {
|
||||||
|
const mainState = useGameStore((state) => state.mainState);
|
||||||
|
const step = useGameStore((state) => state.pylon.currentStep);
|
||||||
|
const setCanMove = useGameStore((state) => state.setCanMove);
|
||||||
|
// Use the repair:pylon anchor from the store so the downed pylon is always
|
||||||
|
// co-located with the instanced mesh it replaces. Falls back to the
|
||||||
|
// hard-coded constant while the map is loading or unavailable.
|
||||||
|
const pylonAnchor = useRepairMissionAnchorStore(
|
||||||
|
(state) => state.anchors.pylon,
|
||||||
|
);
|
||||||
|
// Snap to terrain so the downed/upright model sits flush on the ground,
|
||||||
|
// matching the Y adjustment that InstancedMapAsset applies to the same node.
|
||||||
|
const position = useTerrainSnappedPosition(pylonAnchor ?? PYLON_WORLD_POSITION);
|
||||||
|
const [isStraightening, setIsStraightening] = useState(false);
|
||||||
|
// Keeps the pylon upright after the animation completes while
|
||||||
|
// PylonFarmerNPC plays the post-raise audio sequence.
|
||||||
|
const [isRaised, setIsRaised] = useState(false);
|
||||||
|
const groupRef = useRef<THREE.Group>(null);
|
||||||
|
const straightenStartRef = useRef<number | null>(null);
|
||||||
|
const hasPlayedFirstAudioRef = useRef(false);
|
||||||
|
|
||||||
|
// Hidden outside the pylon mission and once the pylon has been raised
|
||||||
|
// (repair-game steps take over from there).
|
||||||
|
const shouldRender = mainState === "pylon" && !isRepairGameStep(step);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (step === "arrived") {
|
||||||
|
hasPlayedFirstAudioRef.current = false;
|
||||||
|
// Reset the "raised" latch when a new run begins. This is derived
|
||||||
|
// resync from the step prop and runs once per step transition.
|
||||||
|
// eslint-disable-next-line react-hooks/set-state-in-effect
|
||||||
|
setIsRaised(false);
|
||||||
|
}
|
||||||
|
}, [step]);
|
||||||
|
|
||||||
|
const { scene } = useGLTF(PYLON_MODEL_PATH);
|
||||||
|
|
||||||
|
useFrame(() => {
|
||||||
|
const group = groupRef.current;
|
||||||
|
if (!group) return;
|
||||||
|
|
||||||
|
if (!isStraightening || straightenStartRef.current === null) {
|
||||||
|
group.rotation.set(...(isRaised ? PYLON_UPRIGHT_ROTATION : PYLON_DOWNED_ROTATION));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const elapsed = performance.now() - straightenStartRef.current;
|
||||||
|
const t = Math.min(elapsed / PYLON_STRAIGHTEN_ANIMATION_DURATION_MS, 1);
|
||||||
|
const eased = 1 - Math.pow(1 - t, 3);
|
||||||
|
const startEuler = new THREE.Euler(...PYLON_DOWNED_ROTATION);
|
||||||
|
|
||||||
|
group.rotation.set(
|
||||||
|
THREE.MathUtils.lerp(startEuler.x, 0, eased),
|
||||||
|
startEuler.y,
|
||||||
|
THREE.MathUtils.lerp(startEuler.z, 0, eased),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const isPylonInteractive = step === "arrived" || step === "npc-return";
|
||||||
|
|
||||||
|
const beginStraighten = (): void => {
|
||||||
|
setIsStraightening(true);
|
||||||
|
pylonStraighteningSignal.started = true;
|
||||||
|
pylonStraighteningSignal.completed = false;
|
||||||
|
straightenStartRef.current = performance.now();
|
||||||
|
setCanMove(false);
|
||||||
|
if (groupRef.current) {
|
||||||
|
groupRef.current.rotation.set(...PYLON_DOWNED_ROTATION);
|
||||||
|
}
|
||||||
|
window.setTimeout(() => {
|
||||||
|
setIsStraightening(false);
|
||||||
|
pylonStraighteningSignal.started = false;
|
||||||
|
// Keep pylon upright while PylonFarmerNPC plays the audio sequence.
|
||||||
|
// PylonFarmerNPC will call setMissionStep("pylon", "inspected") once done.
|
||||||
|
setIsRaised(true);
|
||||||
|
setCanMove(true);
|
||||||
|
pylonStraighteningSignal.completed = true;
|
||||||
|
}, PYLON_STRAIGHTEN_ANIMATION_DURATION_MS);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!shouldRender) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<group
|
||||||
|
ref={groupRef}
|
||||||
|
position={position}
|
||||||
|
rotation={PYLON_DOWNED_ROTATION}
|
||||||
|
>
|
||||||
|
<primitive object={scene.clone(true)} />
|
||||||
|
{isPylonInteractive ? (
|
||||||
|
<InteractableObject
|
||||||
|
kind="trigger"
|
||||||
|
label={
|
||||||
|
step === "arrived" ? "Inspecter le pylône" : "Redresser le pylône"
|
||||||
|
}
|
||||||
|
position={position}
|
||||||
|
radius={PYLON_NARRATIVE_INTERACT_RADIUS}
|
||||||
|
onPress={() => {
|
||||||
|
if (step === "arrived") {
|
||||||
|
if (!hasPlayedFirstAudioRef.current) {
|
||||||
|
hasPlayedFirstAudioRef.current = true;
|
||||||
|
void (async () => {
|
||||||
|
const manifest = await loadDialogueManifest();
|
||||||
|
if (!manifest) return;
|
||||||
|
const audio = await playDialogueById(
|
||||||
|
manifest,
|
||||||
|
PYLON_NARRATIVE_DIALOGUES.brokenPylon,
|
||||||
|
);
|
||||||
|
if (!audio) return;
|
||||||
|
audio.addEventListener(
|
||||||
|
"ended",
|
||||||
|
() => {
|
||||||
|
void (async () => {
|
||||||
|
const m = await loadDialogueManifest();
|
||||||
|
if (!m) return;
|
||||||
|
await playDialogueById(
|
||||||
|
m,
|
||||||
|
PYLON_NARRATIVE_DIALOGUES.demandeAide,
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
},
|
||||||
|
{ once: true },
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
} else {
|
||||||
|
void (async () => {
|
||||||
|
const manifest = await loadDialogueManifest();
|
||||||
|
if (!manifest) return;
|
||||||
|
await playDialogueById(
|
||||||
|
manifest,
|
||||||
|
PYLON_NARRATIVE_DIALOGUES.demandeAide,
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
} else if (step === "npc-return" && !isStraightening) {
|
||||||
|
beginStraighten();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<mesh>
|
||||||
|
<sphereGeometry args={[1, 8, 8]} />
|
||||||
|
<meshBasicMaterial transparent opacity={0} depthWrite={false} />
|
||||||
|
</mesh>
|
||||||
|
</InteractableObject>
|
||||||
|
) : null}
|
||||||
|
</group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
useGLTF.preload(PYLON_MODEL_PATH);
|
||||||
@@ -0,0 +1,294 @@
|
|||||||
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
||||||
|
import * as THREE from "three";
|
||||||
|
import { useFrame, useThree } from "@react-three/fiber";
|
||||||
|
import { useAnimations } from "@react-three/drei";
|
||||||
|
import { useGLTF } from "@react-three/drei";
|
||||||
|
import { SkeletonUtils } from "three-stdlib";
|
||||||
|
import { InteractableObject } from "@/components/three/interaction/InteractableObject";
|
||||||
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
|
import { loadDialogueManifest } from "@/utils/dialogues/loadDialogueManifest";
|
||||||
|
import { playDialogueById } from "@/utils/dialogues/playDialogue";
|
||||||
|
import { useLoggedGLTF } from "@/hooks/three/useLoggedGLTF";
|
||||||
|
import {
|
||||||
|
PYLON_FARMER_NPC_AFTER_POSITION,
|
||||||
|
PYLON_FARMER_NPC_AFTER_POSITION_pylone_straight,
|
||||||
|
PYLON_FARMER_NPC_AFTER_SCALE,
|
||||||
|
PYLON_FARMER_NPC_POSITION,
|
||||||
|
PYLON_FARMER_NPC_WALK_LOOK_AT,
|
||||||
|
PYLON_FARMER_NPC_WALK_SPEED,
|
||||||
|
PYLON_NARRATIVE_DIALOGUES,
|
||||||
|
PYLON_NARRATIVE_INTERACT_RADIUS,
|
||||||
|
PYLON_WORLD_POSITION,
|
||||||
|
} from "@/data/gameplay/pylonConfig";
|
||||||
|
import { pylonStraighteningSignal } from "@/components/gameplay/pylon/pylonSignals";
|
||||||
|
|
||||||
|
const ELECTRICIENNE_MODEL_PATH = "/models/electricienne-animated/model.gltf";
|
||||||
|
const ANIM_FADE = 0.3;
|
||||||
|
const ARRIVE_THRESHOLD = 0.12;
|
||||||
|
|
||||||
|
type NPCAnimation = "idle" | "walk" | "push";
|
||||||
|
|
||||||
|
const _target = new THREE.Vector3();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute the Y rotation (radians) for a model whose default forward
|
||||||
|
* direction is +Z, so that it faces from `from` toward `to`.
|
||||||
|
*/
|
||||||
|
function faceToward(
|
||||||
|
from: THREE.Vector3,
|
||||||
|
to: readonly [number, number, number],
|
||||||
|
): number {
|
||||||
|
const dx = to[0] - from.x;
|
||||||
|
const dz = to[2] - from.z;
|
||||||
|
return Math.atan2(dx, dz);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outer shell — only checks visibility conditions.
|
||||||
|
* Rendering is delegated to PylonFarmerNPCContent so that the heavy hooks
|
||||||
|
* (useFrame, useAnimations) are only active while the NPC is actually shown.
|
||||||
|
*/
|
||||||
|
export function PylonFarmerNPC(): React.JSX.Element | null {
|
||||||
|
const mainState = useGameStore((state) => state.mainState);
|
||||||
|
const step = useGameStore((state) => state.pylon.currentStep);
|
||||||
|
|
||||||
|
if (mainState !== "pylon") return null;
|
||||||
|
// Visible during narrative + at repair completion (hides during repair steps)
|
||||||
|
if (
|
||||||
|
step !== "arrived" &&
|
||||||
|
step !== "npc-return" &&
|
||||||
|
step !== "inspected" &&
|
||||||
|
step !== "done"
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <PylonFarmerNPCContent />;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Inner component — heavy hooks only run when NPC is mounted ──────────────
|
||||||
|
function PylonFarmerNPCContent(): React.JSX.Element {
|
||||||
|
const step = useGameStore((state) => state.pylon.currentStep);
|
||||||
|
const setMissionStep = useGameStore((state) => state.setMissionStep);
|
||||||
|
const camera = useThree((state) => state.camera);
|
||||||
|
|
||||||
|
const groupRef = useRef<THREE.Group>(null);
|
||||||
|
const currentPosRef = useRef(new THREE.Vector3(...PYLON_FARMER_NPC_POSITION));
|
||||||
|
|
||||||
|
// Animation state guard — null forces playAnim to always trigger
|
||||||
|
const currentAnimRef = useRef<NPCAnimation | null>(null);
|
||||||
|
|
||||||
|
// Signal edge tracking
|
||||||
|
const wasStraighteningRef = useRef(false);
|
||||||
|
const wasCompletedRef = useRef(false);
|
||||||
|
|
||||||
|
// Saved Y rotation used whenever the NPC is stationary
|
||||||
|
const savedRotationYRef = useRef<number>(0);
|
||||||
|
|
||||||
|
const { scene, animations } = useLoggedGLTF(ELECTRICIENNE_MODEL_PATH, {
|
||||||
|
scope: "PylonFarmerNPC",
|
||||||
|
});
|
||||||
|
const model = useMemo(() => SkeletonUtils.clone(scene), [scene]);
|
||||||
|
|
||||||
|
// actions is in deps of playAnim: when useAnimations populates it (async useState
|
||||||
|
// inside drei), playAnim recreates → useEffect([step, playAnim]) re-fires → animation plays.
|
||||||
|
const { actions } = useAnimations(animations, model);
|
||||||
|
|
||||||
|
// ─── playAnim ─────────────────────────────────────────────────────────────
|
||||||
|
// NOTE: actions is intentionally in the dep array so this callback is
|
||||||
|
// recreated when drei's internal state populates the actions map.
|
||||||
|
// External THREE.AnimationAction lifecycle methods (fadeOut/fadeIn/play +
|
||||||
|
// setLoop/clampWhenFinished mutations) are intentional side effects on
|
||||||
|
// drei-managed objects.
|
||||||
|
/* eslint-disable react-hooks/immutability */
|
||||||
|
const playAnim = useCallback(
|
||||||
|
(name: NPCAnimation, fade = ANIM_FADE): void => {
|
||||||
|
if (currentAnimRef.current === name) return;
|
||||||
|
currentAnimRef.current = name;
|
||||||
|
|
||||||
|
Object.values(actions).forEach((a) => a?.fadeOut(fade));
|
||||||
|
|
||||||
|
const action = actions[name];
|
||||||
|
if (!action) return;
|
||||||
|
|
||||||
|
if (name === "push") {
|
||||||
|
action.setLoop(THREE.LoopOnce, 1);
|
||||||
|
action.clampWhenFinished = true;
|
||||||
|
}
|
||||||
|
action.reset().fadeIn(fade).play();
|
||||||
|
},
|
||||||
|
[actions],
|
||||||
|
);
|
||||||
|
/* eslint-enable react-hooks/immutability */
|
||||||
|
|
||||||
|
// ─── Async audio after pylon is raised ────────────────────────────────────
|
||||||
|
const playPostRaiseAudioAndAdvance = useCallback(async () => {
|
||||||
|
const manifest = await loadDialogueManifest();
|
||||||
|
if (manifest) {
|
||||||
|
const audio = await playDialogueById(
|
||||||
|
manifest,
|
||||||
|
PYLON_NARRATIVE_DIALOGUES.electricienneApresMontage,
|
||||||
|
);
|
||||||
|
if (audio) {
|
||||||
|
await new Promise<void>((resolve) => {
|
||||||
|
audio.addEventListener("ended", () => resolve(), { once: true });
|
||||||
|
audio.addEventListener("error", () => resolve(), { once: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pylonStraighteningSignal.completed = false;
|
||||||
|
setMissionStep("pylon", "inspected");
|
||||||
|
}, [setMissionStep]);
|
||||||
|
|
||||||
|
// ─── Step-driven animation ────────────────────────────────────────────────
|
||||||
|
// Fires when step changes OR when playAnim changes (i.e. when actions load).
|
||||||
|
// playAnim mutates drei-managed AnimationAction internals (intentional).
|
||||||
|
/* eslint-disable react-hooks/immutability */
|
||||||
|
useEffect(() => {
|
||||||
|
currentAnimRef.current = null;
|
||||||
|
if (step === "arrived") {
|
||||||
|
currentPosRef.current.set(...PYLON_FARMER_NPC_POSITION);
|
||||||
|
wasStraighteningRef.current = false;
|
||||||
|
wasCompletedRef.current = false;
|
||||||
|
savedRotationYRef.current = 0;
|
||||||
|
playAnim("idle");
|
||||||
|
} else if (step === "npc-return") {
|
||||||
|
playAnim("walk");
|
||||||
|
} else if (step === "inspected") {
|
||||||
|
playAnim("idle");
|
||||||
|
} else if (step === "done") {
|
||||||
|
// NPC reappears at repair completion — position at the post-raise spot,
|
||||||
|
// facing the pylon, playing idle.
|
||||||
|
currentPosRef.current.set(...PYLON_FARMER_NPC_AFTER_POSITION_pylone_straight);
|
||||||
|
savedRotationYRef.current = faceToward(
|
||||||
|
currentPosRef.current,
|
||||||
|
PYLON_WORLD_POSITION,
|
||||||
|
);
|
||||||
|
playAnim("idle");
|
||||||
|
}
|
||||||
|
}, [step, playAnim]);
|
||||||
|
|
||||||
|
// ─── Per-frame: movement + rotation + signal detection ───────────────────
|
||||||
|
useFrame((_, delta) => {
|
||||||
|
const group = groupRef.current;
|
||||||
|
if (!group) return;
|
||||||
|
|
||||||
|
const isStraightening = pylonStraighteningSignal.started;
|
||||||
|
const isCompleted = pylonStraighteningSignal.completed;
|
||||||
|
|
||||||
|
// Rising edge: pylon straightening starts → push
|
||||||
|
if (isStraightening && !wasStraighteningRef.current) {
|
||||||
|
wasStraighteningRef.current = true;
|
||||||
|
currentAnimRef.current = null;
|
||||||
|
playAnim("push");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rising edge: straightening completed → idle + face player + audio
|
||||||
|
if (isCompleted && !wasCompletedRef.current) {
|
||||||
|
wasCompletedRef.current = true;
|
||||||
|
currentAnimRef.current = null;
|
||||||
|
playAnim("idle");
|
||||||
|
savedRotationYRef.current = faceToward(currentPosRef.current, [
|
||||||
|
camera.position.x,
|
||||||
|
camera.position.y,
|
||||||
|
camera.position.z,
|
||||||
|
]);
|
||||||
|
void playPostRaiseAudioAndAdvance();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Position ──────────────────────────────────────────────────────────
|
||||||
|
if (step === "npc-return" && !isCompleted) {
|
||||||
|
const targetPos = isStraightening
|
||||||
|
? PYLON_FARMER_NPC_AFTER_POSITION_pylone_straight
|
||||||
|
: PYLON_FARMER_NPC_AFTER_POSITION;
|
||||||
|
_target.set(...targetPos);
|
||||||
|
|
||||||
|
const dist = currentPosRef.current.distanceTo(_target);
|
||||||
|
if (dist > ARRIVE_THRESHOLD) {
|
||||||
|
const t = Math.min((PYLON_FARMER_NPC_WALK_SPEED * delta) / dist, 1);
|
||||||
|
currentPosRef.current.lerp(_target, t);
|
||||||
|
} else if (!isStraightening && currentAnimRef.current === "walk") {
|
||||||
|
playAnim("idle");
|
||||||
|
savedRotationYRef.current = faceToward(
|
||||||
|
currentPosRef.current,
|
||||||
|
PYLON_WORLD_POSITION,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
group.position.copy(currentPosRef.current);
|
||||||
|
} else if (step === "inspected" || step === "done") {
|
||||||
|
group.position.set(...PYLON_FARMER_NPC_AFTER_POSITION_pylone_straight);
|
||||||
|
} else if (isCompleted) {
|
||||||
|
group.position.copy(currentPosRef.current);
|
||||||
|
} else {
|
||||||
|
group.position.set(...PYLON_FARMER_NPC_POSITION);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Rotation ──────────────────────────────────────────────────────────
|
||||||
|
if (
|
||||||
|
step === "npc-return" &&
|
||||||
|
!isCompleted &&
|
||||||
|
currentAnimRef.current === "walk"
|
||||||
|
) {
|
||||||
|
const walkRotY = faceToward(
|
||||||
|
currentPosRef.current,
|
||||||
|
PYLON_FARMER_NPC_WALK_LOOK_AT,
|
||||||
|
);
|
||||||
|
group.rotation.set(0, walkRotY, 0);
|
||||||
|
} else {
|
||||||
|
group.rotation.set(0, savedRotationYRef.current, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
group.scale.setScalar(PYLON_FARMER_NPC_AFTER_SCALE);
|
||||||
|
});
|
||||||
|
/* eslint-enable react-hooks/immutability */
|
||||||
|
|
||||||
|
return (
|
||||||
|
<group ref={groupRef} position={PYLON_FARMER_NPC_POSITION}>
|
||||||
|
<primitive object={model} />
|
||||||
|
{step === "arrived" ? (
|
||||||
|
<InteractableObject
|
||||||
|
kind="trigger"
|
||||||
|
label="Parler à l'électricienne"
|
||||||
|
position={PYLON_FARMER_NPC_POSITION}
|
||||||
|
radius={PYLON_NARRATIVE_INTERACT_RADIUS}
|
||||||
|
onPress={() => {
|
||||||
|
// Turn to face the player the moment they engage the NPC
|
||||||
|
savedRotationYRef.current = faceToward(currentPosRef.current, [
|
||||||
|
camera.position.x,
|
||||||
|
camera.position.y,
|
||||||
|
camera.position.z,
|
||||||
|
]);
|
||||||
|
|
||||||
|
void (async () => {
|
||||||
|
const manifest = await loadDialogueManifest();
|
||||||
|
if (!manifest) {
|
||||||
|
setMissionStep("pylon", "npc-return");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const audio = await playDialogueById(
|
||||||
|
manifest,
|
||||||
|
PYLON_NARRATIVE_DIALOGUES.electricienneWelcome,
|
||||||
|
);
|
||||||
|
if (!audio) {
|
||||||
|
setMissionStep("pylon", "npc-return");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
audio.addEventListener(
|
||||||
|
"ended",
|
||||||
|
() => setMissionStep("pylon", "npc-return"),
|
||||||
|
{ once: true },
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<mesh>
|
||||||
|
<sphereGeometry args={[1, 8, 8]} />
|
||||||
|
<meshBasicMaterial transparent opacity={0} depthWrite={false} />
|
||||||
|
</mesh>
|
||||||
|
</InteractableObject>
|
||||||
|
) : null}
|
||||||
|
</group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
useGLTF.preload(ELECTRICIENNE_MODEL_PATH);
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { useEffect, useRef } from "react";
|
||||||
|
import * as THREE from "three";
|
||||||
|
import { useFrame } from "@react-three/fiber";
|
||||||
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
|
import { LIGHTING_STATE } from "@/world/lightingState";
|
||||||
|
import { LIGHTING_DEFAULTS } from "@/data/world/lightingConfig";
|
||||||
|
|
||||||
|
// ─── Pylon atmosphere colours ─────────────────────────────────────────────────
|
||||||
|
// Applied from "approaching" until the pylon mission ends.
|
||||||
|
const PYLON_AMBIENT_COLOR = "#7b87c8"; // blue-violet
|
||||||
|
const PYLON_SUN_COLOR = "#a882d4"; // lavender-purple
|
||||||
|
|
||||||
|
// Lerp speed (1 = full transition in ~1 s at 60 fps)
|
||||||
|
const TRANSITION_SPEED = 0.8;
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
export function PylonLightingEffect(): null {
|
||||||
|
const mainState = useGameStore((state) => state.mainState);
|
||||||
|
const step = useGameStore((state) => state.pylon.currentStep);
|
||||||
|
|
||||||
|
// True from "approaching" until done — lighting starts reverting as soon as
|
||||||
|
// the repair is complete (powerup sfx plays at "done", outro dialogue at "narrator-outro").
|
||||||
|
const isActive =
|
||||||
|
mainState === "pylon" &&
|
||||||
|
step !== "locked" &&
|
||||||
|
step !== "done" &&
|
||||||
|
step !== "narrator-outro";
|
||||||
|
|
||||||
|
// Working THREE.Color instances — lerped every frame
|
||||||
|
const ambientRef = useRef(new THREE.Color(LIGHTING_STATE.ambientColor));
|
||||||
|
const sunRef = useRef(new THREE.Color(LIGHTING_STATE.sunColor));
|
||||||
|
|
||||||
|
// Target colours — updated reactively when isActive changes
|
||||||
|
const targetAmbientRef = useRef(
|
||||||
|
new THREE.Color(LIGHTING_DEFAULTS.ambientColor),
|
||||||
|
);
|
||||||
|
const targetSunRef = useRef(new THREE.Color(LIGHTING_DEFAULTS.sunColor));
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isActive) {
|
||||||
|
targetAmbientRef.current.set(PYLON_AMBIENT_COLOR);
|
||||||
|
targetSunRef.current.set(PYLON_SUN_COLOR);
|
||||||
|
} else {
|
||||||
|
targetAmbientRef.current.set(LIGHTING_DEFAULTS.ambientColor);
|
||||||
|
targetSunRef.current.set(LIGHTING_DEFAULTS.sunColor);
|
||||||
|
}
|
||||||
|
}, [isActive]);
|
||||||
|
|
||||||
|
useFrame((_, delta) => {
|
||||||
|
const t = Math.min(TRANSITION_SPEED * delta, 1);
|
||||||
|
|
||||||
|
ambientRef.current.lerp(targetAmbientRef.current, t);
|
||||||
|
sunRef.current.lerp(targetSunRef.current, t);
|
||||||
|
|
||||||
|
LIGHTING_STATE.ambientColor = `#${ambientRef.current.getHexString()}`;
|
||||||
|
LIGHTING_STATE.sunColor = `#${sunRef.current.getHexString()}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
|
import { useDialoguePlayback } from "@/hooks/gameplay/useDialoguePlayback";
|
||||||
|
import { ZoneDetection } from "@/components/zone/ZoneDetection";
|
||||||
|
import { PylonFarmerNPC } from "@/components/gameplay/pylon/PylonFarmerNPC";
|
||||||
|
import { PylonNarratorOutro } from "@/components/gameplay/pylon/PylonNarratorOutro";
|
||||||
|
import { PYLON_APPROACH_ZONE, PYLON_ARRIVED_ZONE } from "@/data/gameplay/zones";
|
||||||
|
import { PYLON_NARRATIVE_DIALOGUES } from "@/data/gameplay/pylonConfig";
|
||||||
|
import { AudioManager } from "@/managers/AudioManager";
|
||||||
|
import { loadDialogueManifest } from "@/utils/dialogues/loadDialogueManifest";
|
||||||
|
import { playDialogueById } from "@/utils/dialogues/playDialogue";
|
||||||
|
|
||||||
|
const PYLON_POWERDOWN_SFX = "/sounds/effect/generateur-powerdown.mp3";
|
||||||
|
const PYLON_POWERUP_SFX = "/sounds/effect/generateur-powerup.mp3";
|
||||||
|
|
||||||
|
export function PylonNarrativeFlow(): React.JSX.Element | null {
|
||||||
|
const mainState = useGameStore((state) => state.mainState);
|
||||||
|
const step = useGameStore((state) => state.pylon.currentStep);
|
||||||
|
const setMissionStep = useGameStore((state) => state.setMissionStep);
|
||||||
|
const setCanMove = useGameStore((state) => state.setCanMove);
|
||||||
|
|
||||||
|
// ── approaching : powerdown sfx → then electricOutage dialogue ────────────
|
||||||
|
useEffect(() => {
|
||||||
|
if (mainState !== "pylon" || step !== "approaching") return undefined;
|
||||||
|
|
||||||
|
let isCancelled = false;
|
||||||
|
setCanMove(false);
|
||||||
|
|
||||||
|
void (async () => {
|
||||||
|
// 1. Play the generator powerdown sound effect
|
||||||
|
const sfx = AudioManager.getInstance().playSound(
|
||||||
|
PYLON_POWERDOWN_SFX,
|
||||||
|
1,
|
||||||
|
{ category: "sfx" },
|
||||||
|
);
|
||||||
|
|
||||||
|
// 2. Wait for it to finish (or skip if it can't load)
|
||||||
|
if (sfx) {
|
||||||
|
await new Promise<void>((resolve) => {
|
||||||
|
sfx.addEventListener("ended", () => resolve(), { once: true });
|
||||||
|
sfx.addEventListener("error", () => resolve(), { once: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isCancelled) return;
|
||||||
|
|
||||||
|
// 3. Play the narrative dialogue
|
||||||
|
const manifest = await loadDialogueManifest();
|
||||||
|
if (isCancelled || !manifest) {
|
||||||
|
setCanMove(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const audio = await playDialogueById(
|
||||||
|
manifest,
|
||||||
|
PYLON_NARRATIVE_DIALOGUES.electricOutage,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isCancelled || !audio) {
|
||||||
|
setCanMove(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
audio.addEventListener(
|
||||||
|
"ended",
|
||||||
|
() => {
|
||||||
|
setCanMove(true);
|
||||||
|
},
|
||||||
|
{ once: true },
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
isCancelled = true;
|
||||||
|
setCanMove(true);
|
||||||
|
};
|
||||||
|
}, [mainState, step, setCanMove]);
|
||||||
|
|
||||||
|
// ── arrived : searchCentral dialogue (unchanged) ──────────────────────────
|
||||||
|
useDialoguePlayback({
|
||||||
|
enabled: mainState === "pylon" && step === "arrived",
|
||||||
|
dialogueId: PYLON_NARRATIVE_DIALOGUES.searchCentral,
|
||||||
|
});
|
||||||
|
|
||||||
|
// ── inspected (demo skip) : jump straight to done after 5 s ─────────────
|
||||||
|
useEffect(() => {
|
||||||
|
if (mainState !== "pylon" || step !== "inspected") return undefined;
|
||||||
|
|
||||||
|
const timeoutId = window.setTimeout(() => {
|
||||||
|
setMissionStep("pylon", "done");
|
||||||
|
}, 5_000);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.clearTimeout(timeoutId);
|
||||||
|
};
|
||||||
|
}, [mainState, step, setMissionStep]);
|
||||||
|
|
||||||
|
// ── done : powerup sfx + lighting revert → auto-transition to narrator-outro
|
||||||
|
useEffect(() => {
|
||||||
|
if (mainState !== "pylon" || step !== "done") return undefined;
|
||||||
|
|
||||||
|
const sfx = AudioManager.getInstance().playSound(PYLON_POWERUP_SFX, 1, {
|
||||||
|
category: "sfx",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (sfx) {
|
||||||
|
sfx.addEventListener(
|
||||||
|
"ended",
|
||||||
|
() => setMissionStep("pylon", "narrator-outro"),
|
||||||
|
{ once: true },
|
||||||
|
);
|
||||||
|
sfx.addEventListener(
|
||||||
|
"error",
|
||||||
|
() => setMissionStep("pylon", "narrator-outro"),
|
||||||
|
{ once: true },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Fallback if the audio can't load
|
||||||
|
setMissionStep("pylon", "narrator-outro");
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}, [mainState, step, setMissionStep]);
|
||||||
|
|
||||||
|
// narrator-outro audio sequence + completeMission are handled in PylonNarratorOutro
|
||||||
|
|
||||||
|
if (mainState !== "pylon") return null;
|
||||||
|
|
||||||
|
if (step === "locked") {
|
||||||
|
return (
|
||||||
|
<ZoneDetection
|
||||||
|
key="pylon-approach"
|
||||||
|
zone={PYLON_APPROACH_ZONE}
|
||||||
|
onEnter={() => setMissionStep("pylon", "approaching")}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (step === "approaching") {
|
||||||
|
return (
|
||||||
|
<ZoneDetection
|
||||||
|
key="pylon-arrived"
|
||||||
|
zone={PYLON_ARRIVED_ZONE}
|
||||||
|
onEnter={() => setMissionStep("pylon", "arrived")}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
step === "arrived" ||
|
||||||
|
step === "npc-return" ||
|
||||||
|
step === "inspected" ||
|
||||||
|
step === "done"
|
||||||
|
) {
|
||||||
|
return <PylonFarmerNPC />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (step === "narrator-outro") {
|
||||||
|
return <PylonNarratorOutro />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
|
import { loadDialogueManifest } from "@/utils/dialogues/loadDialogueManifest";
|
||||||
|
import { playDialogueById } from "@/utils/dialogues/playDialogue";
|
||||||
|
import { PYLON_NARRATIVE_DIALOGUES } from "@/data/gameplay/pylonConfig";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays the narrator-outro audio sequence:
|
||||||
|
* 1. electricienne_aurevoir ("À la prochaine !")
|
||||||
|
* 2. narrateur_courantrepare ("powerRestored")
|
||||||
|
* then completes the pylon mission.
|
||||||
|
*/
|
||||||
|
export function PylonNarratorOutro(): null {
|
||||||
|
const completeMission = useGameStore((state) => state.completeMission);
|
||||||
|
const setCanMove = useGameStore((state) => state.setCanMove);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false;
|
||||||
|
setCanMove(false);
|
||||||
|
|
||||||
|
void (async () => {
|
||||||
|
const manifest = await loadDialogueManifest();
|
||||||
|
if (cancelled || !manifest) {
|
||||||
|
setCanMove(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. Électricienne : "À la prochaine !"
|
||||||
|
const audio1 = await playDialogueById(
|
||||||
|
manifest,
|
||||||
|
PYLON_NARRATIVE_DIALOGUES.electricienneAurevoir,
|
||||||
|
);
|
||||||
|
if (audio1 && !cancelled) {
|
||||||
|
await new Promise<void>((resolve) => {
|
||||||
|
audio1.addEventListener("ended", () => resolve(), { once: true });
|
||||||
|
audio1.addEventListener("error", () => resolve(), { once: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cancelled) {
|
||||||
|
setCanMove(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Narrateur : "Le courant est réparé"
|
||||||
|
const audio2 = await playDialogueById(
|
||||||
|
manifest,
|
||||||
|
PYLON_NARRATIVE_DIALOGUES.powerRestored,
|
||||||
|
);
|
||||||
|
if (audio2 && !cancelled) {
|
||||||
|
audio2.addEventListener(
|
||||||
|
"ended",
|
||||||
|
() => {
|
||||||
|
setCanMove(true);
|
||||||
|
completeMission("pylon");
|
||||||
|
},
|
||||||
|
{ once: true },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
setCanMove(true);
|
||||||
|
completeMission("pylon");
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
setCanMove(true);
|
||||||
|
};
|
||||||
|
}, [completeMission, setCanMove]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* Shared runtime signal set by PylonDownedPylon when the straighten
|
||||||
|
* animation starts, so PylonFarmerNPC can switch its lerp target.
|
||||||
|
*
|
||||||
|
* `completed` is set after the straighten animation finishes so
|
||||||
|
* PylonFarmerNPC can play the post-raise audio sequence before
|
||||||
|
* transitioning to the repair game.
|
||||||
|
*/
|
||||||
|
export const pylonStraighteningSignal = { started: false, completed: false };
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
import { useEffect, useMemo, useRef } from "react";
|
||||||
|
import gsap from "gsap";
|
||||||
|
import * as THREE from "three";
|
||||||
|
import { useRepairFocusStore } from "@/managers/stores/useRepairFocusStore";
|
||||||
|
|
||||||
|
const BUBBLE_RADIUS_METERS = 10;
|
||||||
|
const BUBBLE_GROW_DURATION_SECONDS = 2.5;
|
||||||
|
const BUBBLE_SHRINK_DURATION_SECONDS = 1.2;
|
||||||
|
const BUBBLE_COLOR = "#060814";
|
||||||
|
const BUBBLE_OPACITY = 0.92;
|
||||||
|
const BUBBLE_SHELL_RADIUS = 1; // sphere geometry baked at radius=1, scale = radius
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dark sphere shroud rendered around the active repair model when the
|
||||||
|
* focus state is active. Grows from 0 -> BUBBLE_RADIUS_METERS using a
|
||||||
|
* GSAP `expo.out` ease so the player visually transitions from the open
|
||||||
|
* map to an isolated repair "cocoon". Reverses on focus end.
|
||||||
|
*
|
||||||
|
* The sphere uses BackSide rendering so the player remains inside the
|
||||||
|
* shroud when they stand near the repair model. A subtle decor pass
|
||||||
|
* (grid floor + soft directional light + light fog) is rendered as a
|
||||||
|
* sibling group so it appears once the bubble has expanded.
|
||||||
|
*/
|
||||||
|
export function RepairFocusBubble(): React.JSX.Element | null {
|
||||||
|
const active = useRepairFocusStore((state) => state.active);
|
||||||
|
const center = useRepairFocusStore((state) => state.center);
|
||||||
|
const groupRef = useRef<THREE.Group>(null);
|
||||||
|
const meshRef = useRef<THREE.Mesh>(null);
|
||||||
|
const decorRef = useRef<THREE.Group>(null);
|
||||||
|
const scaleRef = useRef({ value: 0.0001 });
|
||||||
|
const decorOpacityRef = useRef({ value: 0 });
|
||||||
|
|
||||||
|
const sphereGeometry = useMemo(
|
||||||
|
() => new THREE.SphereGeometry(BUBBLE_SHELL_RADIUS, 48, 32),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
const sphereMaterial = useMemo(
|
||||||
|
() =>
|
||||||
|
new THREE.MeshBasicMaterial({
|
||||||
|
color: BUBBLE_COLOR,
|
||||||
|
side: THREE.BackSide,
|
||||||
|
transparent: true,
|
||||||
|
opacity: BUBBLE_OPACITY,
|
||||||
|
depthWrite: false,
|
||||||
|
fog: false,
|
||||||
|
}),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
sphereGeometry.dispose();
|
||||||
|
sphereMaterial.dispose();
|
||||||
|
};
|
||||||
|
}, [sphereGeometry, sphereMaterial]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const targetScale = active ? BUBBLE_RADIUS_METERS : 0.0001;
|
||||||
|
const targetDecor = active ? 1 : 0;
|
||||||
|
const duration = active
|
||||||
|
? BUBBLE_GROW_DURATION_SECONDS
|
||||||
|
: BUBBLE_SHRINK_DURATION_SECONDS;
|
||||||
|
|
||||||
|
const scaleTween = gsap.to(scaleRef.current, {
|
||||||
|
value: targetScale,
|
||||||
|
duration,
|
||||||
|
ease: active ? "expo.out" : "expo.in",
|
||||||
|
onUpdate: () => {
|
||||||
|
const mesh = meshRef.current;
|
||||||
|
if (mesh) mesh.scale.setScalar(scaleRef.current.value);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const decorTween = gsap.to(decorOpacityRef.current, {
|
||||||
|
value: targetDecor,
|
||||||
|
duration: duration * 0.8,
|
||||||
|
delay: active ? duration * 0.4 : 0,
|
||||||
|
ease: "power2.inOut",
|
||||||
|
onUpdate: () => {
|
||||||
|
const decor = decorRef.current;
|
||||||
|
if (!decor) return;
|
||||||
|
decor.traverse((child) => {
|
||||||
|
if (
|
||||||
|
child instanceof THREE.Mesh &&
|
||||||
|
child.material instanceof THREE.Material
|
||||||
|
) {
|
||||||
|
const material = child.material as THREE.Material & {
|
||||||
|
opacity?: number;
|
||||||
|
transparent?: boolean;
|
||||||
|
};
|
||||||
|
if (typeof material.opacity === "number") {
|
||||||
|
material.opacity = decorOpacityRef.current.value;
|
||||||
|
material.transparent = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
scaleTween.kill();
|
||||||
|
decorTween.kill();
|
||||||
|
};
|
||||||
|
}, [active]);
|
||||||
|
|
||||||
|
// Render even when inactive so the shrink tween can play out; visibility
|
||||||
|
// is implicit via near-zero scale.
|
||||||
|
return (
|
||||||
|
<group ref={groupRef} position={center}>
|
||||||
|
<mesh
|
||||||
|
ref={meshRef}
|
||||||
|
geometry={sphereGeometry}
|
||||||
|
material={sphereMaterial}
|
||||||
|
renderOrder={-1}
|
||||||
|
frustumCulled={false}
|
||||||
|
/>
|
||||||
|
<group ref={decorRef}>
|
||||||
|
{/* Subtle grid floor visible only inside the bubble */}
|
||||||
|
<gridHelper
|
||||||
|
args={[BUBBLE_RADIUS_METERS * 1.6, 24, "#1f2937", "#111827"]}
|
||||||
|
position={[0, -0.5, 0]}
|
||||||
|
/>
|
||||||
|
{/* Soft directional light for the repair model */}
|
||||||
|
<directionalLight
|
||||||
|
position={[2, 4, 3]}
|
||||||
|
intensity={0.6}
|
||||||
|
color="#cbd5f5"
|
||||||
|
/>
|
||||||
|
<ambientLight intensity={0.25} color="#1e293b" />
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -25,6 +25,7 @@ import type {
|
|||||||
RepairScannedBrokenPart,
|
RepairScannedBrokenPart,
|
||||||
} from "@/types/gameplay/repairMission";
|
} from "@/types/gameplay/repairMission";
|
||||||
import { useGameStore } from "@/managers/stores/useGameStore";
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
|
import { useRepairFocusStore } from "@/managers/stores/useRepairFocusStore";
|
||||||
import type { ModelTransformProps, Vector3Tuple } from "@/types/three/three";
|
import type { ModelTransformProps, Vector3Tuple } from "@/types/three/three";
|
||||||
import { toVector3Scale } from "@/utils/three/scale";
|
import { toVector3Scale } from "@/utils/three/scale";
|
||||||
|
|
||||||
@@ -72,8 +73,20 @@ export function RepairGame({
|
|||||||
const [scannedBrokenParts, setScannedBrokenParts] = useState<
|
const [scannedBrokenParts, setScannedBrokenParts] = useState<
|
||||||
readonly RepairScannedBrokenPart[]
|
readonly RepairScannedBrokenPart[]
|
||||||
>([]);
|
>([]);
|
||||||
|
// For the ebike mission, use the bike's live parked world position once
|
||||||
|
// the repair flow leaves the waiting/locked phase so the repair happens
|
||||||
|
// wherever the player parked the bike, not at the static zone anchor.
|
||||||
|
// window.ebikeParkedPosition is set by Ebike when the player drops the
|
||||||
|
// bike and stays stable through the rest of the repair flow.
|
||||||
|
const livePosition = useMemo<Vector3Tuple>(() => {
|
||||||
|
if (mission !== "ebike" || mainState !== mission) return position;
|
||||||
|
if (step === "locked" || step === "waiting") return position;
|
||||||
|
const parked = window.ebikeParkedPosition;
|
||||||
|
if (!parked) return position;
|
||||||
|
return [parked[0], parked[1], parked[2]];
|
||||||
|
}, [mainState, mission, position, step]);
|
||||||
const parsedScale = toVector3Scale(scale);
|
const parsedScale = toVector3Scale(scale);
|
||||||
const snappedPosition = useTerrainSnappedPosition(position);
|
const snappedPosition = useTerrainSnappedPosition(livePosition);
|
||||||
const readyForFragmentation = step === "inspected";
|
const readyForFragmentation = step === "inspected";
|
||||||
const brokenNodeNames = useMemo(() => getBrokenNodeNames(config), [config]);
|
const brokenNodeNames = useMemo(() => getBrokenNodeNames(config), [config]);
|
||||||
|
|
||||||
@@ -98,6 +111,25 @@ export function RepairGame({
|
|||||||
};
|
};
|
||||||
}, [mainState, mission, step]);
|
}, [mainState, mission, step]);
|
||||||
|
|
||||||
|
// Drive the global focus bubble: active during the immersive repair
|
||||||
|
// phases so the world dims/hides outside the dark sphere shroud.
|
||||||
|
const focusCenterX = snappedPosition[0];
|
||||||
|
const focusCenterY = snappedPosition[1];
|
||||||
|
const focusCenterZ = snappedPosition[2];
|
||||||
|
useEffect(() => {
|
||||||
|
const inFocusPhase =
|
||||||
|
mainState === mission && shouldFocusBubbleBeActive(step);
|
||||||
|
if (inFocusPhase) {
|
||||||
|
useRepairFocusStore
|
||||||
|
.getState()
|
||||||
|
.setFocus(true, [focusCenterX, focusCenterY, focusCenterZ]);
|
||||||
|
return () => {
|
||||||
|
useRepairFocusStore.getState().setFocus(false);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}, [mainState, mission, step, focusCenterX, focusCenterY, focusCenterZ]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (mainState !== mission) return undefined;
|
if (mainState !== mission) return undefined;
|
||||||
|
|
||||||
@@ -131,6 +163,7 @@ export function RepairGame({
|
|||||||
{step === "fragmented" ? (
|
{step === "fragmented" ? (
|
||||||
<ExplodableModel
|
<ExplodableModel
|
||||||
modelPath={config.modelPath}
|
modelPath={config.modelPath}
|
||||||
|
rotation={config.modelRotation ?? [0, 0, 0]}
|
||||||
scale={config.modelScale ?? 1}
|
scale={config.modelScale ?? 1}
|
||||||
split
|
split
|
||||||
/>
|
/>
|
||||||
@@ -148,6 +181,7 @@ export function RepairGame({
|
|||||||
<>
|
<>
|
||||||
<ExplodableModel
|
<ExplodableModel
|
||||||
modelPath={config.modelPath}
|
modelPath={config.modelPath}
|
||||||
|
rotation={config.modelRotation ?? [0, 0, 0]}
|
||||||
scale={config.modelScale ?? 1}
|
scale={config.modelScale ?? 1}
|
||||||
split
|
split
|
||||||
hideNodeNames={brokenNodeNames}
|
hideNodeNames={brokenNodeNames}
|
||||||
@@ -170,7 +204,7 @@ export function RepairGame({
|
|||||||
onComplete={() => setMissionStep(mission, "done")}
|
onComplete={() => setMissionStep(mission, "done")}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{step === "done" ? (
|
{step === "done" && mission !== "pylon" ? (
|
||||||
<RepairCompletionStep
|
<RepairCompletionStep
|
||||||
config={config}
|
config={config}
|
||||||
onComplete={() => completeMission(mission)}
|
onComplete={() => completeMission(mission)}
|
||||||
@@ -200,6 +234,15 @@ function shouldKeepRepairRuntimeState(step: MissionStep): boolean {
|
|||||||
return step === "repairing" || step === "reassembling" || step === "done";
|
return step === "repairing" || step === "reassembling" || step === "done";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shouldFocusBubbleBeActive(step: MissionStep): boolean {
|
||||||
|
return (
|
||||||
|
step === "fragmented" ||
|
||||||
|
step === "scanning" ||
|
||||||
|
step === "repairing" ||
|
||||||
|
step === "reassembling"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function getRepairMissionModelPaths(config: RepairMissionConfig): string[] {
|
function getRepairMissionModelPaths(config: RepairMissionConfig): string[] {
|
||||||
return [
|
return [
|
||||||
...new Set([
|
...new Set([
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { GameSettingsMenu } from "@/components/ui/GameSettingsMenu";
|
|||||||
import { HandTrackingFallback } from "@/components/ui/HandTrackingFallback";
|
import { HandTrackingFallback } from "@/components/ui/HandTrackingFallback";
|
||||||
import { HandTrackingVisualizer } from "@/components/ui/HandTrackingVisualizer";
|
import { HandTrackingVisualizer } from "@/components/ui/HandTrackingVisualizer";
|
||||||
import { InteractPrompt } from "@/components/ui/InteractPrompt";
|
import { InteractPrompt } from "@/components/ui/InteractPrompt";
|
||||||
import { RepairMovementLockIndicator } from "@/components/ui/RepairMovementLockIndicator";
|
import { OutroVideoOverlay } from "@/components/ui/OutroVideoOverlay";
|
||||||
import { Subtitles } from "@/components/ui/Subtitles";
|
import { Subtitles } from "@/components/ui/Subtitles";
|
||||||
import { TalkieDialogueOverlay } from "@/components/ui/TalkieDialogueOverlay";
|
import { TalkieDialogueOverlay } from "@/components/ui/TalkieDialogueOverlay";
|
||||||
|
|
||||||
@@ -13,13 +13,13 @@ export function GameUI(): React.JSX.Element {
|
|||||||
<>
|
<>
|
||||||
<DebugOverlayLayout />
|
<DebugOverlayLayout />
|
||||||
<Crosshair />
|
<Crosshair />
|
||||||
<RepairMovementLockIndicator />
|
|
||||||
<InteractPrompt />
|
<InteractPrompt />
|
||||||
<HandTrackingVisualizer />
|
<HandTrackingVisualizer />
|
||||||
<HandTrackingFallback />
|
<HandTrackingFallback />
|
||||||
<Subtitles />
|
<Subtitles />
|
||||||
<TalkieDialogueOverlay />
|
<TalkieDialogueOverlay />
|
||||||
<GameSettingsMenu />
|
<GameSettingsMenu />
|
||||||
|
<OutroVideoOverlay />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,14 @@ export function InteractPrompt(): React.JSX.Element | null {
|
|||||||
if (cameraMode !== "player") return null;
|
if (cameraMode !== "player") return null;
|
||||||
if (!focused || holding || focused.kind !== "trigger") return null;
|
if (!focused || holding || focused.kind !== "trigger") return null;
|
||||||
|
|
||||||
|
const label = focused.label?.trim() ?? "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="interact-prompt" aria-live="polite">
|
<div className="interact-prompt" aria-live="polite">
|
||||||
<kbd className="interact-prompt__key">{INTERACT_KEY.toUpperCase()}</kbd>
|
<kbd className="interact-prompt__key">{INTERACT_KEY.toUpperCase()}</kbd>
|
||||||
<span className="interact-prompt__label">{focused.label}</span>
|
{label.length > 0 ? (
|
||||||
|
<span className="interact-prompt__label">{label}</span>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
|
const OUTRO_VIDEO_SRC = "/cinematics/outro.mp4";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full-screen video overlay that plays once after the outro drone-shot
|
||||||
|
* cinematic ends. Triggered by the "outro-cinematic-complete" window event
|
||||||
|
* dispatched from GameCinematics.tsx.
|
||||||
|
*/
|
||||||
|
export function OutroVideoOverlay(): React.JSX.Element | null {
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
const videoRef = useRef<HTMLVideoElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
function handleCinematicComplete(): void {
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener("outro-cinematic-complete", handleCinematicComplete);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener(
|
||||||
|
"outro-cinematic-complete",
|
||||||
|
handleCinematicComplete,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!visible) return;
|
||||||
|
void videoRef.current?.play();
|
||||||
|
}, [visible]);
|
||||||
|
|
||||||
|
if (!visible) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "fixed",
|
||||||
|
inset: 0,
|
||||||
|
zIndex: 10000,
|
||||||
|
background: "#000",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<video
|
||||||
|
ref={videoRef}
|
||||||
|
src={OUTRO_VIDEO_SRC}
|
||||||
|
style={{ width: "100%", height: "100%", objectFit: "cover" }}
|
||||||
|
playsInline
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
import { useCameraMode } from "@/hooks/debug/useCameraMode";
|
|
||||||
import { useRepairMovementLocked } from "@/hooks/gameplay/useRepairMovementLocked";
|
|
||||||
|
|
||||||
export function RepairMovementLockIndicator(): React.JSX.Element | null {
|
|
||||||
const cameraMode = useCameraMode();
|
|
||||||
const movementLocked = useRepairMovementLocked();
|
|
||||||
|
|
||||||
if (cameraMode !== "player") return null;
|
|
||||||
if (!movementLocked) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="repair-movement-lock-indicator" aria-live="polite">
|
|
||||||
<span
|
|
||||||
className="repair-movement-lock-indicator__dot"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
<span>Déplacement verrouillé pendant la réparation</span>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -5,8 +5,8 @@ import {
|
|||||||
MAIN_GAME_STATES,
|
MAIN_GAME_STATES,
|
||||||
} from "@/data/game/gameStateConfig";
|
} from "@/data/game/gameStateConfig";
|
||||||
import {
|
import {
|
||||||
|
getMissionStepsFor,
|
||||||
isMissionStep,
|
isMissionStep,
|
||||||
MISSION_STEPS,
|
|
||||||
} from "@/data/gameplay/repairMissionState";
|
} from "@/data/gameplay/repairMissionState";
|
||||||
import { useGameStore } from "@/managers/stores/useGameStore";
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
import type { MainGameState } from "@/types/game";
|
import type { MainGameState } from "@/types/game";
|
||||||
@@ -53,7 +53,9 @@ export function GameStateDebugPanel(): React.JSX.Element {
|
|||||||
? GAME_STEPS
|
? GAME_STEPS
|
||||||
: mainState === "outro"
|
: mainState === "outro"
|
||||||
? ["waiting", "started"]
|
? ["waiting", "started"]
|
||||||
: MISSION_STEPS;
|
: mainState === "ebike" || mainState === "pylon" || mainState === "farm"
|
||||||
|
? getMissionStepsFor(mainState)
|
||||||
|
: [];
|
||||||
|
|
||||||
function setSubState(nextSubState: string): void {
|
function setSubState(nextSubState: string): void {
|
||||||
if (mainState === "intro") {
|
if (mainState === "intro") {
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import { useFrame, useThree } from "@react-three/fiber";
|
||||||
|
import * as THREE from "three";
|
||||||
|
import { isDebugEnabled } from "@/utils/debug/isDebugEnabled";
|
||||||
|
import type { ZoneConfig } from "@/types/gameplay/zone";
|
||||||
|
|
||||||
|
interface ZoneDetectionProps {
|
||||||
|
zone: ZoneConfig;
|
||||||
|
onEnter: () => void;
|
||||||
|
height?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const _cameraPos = new THREE.Vector3();
|
||||||
|
|
||||||
|
export function ZoneDebugVisual({
|
||||||
|
zone,
|
||||||
|
active,
|
||||||
|
}: {
|
||||||
|
zone: ZoneConfig;
|
||||||
|
active: boolean;
|
||||||
|
}): React.JSX.Element | null {
|
||||||
|
if (!isDebugEnabled()) return null;
|
||||||
|
return (
|
||||||
|
<group position={zone.position}>
|
||||||
|
<mesh rotation={[-Math.PI / 2, 0, 0]}>
|
||||||
|
<ringGeometry args={[zone.radius - 0.2, zone.radius, 32]} />
|
||||||
|
<meshBasicMaterial
|
||||||
|
color={active ? "#22c55e" : "#fbbf24"}
|
||||||
|
transparent
|
||||||
|
opacity={0.6}
|
||||||
|
side={THREE.DoubleSide}
|
||||||
|
/>
|
||||||
|
</mesh>
|
||||||
|
<mesh>
|
||||||
|
<cylinderGeometry
|
||||||
|
args={[zone.radius, zone.radius, zone.height, 16, 1, true]}
|
||||||
|
/>
|
||||||
|
<meshBasicMaterial
|
||||||
|
color={active ? "#22c55e" : "#fbbf24"}
|
||||||
|
transparent
|
||||||
|
opacity={0.08}
|
||||||
|
side={THREE.DoubleSide}
|
||||||
|
/>
|
||||||
|
</mesh>
|
||||||
|
</group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ZoneDetection({
|
||||||
|
zone,
|
||||||
|
onEnter,
|
||||||
|
height,
|
||||||
|
}: ZoneDetectionProps): React.JSX.Element {
|
||||||
|
const camera = useThree((state) => state.camera);
|
||||||
|
const hasTriggeredRef = useRef(false);
|
||||||
|
const onEnterRef = useRef(onEnter);
|
||||||
|
const [isActive, setIsActive] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onEnterRef.current = onEnter;
|
||||||
|
}, [onEnter]);
|
||||||
|
|
||||||
|
useFrame(() => {
|
||||||
|
if (hasTriggeredRef.current) return;
|
||||||
|
|
||||||
|
camera.getWorldPosition(_cameraPos);
|
||||||
|
const dx = _cameraPos.x - zone.position[0];
|
||||||
|
const dz = _cameraPos.z - zone.position[2];
|
||||||
|
const horizontalDist = Math.sqrt(dx * dx + dz * dz);
|
||||||
|
|
||||||
|
if (horizontalDist > zone.radius) return;
|
||||||
|
|
||||||
|
const zoneHeight = height ?? zone.height;
|
||||||
|
if (_cameraPos.y < zone.position[1] - zoneHeight / 2) return;
|
||||||
|
if (_cameraPos.y > zone.position[1] + zoneHeight / 2) return;
|
||||||
|
|
||||||
|
hasTriggeredRef.current = true;
|
||||||
|
setIsActive(true);
|
||||||
|
onEnterRef.current();
|
||||||
|
});
|
||||||
|
|
||||||
|
return <ZoneDebugVisual zone={zone} active={isActive} />;
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import type { Vector3Tuple } from "@/types/three/three";
|
||||||
|
|
||||||
|
export const PYLON_WORLD_POSITION: Vector3Tuple = [-31.5, 3.5, 36.04];
|
||||||
|
|
||||||
|
export const PYLON_DOWNED_ROTATION: Vector3Tuple = [0, 0, -0.9];
|
||||||
|
|
||||||
|
export const PYLON_UPRIGHT_ROTATION: Vector3Tuple = [0, 0, 0];
|
||||||
|
|
||||||
|
export const PYLON_FARMER_NPC_POSITION: Vector3Tuple = [-16.13, 3.2, 52.46];
|
||||||
|
|
||||||
|
export const PYLON_FARMER_NPC_AFTER_POSITION: Vector3Tuple = [
|
||||||
|
PYLON_WORLD_POSITION[0] + 3,
|
||||||
|
PYLON_WORLD_POSITION[1] + 0.2,
|
||||||
|
PYLON_WORLD_POSITION[2],
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Point vers lequel l'électricienne regarde pendant sa marche vers le pylône (ajustable) */
|
||||||
|
export const PYLON_FARMER_NPC_WALK_LOOK_AT: Vector3Tuple = [
|
||||||
|
PYLON_WORLD_POSITION[0] + 3,
|
||||||
|
PYLON_WORLD_POSITION[1] + 0.2,
|
||||||
|
PYLON_WORLD_POSITION[2],
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Position finale du PNJ quand le pylône se redresse */
|
||||||
|
export const PYLON_FARMER_NPC_AFTER_POSITION_pylone_straight: Vector3Tuple = [
|
||||||
|
PYLON_WORLD_POSITION[0] + 1,
|
||||||
|
PYLON_WORLD_POSITION[1],
|
||||||
|
PYLON_WORLD_POSITION[2],
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Rotation (X Y Z radians) du PNJ une fois arrivé sous le pylône */
|
||||||
|
export const PYLON_FARMER_NPC_AFTER_ROTATION: Vector3Tuple = [0, 0, 0];
|
||||||
|
|
||||||
|
/** Scale uniforme du PNJ une fois arrivé sous le pylône */
|
||||||
|
export const PYLON_FARMER_NPC_AFTER_SCALE = 1.55;
|
||||||
|
|
||||||
|
/** Vitesse du lerp de déplacement du PNJ (unités/s) */
|
||||||
|
export const PYLON_FARMER_NPC_WALK_SPEED = 2;
|
||||||
|
|
||||||
|
export const PYLON_NARRATIVE_INTERACT_RADIUS = 3.5;
|
||||||
|
|
||||||
|
export const PYLON_STRAIGHTEN_ANIMATION_DURATION_MS = 2200;
|
||||||
|
|
||||||
|
export const PYLON_NARRATIVE_DIALOGUES = {
|
||||||
|
electricOutage: "narrateur_coupureelec",
|
||||||
|
searchCentral: "narrateur_fouillelecentre",
|
||||||
|
brokenPylon: "narrateur_poteaueleccasse",
|
||||||
|
demandeAide: "narrateur_demande_aide",
|
||||||
|
farmerHelp: "fermier_coupdemain",
|
||||||
|
electricienneWelcome: "electricienne_welcome",
|
||||||
|
electricienneApresMontage: "electricienne_apresMontage",
|
||||||
|
electricienneAurevoir: "electricienne_aurevoir",
|
||||||
|
powerRestored: "narrateur_courantrepare",
|
||||||
|
} as const;
|
||||||
@@ -4,6 +4,7 @@ import type {
|
|||||||
RepairMissionTriggerConfig,
|
RepairMissionTriggerConfig,
|
||||||
} from "@/types/gameplay/repairMission";
|
} from "@/types/gameplay/repairMission";
|
||||||
import { EBIKE_WORLD_POSITION } from "@/data/ebike/ebikeConfig";
|
import { EBIKE_WORLD_POSITION } from "@/data/ebike/ebikeConfig";
|
||||||
|
import { PYLON_WORLD_POSITION } from "@/data/gameplay/pylonConfig";
|
||||||
|
|
||||||
export const REPAIR_MISSION_ANCHOR_IDS: Partial<
|
export const REPAIR_MISSION_ANCHOR_IDS: Partial<
|
||||||
Record<RepairMissionId, string>
|
Record<RepairMissionId, string>
|
||||||
@@ -15,7 +16,7 @@ const EBIKE_REPAIR_POSITION = EBIKE_WORLD_POSITION satisfies Vector3Tuple;
|
|||||||
|
|
||||||
const REPAIR_MISSION_POSITIONS = {
|
const REPAIR_MISSION_POSITIONS = {
|
||||||
ebike: EBIKE_REPAIR_POSITION,
|
ebike: EBIKE_REPAIR_POSITION,
|
||||||
pylon: [64, 0, -66],
|
pylon: PYLON_WORLD_POSITION,
|
||||||
farm: [-24, 0, 42],
|
farm: [-24, 0, 42],
|
||||||
} as const satisfies Record<RepairMissionId, Vector3Tuple>;
|
} as const satisfies Record<RepairMissionId, Vector3Tuple>;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ const REPAIR_MISSION_ID_VALUES: ReadonlySet<string> = new Set(
|
|||||||
|
|
||||||
export const MISSION_STEPS = [
|
export const MISSION_STEPS = [
|
||||||
"locked",
|
"locked",
|
||||||
|
"approaching",
|
||||||
|
"arrived",
|
||||||
|
"npc-return",
|
||||||
"waiting",
|
"waiting",
|
||||||
"inspected",
|
"inspected",
|
||||||
"fragmented",
|
"fragmented",
|
||||||
@@ -17,9 +20,24 @@ export const MISSION_STEPS = [
|
|||||||
"repairing",
|
"repairing",
|
||||||
"reassembling",
|
"reassembling",
|
||||||
"done",
|
"done",
|
||||||
|
"narrator-outro",
|
||||||
] as const satisfies readonly MissionStep[];
|
] as const satisfies readonly MissionStep[];
|
||||||
const MISSION_STEP_VALUES: ReadonlySet<string> = new Set(MISSION_STEPS);
|
const MISSION_STEP_VALUES: ReadonlySet<string> = new Set(MISSION_STEPS);
|
||||||
|
|
||||||
|
const PYLON_ONLY_MISSION_STEPS = new Set<MissionStep>([
|
||||||
|
"approaching",
|
||||||
|
"arrived",
|
||||||
|
"npc-return",
|
||||||
|
"narrator-outro",
|
||||||
|
]);
|
||||||
|
|
||||||
|
export function getMissionStepsFor(
|
||||||
|
mission: RepairMissionId,
|
||||||
|
): readonly MissionStep[] {
|
||||||
|
if (mission === "pylon") return MISSION_STEPS;
|
||||||
|
return MISSION_STEPS.filter((step) => !PYLON_ONLY_MISSION_STEPS.has(step));
|
||||||
|
}
|
||||||
|
|
||||||
export function isRepairMissionId(value: string): value is RepairMissionId {
|
export function isRepairMissionId(value: string): value is RepairMissionId {
|
||||||
return REPAIR_MISSION_ID_VALUES.has(value);
|
return REPAIR_MISSION_ID_VALUES.has(value);
|
||||||
}
|
}
|
||||||
@@ -28,9 +46,18 @@ export function isMissionStep(value: string): value is MissionStep {
|
|||||||
return MISSION_STEP_VALUES.has(value);
|
return MISSION_STEP_VALUES.has(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNextMissionStep(step: MissionStep): MissionStep {
|
export function getNextMissionStep(
|
||||||
|
step: MissionStep,
|
||||||
|
mission?: RepairMissionId,
|
||||||
|
): MissionStep {
|
||||||
switch (step) {
|
switch (step) {
|
||||||
case "locked":
|
case "locked":
|
||||||
|
return mission === "pylon" ? "approaching" : "waiting";
|
||||||
|
case "approaching":
|
||||||
|
return "arrived";
|
||||||
|
case "arrived":
|
||||||
|
return "npc-return";
|
||||||
|
case "npc-return":
|
||||||
return "waiting";
|
return "waiting";
|
||||||
case "waiting":
|
case "waiting":
|
||||||
return "inspected";
|
return "inspected";
|
||||||
@@ -43,16 +70,29 @@ export function getNextMissionStep(step: MissionStep): MissionStep {
|
|||||||
case "repairing":
|
case "repairing":
|
||||||
return "reassembling";
|
return "reassembling";
|
||||||
case "reassembling":
|
case "reassembling":
|
||||||
case "done":
|
|
||||||
return "done";
|
return "done";
|
||||||
|
case "done":
|
||||||
|
return mission === "pylon" ? "narrator-outro" : "done";
|
||||||
|
case "narrator-outro":
|
||||||
|
return "narrator-outro";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPreviousMissionStep(step: MissionStep): MissionStep {
|
export function getPreviousMissionStep(
|
||||||
|
step: MissionStep,
|
||||||
|
mission?: RepairMissionId,
|
||||||
|
): MissionStep {
|
||||||
switch (step) {
|
switch (step) {
|
||||||
case "locked":
|
case "locked":
|
||||||
case "waiting":
|
|
||||||
return "locked";
|
return "locked";
|
||||||
|
case "approaching":
|
||||||
|
return "locked";
|
||||||
|
case "arrived":
|
||||||
|
return "approaching";
|
||||||
|
case "npc-return":
|
||||||
|
return "arrived";
|
||||||
|
case "waiting":
|
||||||
|
return mission === "pylon" ? "npc-return" : "locked";
|
||||||
case "inspected":
|
case "inspected":
|
||||||
return "waiting";
|
return "waiting";
|
||||||
case "fragmented":
|
case "fragmented":
|
||||||
@@ -65,5 +105,7 @@ export function getPreviousMissionStep(step: MissionStep): MissionStep {
|
|||||||
return "repairing";
|
return "repairing";
|
||||||
case "done":
|
case "done":
|
||||||
return "reassembling";
|
return "reassembling";
|
||||||
|
case "narrator-outro":
|
||||||
|
return "done";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import type {
|
|||||||
RepairMissionConfig,
|
RepairMissionConfig,
|
||||||
RepairMissionId,
|
RepairMissionId,
|
||||||
} from "@/types/gameplay/repairMission";
|
} from "@/types/gameplay/repairMission";
|
||||||
|
import {
|
||||||
|
EBIKE_WORLD_ROTATION_Y,
|
||||||
|
EBIKE_WORLD_SCALE,
|
||||||
|
} from "@/data/ebike/ebikeConfig";
|
||||||
|
|
||||||
const REPAIR_INTERACT_UI_PATH = "/assets/world/UI/interagir.webm";
|
const REPAIR_INTERACT_UI_PATH = "/assets/world/UI/interagir.webm";
|
||||||
const REPAIR_BROKEN_UI_PATH = "/assets/world/UI/cassé.webm";
|
const REPAIR_BROKEN_UI_PATH = "/assets/world/UI/cassé.webm";
|
||||||
@@ -20,7 +24,8 @@ export const REPAIR_MISSIONS: Record<RepairMissionId, RepairMissionConfig> = {
|
|||||||
description:
|
description:
|
||||||
"Repair the damaged cooling module before relaunching the bike",
|
"Repair the damaged cooling module before relaunching the bike",
|
||||||
modelPath: "/models/ebike/model.gltf",
|
modelPath: "/models/ebike/model.gltf",
|
||||||
modelScale: 0.3,
|
modelScale: EBIKE_WORLD_SCALE,
|
||||||
|
modelRotation: [0, EBIKE_WORLD_ROTATION_Y, 0],
|
||||||
stageUiPath: "/assets/world/UI/ebike-mission-notification.webm",
|
stageUiPath: "/assets/world/UI/ebike-mission-notification.webm",
|
||||||
interactUiPath: REPAIR_INTERACT_UI_PATH,
|
interactUiPath: REPAIR_INTERACT_UI_PATH,
|
||||||
brokenUiPath: REPAIR_BROKEN_UI_PATH,
|
brokenUiPath: REPAIR_BROKEN_UI_PATH,
|
||||||
@@ -86,7 +91,20 @@ export const REPAIR_MISSIONS: Record<RepairMissionId, RepairMissionConfig> = {
|
|||||||
"pylon-cable-left-replacement",
|
"pylon-cable-left-replacement",
|
||||||
],
|
],
|
||||||
scanPartSeconds: 1.4,
|
scanPartSeconds: 1.4,
|
||||||
brokenParts: [],
|
brokenParts: [
|
||||||
|
{
|
||||||
|
id: "pylon-grid-relay",
|
||||||
|
label: "Grid relay",
|
||||||
|
nodeName: "lampe",
|
||||||
|
caseSlotName: "placeholder_1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "pylon-damaged-panel",
|
||||||
|
label: "Damaged solar panel",
|
||||||
|
nodeName: "pylone",
|
||||||
|
caseSlotName: "placeholder_2",
|
||||||
|
},
|
||||||
|
],
|
||||||
replacementParts: [
|
replacementParts: [
|
||||||
{
|
{
|
||||||
id: "pylon-cable-right-replacement",
|
id: "pylon-cable-right-replacement",
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import type { ZoneConfig } from "@/types/gameplay/zone";
|
||||||
|
import { PYLON_WORLD_POSITION } from "@/data/gameplay/pylonConfig";
|
||||||
|
|
||||||
|
// Zones qui active la coupure de courant
|
||||||
|
export const PYLON_APPROACH_ZONE: ZoneConfig = {
|
||||||
|
id: "pylon-approach",
|
||||||
|
position: [5, 4, -21.5],
|
||||||
|
radius: 10,
|
||||||
|
height: 18,
|
||||||
|
oneShot: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Zone qui active la cinématique d'arrivée du pylône
|
||||||
|
export const PYLON_ARRIVED_ZONE: ZoneConfig = {
|
||||||
|
id: "pylon-arrived",
|
||||||
|
position: [
|
||||||
|
PYLON_WORLD_POSITION[0],
|
||||||
|
PYLON_WORLD_POSITION[1],
|
||||||
|
PYLON_WORLD_POSITION[2],
|
||||||
|
],
|
||||||
|
radius: 30,
|
||||||
|
height: 15,
|
||||||
|
oneShot: true,
|
||||||
|
};
|
||||||
@@ -30,8 +30,8 @@ export const CHARACTER_CONFIGS = {
|
|||||||
position: [-40.5, 0, 45.5],
|
position: [-40.5, 0, 45.5],
|
||||||
rotation: [0, -0.35, 0],
|
rotation: [0, -0.35, 0],
|
||||||
scale: [1.55, 1.55, 1.55],
|
scale: [1.55, 1.55, 1.55],
|
||||||
animations: ["Dance"],
|
animations: ["idle", "walk"],
|
||||||
defaultAnimation: "Dance",
|
defaultAnimation: "idle",
|
||||||
},
|
},
|
||||||
gerant: {
|
gerant: {
|
||||||
id: "gerant",
|
id: "gerant",
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { useRef } from "react";
|
||||||
|
import { useFrame } from "@react-three/fiber";
|
||||||
|
import type GUI from "lil-gui";
|
||||||
|
import { useDebugFolder } from "@/hooks/debug/useDebugFolder";
|
||||||
|
|
||||||
|
export function usePlayerPositionDebug(): void {
|
||||||
|
const pos = useRef({ x: 0, y: 0, z: 0 });
|
||||||
|
const controllers = useRef<{ updateDisplay: () => void }[]>([]);
|
||||||
|
|
||||||
|
useDebugFolder("Game", (folder: GUI) => {
|
||||||
|
const sub = folder.addFolder("Player Position");
|
||||||
|
sub.open();
|
||||||
|
|
||||||
|
controllers.current = [
|
||||||
|
sub.add(pos.current, "x").name("X").decimals(2).disable(),
|
||||||
|
sub.add(pos.current, "y").name("Y").decimals(2).disable(),
|
||||||
|
sub.add(pos.current, "z").name("Z").decimals(2).disable(),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
useFrame(() => {
|
||||||
|
const p = window.playerPos;
|
||||||
|
if (!p) return;
|
||||||
|
pos.current.x = p[0];
|
||||||
|
pos.current.y = p[1];
|
||||||
|
pos.current.z = p[2];
|
||||||
|
for (const c of controllers.current) c.updateDisplay();
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
|
import { loadDialogueManifest } from "@/utils/dialogues/loadDialogueManifest";
|
||||||
|
import { playDialogueById } from "@/utils/dialogues/playDialogue";
|
||||||
|
|
||||||
|
interface UseDialoguePlaybackOptions {
|
||||||
|
enabled: boolean;
|
||||||
|
dialogueId: string | null;
|
||||||
|
onComplete?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDialoguePlayback({
|
||||||
|
enabled,
|
||||||
|
dialogueId,
|
||||||
|
onComplete,
|
||||||
|
}: UseDialoguePlaybackOptions): void {
|
||||||
|
const setCanMove = useGameStore((state) => state.setCanMove);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!enabled || !dialogueId) return undefined;
|
||||||
|
|
||||||
|
let isCancelled = false;
|
||||||
|
setCanMove(false);
|
||||||
|
|
||||||
|
void (async () => {
|
||||||
|
const manifest = await loadDialogueManifest();
|
||||||
|
if (isCancelled || !manifest) {
|
||||||
|
setCanMove(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const audio = await playDialogueById(manifest, dialogueId);
|
||||||
|
if (isCancelled || !audio) {
|
||||||
|
setCanMove(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
audio.addEventListener(
|
||||||
|
"ended",
|
||||||
|
() => {
|
||||||
|
setCanMove(true);
|
||||||
|
onComplete?.();
|
||||||
|
},
|
||||||
|
{ once: true },
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
isCancelled = true;
|
||||||
|
setCanMove(true);
|
||||||
|
};
|
||||||
|
}, [enabled, dialogueId, onComplete, setCanMove]);
|
||||||
|
}
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import { useGameStore } from "@/managers/stores/useGameStore";
|
|
||||||
import type { MissionStep } from "@/types/gameplay/repairMission";
|
|
||||||
|
|
||||||
export function useRepairMovementLocked(): boolean {
|
|
||||||
return useGameStore((state) => {
|
|
||||||
switch (state.mainState) {
|
|
||||||
case "ebike":
|
|
||||||
return isRepairMovementLocked(state.ebike.currentStep);
|
|
||||||
case "pylon":
|
|
||||||
return isRepairMovementLocked(state.pylon.currentStep);
|
|
||||||
case "farm":
|
|
||||||
return isRepairMovementLocked(state.farm.currentStep);
|
|
||||||
case "intro":
|
|
||||||
case "outro":
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function isRepairMovementLocked(step: MissionStep): boolean {
|
|
||||||
return (
|
|
||||||
step === "inspected" ||
|
|
||||||
step === "fragmented" ||
|
|
||||||
step === "scanning" ||
|
|
||||||
step === "repairing" ||
|
|
||||||
step === "reassembling" ||
|
|
||||||
step === "done"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
+26
-13
@@ -809,35 +809,48 @@ canvas {
|
|||||||
|
|
||||||
.interact-prompt {
|
.interact-prompt {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 30%;
|
bottom: 12%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: stretch;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
.interact-prompt__key {
|
.interact-prompt__key,
|
||||||
|
.interact-prompt__label {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 24px;
|
height: 36px;
|
||||||
height: 24px;
|
background: rgba(10, 12, 20, 0.55);
|
||||||
background: rgba(255, 255, 255, 0.15);
|
border: 1px solid rgba(255, 255, 255, 0.7);
|
||||||
border: 1px solid rgba(255, 255, 255, 0.5);
|
font-family: "Inter", sans-serif;
|
||||||
border-radius: 4px;
|
color: #ffffff;
|
||||||
font-size: 13px;
|
}
|
||||||
font-weight: 600;
|
|
||||||
color: white;
|
.interact-prompt__key {
|
||||||
|
width: 36px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 900;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
|
letter-spacing: 0;
|
||||||
|
/* 3D keyboard key effect: top highlight, bottom inner darkening,
|
||||||
|
and a thin bottom drop so the key reads as physically pressed-up. */
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.25),
|
||||||
|
inset 0 -3px 0 rgba(0, 0, 0, 0.45),
|
||||||
|
0 2px 0 rgba(0, 0, 0, 0.55);
|
||||||
}
|
}
|
||||||
|
|
||||||
.interact-prompt__label {
|
.interact-prompt__label {
|
||||||
|
padding: 0 12px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: rgba(255, 255, 255, 0.85);
|
font-weight: 700;
|
||||||
letter-spacing: 0.03em;
|
letter-spacing: 0.02em;
|
||||||
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.repair-movement-lock-indicator {
|
.repair-movement-lock-indicator {
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ function completeEbikeState(state: GameState): GameStateUpdate {
|
|||||||
},
|
},
|
||||||
pylon: {
|
pylon: {
|
||||||
...state.pylon,
|
...state.pylon,
|
||||||
currentStep: "waiting",
|
currentStep: "approaching",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,10 @@ function completePylonState(state: GameState): GameStateUpdate {
|
|||||||
},
|
},
|
||||||
farm: {
|
farm: {
|
||||||
...state.farm,
|
...state.farm,
|
||||||
currentStep: "waiting",
|
// Farm starts at "locked" so FarmNarrativeFlow can auto-transition
|
||||||
|
// to "electricienne_history" and play the intro audio before the
|
||||||
|
// repair game begins.
|
||||||
|
currentStep: "locked",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -212,7 +215,7 @@ function advanceRepairMissionState(
|
|||||||
state: GameState,
|
state: GameState,
|
||||||
mission: RepairMissionId,
|
mission: RepairMissionId,
|
||||||
): GameStateUpdate {
|
): GameStateUpdate {
|
||||||
const nextStep = getNextMissionStep(state[mission].currentStep);
|
const nextStep = getNextMissionStep(state[mission].currentStep, mission);
|
||||||
if (nextStep === "done") {
|
if (nextStep === "done") {
|
||||||
return completeMissionState(state, mission);
|
return completeMissionState(state, mission);
|
||||||
}
|
}
|
||||||
@@ -227,7 +230,7 @@ function rewindRepairMissionState(
|
|||||||
return setMissionStepState(
|
return setMissionStepState(
|
||||||
state,
|
state,
|
||||||
mission,
|
mission,
|
||||||
getPreviousMissionStep(state[mission].currentStep),
|
getPreviousMissionStep(state[mission].currentStep, mission),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { create } from "zustand";
|
||||||
|
import type { Vector3Tuple } from "@/types/three/three";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tracks whether a repair mini-game is currently in its "focused" phase
|
||||||
|
* (fragmented / scanning / repairing / reassembling). When active, a dark
|
||||||
|
* sphere expands around the repair model to visually isolate the player
|
||||||
|
* from the rest of the map. The store also exposes the world-space center
|
||||||
|
* of the bubble so map content can dim/hide content outside it if needed.
|
||||||
|
*/
|
||||||
|
interface RepairFocusStore {
|
||||||
|
active: boolean;
|
||||||
|
center: Vector3Tuple;
|
||||||
|
setFocus: (active: boolean, center?: Vector3Tuple) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useRepairFocusStore = create<RepairFocusStore>((set) => ({
|
||||||
|
active: false,
|
||||||
|
center: [0, 0, 0],
|
||||||
|
setFocus: (active, center) =>
|
||||||
|
set((state) => ({
|
||||||
|
active,
|
||||||
|
center: center ?? state.center,
|
||||||
|
})),
|
||||||
|
}));
|
||||||
@@ -64,6 +64,13 @@ export interface RepairMissionConfig {
|
|||||||
description: string;
|
description: string;
|
||||||
modelPath: string;
|
modelPath: string;
|
||||||
modelScale?: ModelTransformProps["scale"];
|
modelScale?: ModelTransformProps["scale"];
|
||||||
|
/**
|
||||||
|
* World-space rotation applied to the model when mounted by RepairGame
|
||||||
|
* (fragmented + repairing steps). Should match the rotation used by the
|
||||||
|
* source object in the world (e.g. parked Ebike) so the fragmented model
|
||||||
|
* lines up visually with the inspection model.
|
||||||
|
*/
|
||||||
|
modelRotation?: Vector3Tuple;
|
||||||
stageUiPath: string;
|
stageUiPath: string;
|
||||||
interactUiPath: string;
|
interactUiPath: string;
|
||||||
brokenUiPath: string;
|
brokenUiPath: string;
|
||||||
@@ -83,10 +90,50 @@ export interface RepairMissionConfig {
|
|||||||
|
|
||||||
export type MissionStep =
|
export type MissionStep =
|
||||||
| "locked"
|
| "locked"
|
||||||
|
| "approaching"
|
||||||
|
| "arrived"
|
||||||
|
| "npc-return"
|
||||||
| "waiting"
|
| "waiting"
|
||||||
| "inspected"
|
| "inspected"
|
||||||
| "fragmented"
|
| "fragmented"
|
||||||
| "scanning"
|
| "scanning"
|
||||||
| "repairing"
|
| "repairing"
|
||||||
| "reassembling"
|
| "reassembling"
|
||||||
| "done";
|
| "done"
|
||||||
|
| "narrator-outro"
|
||||||
|
| "electricienne_history";
|
||||||
|
|
||||||
|
export const PYLON_NARRATIVE_STEPS = [
|
||||||
|
"approaching",
|
||||||
|
"arrived",
|
||||||
|
"npc-return",
|
||||||
|
"narrator-outro",
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
/** Farm-specific steps that bypass the repair-game flow. */
|
||||||
|
export const FARM_NARRATIVE_STEPS = [
|
||||||
|
"locked",
|
||||||
|
"electricienne_history",
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export const REPAIR_GAME_STEPS = [
|
||||||
|
"waiting",
|
||||||
|
"inspected",
|
||||||
|
"fragmented",
|
||||||
|
"scanning",
|
||||||
|
"repairing",
|
||||||
|
"reassembling",
|
||||||
|
"done",
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export function isPylonNarrativeStep(step: MissionStep): boolean {
|
||||||
|
return (PYLON_NARRATIVE_STEPS as readonly MissionStep[]).includes(step);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isFarmNarrativeStep(step: MissionStep): boolean {
|
||||||
|
return (FARM_NARRATIVE_STEPS as readonly MissionStep[]).includes(step);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isRepairGameStep(step: MissionStep): boolean {
|
||||||
|
return (REPAIR_GAME_STEPS as readonly MissionStep[]).includes(step);
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import type { Vector3Tuple } from "@/types/three/three";
|
||||||
|
|
||||||
|
export interface ZoneConfig {
|
||||||
|
id: string;
|
||||||
|
position: Vector3Tuple;
|
||||||
|
radius: number;
|
||||||
|
height: number;
|
||||||
|
oneShot: boolean;
|
||||||
|
}
|
||||||
@@ -11,6 +11,8 @@ export interface MapNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface MapNodeInstanceTransform {
|
export interface MapNodeInstanceTransform {
|
||||||
|
/** Node id from map.json — preserved so specific instances can be excluded at runtime. */
|
||||||
|
id?: string;
|
||||||
position: Vector3Tuple;
|
position: Vector3Tuple;
|
||||||
rotation: Vector3Tuple;
|
rotation: Vector3Tuple;
|
||||||
scale: Vector3Tuple;
|
scale: Vector3Tuple;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ export class Debug {
|
|||||||
fogEnabled: boolean;
|
fogEnabled: boolean;
|
||||||
handTrackingSource: HandTrackingSource;
|
handTrackingSource: HandTrackingSource;
|
||||||
showDebugOverlay: boolean;
|
showDebugOverlay: boolean;
|
||||||
showHandTrackingSvg: boolean;
|
showHandTrackingModel: boolean;
|
||||||
showInteractionSpheres: boolean;
|
showInteractionSpheres: boolean;
|
||||||
showPerf: boolean;
|
showPerf: boolean;
|
||||||
sceneMode: SceneMode;
|
sceneMode: SceneMode;
|
||||||
@@ -108,7 +108,7 @@ export class Debug {
|
|||||||
fogEnabled: FOG_CONFIG.enabled,
|
fogEnabled: FOG_CONFIG.enabled,
|
||||||
handTrackingSource: storedControls.handTrackingSource ?? "browser",
|
handTrackingSource: storedControls.handTrackingSource ?? "browser",
|
||||||
showDebugOverlay: true,
|
showDebugOverlay: true,
|
||||||
showHandTrackingSvg: false,
|
showHandTrackingModel: false,
|
||||||
showInteractionSpheres: false,
|
showInteractionSpheres: false,
|
||||||
showPerf: true,
|
showPerf: true,
|
||||||
sceneMode: storedControls.sceneMode ?? "game",
|
sceneMode: storedControls.sceneMode ?? "game",
|
||||||
@@ -156,10 +156,10 @@ export class Debug {
|
|||||||
const handTrackingFolder = this.createFolder("Hand Tracking");
|
const handTrackingFolder = this.createFolder("Hand Tracking");
|
||||||
|
|
||||||
handTrackingFolder
|
handTrackingFolder
|
||||||
?.add(this.controls, "showHandTrackingSvg")
|
?.add(this.controls, "showHandTrackingModel")
|
||||||
.name("Show SVG")
|
.name("Show Model")
|
||||||
.onChange((value: boolean) => {
|
.onChange((value: boolean) => {
|
||||||
this.controls.showHandTrackingSvg = value;
|
this.controls.showHandTrackingModel = value;
|
||||||
this.emit();
|
this.emit();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -281,12 +281,12 @@ export class Debug {
|
|||||||
return this.controls.showInteractionSpheres;
|
return this.controls.showInteractionSpheres;
|
||||||
}
|
}
|
||||||
|
|
||||||
getShowHandTrackingSvg(): boolean {
|
getShowHandTrackingModel(): boolean {
|
||||||
return this.controls.showHandTrackingSvg;
|
return this.controls.showHandTrackingModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
setShowHandTrackingSvg(value: boolean): void {
|
setShowHandTrackingModel(value: boolean): void {
|
||||||
this.controls.showHandTrackingSvg = value;
|
this.controls.showHandTrackingModel = value;
|
||||||
this.emit();
|
this.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export function mapNodeToInstanceTransform(
|
|||||||
node: MapNode,
|
node: MapNode,
|
||||||
): MapNodeInstanceTransform {
|
): MapNodeInstanceTransform {
|
||||||
return {
|
return {
|
||||||
|
id: node.id,
|
||||||
position: node.position,
|
position: node.position,
|
||||||
rotation: node.rotation,
|
rotation: node.rotation,
|
||||||
scale: node.scale,
|
scale: node.scale,
|
||||||
|
|||||||
@@ -53,13 +53,23 @@ export class ExplodedModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private createParts(model: THREE.Object3D): ExplodedPart[] {
|
private createParts(model: THREE.Object3D): ExplodedPart[] {
|
||||||
const root =
|
// Drill down through single-mesh-bearing branches until we find a node
|
||||||
model.children.length === 1 && model.children[0]
|
// with multiple mesh-bearing children (the natural "explosion group" the
|
||||||
? model.children[0]
|
// modeler authored). Falls back to flat mesh list only if no such group
|
||||||
: model;
|
// exists. This avoids exploding leaves in local space when wrapper nodes
|
||||||
const directChildren = root.children.filter((child) => hasMesh(child));
|
// (e.g. "Empty" + "Moto" > "Eclatement") sit above the actual group.
|
||||||
|
let current = model;
|
||||||
|
while (true) {
|
||||||
|
const meshChildren = current.children.filter((child) => hasMesh(child));
|
||||||
|
if (meshChildren.length === 1 && meshChildren[0]) {
|
||||||
|
current = meshChildren[0];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const directChildren = current.children.filter((child) => hasMesh(child));
|
||||||
const sourceObjects =
|
const sourceObjects =
|
||||||
directChildren.length > 1 ? directChildren : getMeshes(root);
|
directChildren.length > 1 ? directChildren : getMeshes(current);
|
||||||
|
|
||||||
if (sourceObjects.length === 0) return [];
|
if (sourceObjects.length === 0) return [];
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
isMapModelVisible,
|
isMapModelVisible,
|
||||||
useMapPerformanceStore,
|
useMapPerformanceStore,
|
||||||
} from "@/managers/stores/useMapPerformanceStore";
|
} from "@/managers/stores/useMapPerformanceStore";
|
||||||
|
import { useRepairFocusStore } from "@/managers/stores/useRepairFocusStore";
|
||||||
import { SkyModel } from "@/components/three/world/SkyModel";
|
import { SkyModel } from "@/components/three/world/SkyModel";
|
||||||
import { CloudSystem } from "@/world/clouds/CloudSystem";
|
import { CloudSystem } from "@/world/clouds/CloudSystem";
|
||||||
import { FogSystem } from "@/world/fog/FogSystem";
|
import { FogSystem } from "@/world/fog/FogSystem";
|
||||||
@@ -24,6 +25,9 @@ export function Environment(): React.JSX.Element {
|
|||||||
const groups = useMapPerformanceStore((state) => state.groups);
|
const groups = useMapPerformanceStore((state) => state.groups);
|
||||||
const models = useMapPerformanceStore((state) => state.models);
|
const models = useMapPerformanceStore((state) => state.models);
|
||||||
const showSky = isMapModelVisible("sky", { groups, models });
|
const showSky = isMapModelVisible("sky", { groups, models });
|
||||||
|
// Hide vegetation while the repair focus bubble is active so the cocoon
|
||||||
|
// shroud is not pierced by tall trees / bushes around the repair model.
|
||||||
|
const repairFocusActive = useRepairFocusStore((state) => state.active);
|
||||||
|
|
||||||
if (sceneMode === "physics") {
|
if (sceneMode === "physics") {
|
||||||
return (
|
return (
|
||||||
@@ -52,7 +56,7 @@ export function Environment(): React.JSX.Element {
|
|||||||
<WaterSystem />
|
<WaterSystem />
|
||||||
<CloudSystem />
|
<CloudSystem />
|
||||||
<GrassSystem />
|
<GrassSystem />
|
||||||
<VegetationSystem />
|
{repairFocusActive ? null : <VegetationSystem />}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,15 @@ function playCinematic(
|
|||||||
onUpdate: () => camera.lookAt(target),
|
onUpdate: () => camera.lookAt(target),
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
timelineRef.current = null;
|
timelineRef.current = null;
|
||||||
|
// During the outro the camera is intentionally left at its final
|
||||||
|
// position — don't release cinematic lock so the player camera system
|
||||||
|
// can't snap it back to the player's eye position.
|
||||||
|
const { mainState } = useGameStore.getState();
|
||||||
|
if (mainState === "outro") {
|
||||||
|
window.dispatchEvent(new CustomEvent("outro-cinematic-complete"));
|
||||||
|
} else {
|
||||||
useGameStore.getState().setCinematicPlaying(false);
|
useGameStore.getState().setCinematicPlaying(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -242,7 +250,10 @@ export function animateCameraTransformTransition(
|
|||||||
targetRotation: Vector3Tuple,
|
targetRotation: Vector3Tuple,
|
||||||
duration: number = 1,
|
duration: number = 1,
|
||||||
onComplete?: () => void,
|
onComplete?: () => void,
|
||||||
|
options: { lockInput?: boolean } = {},
|
||||||
): void {
|
): void {
|
||||||
|
const { lockInput = true } = options;
|
||||||
|
|
||||||
if (!globalCamera) {
|
if (!globalCamera) {
|
||||||
logger.warn("GameCinematics", "Camera not found for transition");
|
logger.warn("GameCinematics", "Camera not found for transition");
|
||||||
onComplete?.();
|
onComplete?.();
|
||||||
@@ -252,7 +263,9 @@ export function animateCameraTransformTransition(
|
|||||||
const camera = globalCamera;
|
const camera = globalCamera;
|
||||||
|
|
||||||
cameraTransitionTimeline?.kill();
|
cameraTransitionTimeline?.kill();
|
||||||
|
if (lockInput) {
|
||||||
useGameStore.getState().setCinematicPlaying(true);
|
useGameStore.getState().setCinematicPlaying(true);
|
||||||
|
}
|
||||||
|
|
||||||
// Convert target rotation in degrees to quaternion
|
// Convert target rotation in degrees to quaternion
|
||||||
const targetEuler = new THREE.Euler(
|
const targetEuler = new THREE.Euler(
|
||||||
@@ -274,7 +287,9 @@ export function animateCameraTransformTransition(
|
|||||||
},
|
},
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
cameraTransitionTimeline = null;
|
cameraTransitionTimeline = null;
|
||||||
|
if (lockInput) {
|
||||||
useGameStore.getState().setCinematicPlaying(false);
|
useGameStore.getState().setCinematicPlaying(false);
|
||||||
|
}
|
||||||
onComplete?.();
|
onComplete?.();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
import { Ebike } from "@/components/ebike/Ebike";
|
import { Ebike } from "@/components/ebike/Ebike";
|
||||||
import { InteractableObject } from "@/components/three/interaction/InteractableObject";
|
import { InteractableObject } from "@/components/three/interaction/InteractableObject";
|
||||||
|
import { RepairFocusBubble } from "@/components/three/gameplay/RepairFocusBubble";
|
||||||
import { RepairGame } from "@/components/three/gameplay/RepairGame";
|
import { RepairGame } from "@/components/three/gameplay/RepairGame";
|
||||||
|
import { FarmNarrativeFlow } from "@/components/gameplay/farm/FarmNarrativeFlow";
|
||||||
|
import { PylonDownedPylon } from "@/components/gameplay/pylon/PylonDownedPylon";
|
||||||
|
import { PylonLightingEffect } from "@/components/gameplay/pylon/PylonLightingEffect";
|
||||||
|
import { PylonNarrativeFlow } from "@/components/gameplay/pylon/PylonNarrativeFlow";
|
||||||
|
import { ZoneDebugVisual } from "@/components/zone/ZoneDetection";
|
||||||
|
import { PYLON_APPROACH_ZONE, PYLON_ARRIVED_ZONE } from "@/data/gameplay/zones";
|
||||||
|
import { isDebugEnabled } from "@/utils/debug/isDebugEnabled";
|
||||||
import {
|
import {
|
||||||
REPAIR_MISSION_POSITION_ENTRIES,
|
REPAIR_MISSION_POSITION_ENTRIES,
|
||||||
REPAIR_MISSION_TRIGGERS,
|
REPAIR_MISSION_TRIGGERS,
|
||||||
@@ -10,17 +18,16 @@ import {
|
|||||||
OUTRO_STAGE_ANCHOR,
|
OUTRO_STAGE_ANCHOR,
|
||||||
} from "@/data/gameplay/gameStageAnchors";
|
} from "@/data/gameplay/gameStageAnchors";
|
||||||
import { useGameStore } from "@/managers/stores/useGameStore";
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
|
import { useRepairFocusStore } from "@/managers/stores/useRepairFocusStore";
|
||||||
import { useRepairMissionAnchorStore } from "@/managers/stores/useRepairMissionAnchorStore";
|
import { useRepairMissionAnchorStore } from "@/managers/stores/useRepairMissionAnchorStore";
|
||||||
|
import {
|
||||||
|
isFarmNarrativeStep,
|
||||||
|
isPylonNarrativeStep,
|
||||||
|
} from "@/types/gameplay/repairMission";
|
||||||
import type { RepairMissionTriggerConfig } from "@/types/gameplay/repairMission";
|
import type { RepairMissionTriggerConfig } from "@/types/gameplay/repairMission";
|
||||||
import type { Vector3Tuple } from "@/types/three/three";
|
import type { Vector3Tuple } from "@/types/three/three";
|
||||||
import { getRepairMissionPosition } from "@/utils/gameplay/repairMissionPosition";
|
import { getRepairMissionPosition } from "@/utils/gameplay/repairMissionPosition";
|
||||||
import {
|
import { EBIKE_WORLD_POSITION } from "@/data/ebike/ebikeConfig";
|
||||||
EBIKE_WORLD_POSITION,
|
|
||||||
EBIKE_WORLD_ROTATION_Y,
|
|
||||||
EBIKE_WORLD_SCALE,
|
|
||||||
} from "@/data/ebike/ebikeConfig";
|
|
||||||
|
|
||||||
const EBIKE_CONFIG_KEY = `${EBIKE_WORLD_POSITION.join(",")}:${EBIKE_WORLD_ROTATION_Y}:${EBIKE_WORLD_SCALE}`;
|
|
||||||
|
|
||||||
interface StageAnchorProps {
|
interface StageAnchorProps {
|
||||||
color: string;
|
color: string;
|
||||||
@@ -83,15 +90,36 @@ function RepairMissionTrigger({
|
|||||||
|
|
||||||
export function GameStageContent(): React.JSX.Element {
|
export function GameStageContent(): React.JSX.Element {
|
||||||
const mainState = useGameStore((state) => state.mainState);
|
const mainState = useGameStore((state) => state.mainState);
|
||||||
|
const pylonStep = useGameStore((state) => state.pylon.currentStep);
|
||||||
const anchors = useRepairMissionAnchorStore((state) => state.anchors);
|
const anchors = useRepairMissionAnchorStore((state) => state.anchors);
|
||||||
|
const repairFocusActive = useRepairFocusStore((state) => state.active);
|
||||||
|
|
||||||
|
const farmStep = useGameStore((state) => state.farm.currentStep);
|
||||||
|
|
||||||
|
const pylonInNarrative =
|
||||||
|
mainState === "pylon" && isPylonNarrativeStep(pylonStep);
|
||||||
|
const farmInNarrative =
|
||||||
|
mainState === "farm" && isFarmNarrativeStep(farmStep);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{mainState === "intro" ? <StageAnchor {...INTRO_STAGE_ANCHOR} /> : null}
|
{mainState === "intro" ? <StageAnchor {...INTRO_STAGE_ANCHOR} /> : null}
|
||||||
<Ebike key={EBIKE_CONFIG_KEY} position={EBIKE_WORLD_POSITION} />
|
<Ebike position={EBIKE_WORLD_POSITION} />
|
||||||
|
<PylonLightingEffect />
|
||||||
|
<PylonDownedPylon />
|
||||||
|
{isDebugEnabled() && !repairFocusActive ? (
|
||||||
|
<>
|
||||||
|
<ZoneDebugVisual zone={PYLON_APPROACH_ZONE} active={false} />
|
||||||
|
<ZoneDebugVisual zone={PYLON_ARRIVED_ZONE} active={false} />
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
{mainState === "pylon" ? <PylonNarrativeFlow /> : null}
|
||||||
|
{mainState === "farm" ? <FarmNarrativeFlow /> : null}
|
||||||
{REPAIR_MISSION_POSITION_ENTRIES.map(({ mission }) => {
|
{REPAIR_MISSION_POSITION_ENTRIES.map(({ mission }) => {
|
||||||
const position = getRepairMissionPosition(mission, anchors);
|
const position = getRepairMissionPosition(mission, anchors);
|
||||||
if (!position) return null;
|
if (!position) return null;
|
||||||
|
if (mission === "pylon" && pylonInNarrative) return null;
|
||||||
|
if (mission === "farm" && farmInNarrative) return null;
|
||||||
return (
|
return (
|
||||||
<RepairGame key={mission} mission={mission} position={position} />
|
<RepairGame key={mission} mission={mission} position={position} />
|
||||||
);
|
);
|
||||||
@@ -100,6 +128,7 @@ export function GameStageContent(): React.JSX.Element {
|
|||||||
<RepairMissionTrigger key={config.mission} config={config} />
|
<RepairMissionTrigger key={config.mission} config={config} />
|
||||||
))}
|
))}
|
||||||
{mainState === "outro" ? <StageAnchor {...OUTRO_STAGE_ANCHOR} /> : null}
|
{mainState === "outro" ? <StageAnchor {...OUTRO_STAGE_ANCHOR} /> : null}
|
||||||
|
<RepairFocusBubble />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-3
@@ -6,9 +6,11 @@ import {
|
|||||||
} from "@/data/player/playerConfig";
|
} from "@/data/player/playerConfig";
|
||||||
import { LA_FABRIK_INITIAL_LOOK_AT } from "@/data/world/laFabrikConfig";
|
import { LA_FABRIK_INITIAL_LOOK_AT } from "@/data/world/laFabrikConfig";
|
||||||
import { useCameraMode } from "@/hooks/debug/useCameraMode";
|
import { useCameraMode } from "@/hooks/debug/useCameraMode";
|
||||||
|
import { useDebugStore } from "@/hooks/debug/useDebugStore";
|
||||||
import { useEnvironmentDebug } from "@/hooks/debug/useEnvironmentDebug";
|
import { useEnvironmentDebug } from "@/hooks/debug/useEnvironmentDebug";
|
||||||
import { useMapPerformanceDebug } from "@/hooks/debug/useMapPerformanceDebug";
|
import { useMapPerformanceDebug } from "@/hooks/debug/useMapPerformanceDebug";
|
||||||
import { useCharacterDebug } from "@/hooks/debug/useCharacterDebug";
|
import { useCharacterDebug } from "@/hooks/debug/useCharacterDebug";
|
||||||
|
import { usePlayerPositionDebug } from "@/hooks/debug/usePlayerPositionDebug";
|
||||||
import { useDebugVisualsDebug } from "@/hooks/debug/useDebugVisualsDebug";
|
import { useDebugVisualsDebug } from "@/hooks/debug/useDebugVisualsDebug";
|
||||||
import { useSceneMode } from "@/hooks/debug/useSceneMode";
|
import { useSceneMode } from "@/hooks/debug/useSceneMode";
|
||||||
import { useHandTrackingSnapshot } from "@/hooks/handTracking/useHandTrackingSnapshot";
|
import { useHandTrackingSnapshot } from "@/hooks/handTracking/useHandTrackingSnapshot";
|
||||||
@@ -31,7 +33,6 @@ import { CharacterSystem } from "@/world/characters/CharacterSystem";
|
|||||||
import { Player } from "@/world/player/Player";
|
import { Player } from "@/world/player/Player";
|
||||||
import { TestMap } from "@/world/debug/TestMap";
|
import { TestMap } from "@/world/debug/TestMap";
|
||||||
import type { SceneLoadingChangeHandler } from "@/types/world/sceneLoading";
|
import type { SceneLoadingChangeHandler } from "@/types/world/sceneLoading";
|
||||||
import type { HandTrackingGloveHandedness } from "@/hooks/handTracking/useHandTrackingGloveStatus";
|
|
||||||
import type { HandTrackingHand } from "@/types/handTracking/handTracking";
|
import type { HandTrackingHand } from "@/types/handTracking/handTracking";
|
||||||
|
|
||||||
interface WorldProps {
|
interface WorldProps {
|
||||||
@@ -40,7 +41,7 @@ interface WorldProps {
|
|||||||
|
|
||||||
function hasTrackedHand(
|
function hasTrackedHand(
|
||||||
hands: HandTrackingHand[],
|
hands: HandTrackingHand[],
|
||||||
handedness: HandTrackingGloveHandedness,
|
handedness: "left" | "right",
|
||||||
): boolean {
|
): boolean {
|
||||||
return hands.some((hand) => hand.handedness.toLowerCase() === handedness);
|
return hands.some((hand) => hand.handedness.toLowerCase() === handedness);
|
||||||
}
|
}
|
||||||
@@ -49,6 +50,7 @@ export function World({ onLoadingStateChange }: WorldProps): React.JSX.Element {
|
|||||||
useEnvironmentDebug();
|
useEnvironmentDebug();
|
||||||
useMapPerformanceDebug();
|
useMapPerformanceDebug();
|
||||||
useCharacterDebug();
|
useCharacterDebug();
|
||||||
|
usePlayerPositionDebug();
|
||||||
useDebugVisualsDebug();
|
useDebugVisualsDebug();
|
||||||
|
|
||||||
const cameraMode = useCameraMode();
|
const cameraMode = useCameraMode();
|
||||||
@@ -58,6 +60,9 @@ export function World({ onLoadingStateChange }: WorldProps): React.JSX.Element {
|
|||||||
(state) => state.showPlayerModel,
|
(state) => state.showPlayerModel,
|
||||||
);
|
);
|
||||||
const showDebugOctree = useDebugVisualsStore((state) => state.showOctree);
|
const showDebugOctree = useDebugVisualsStore((state) => state.showOctree);
|
||||||
|
const showHandTrackingModel = useDebugStore((debug) =>
|
||||||
|
debug.getShowHandTrackingModel(),
|
||||||
|
);
|
||||||
const { hands, status, usageStatus } = useHandTrackingSnapshot();
|
const { hands, status, usageStatus } = useHandTrackingSnapshot();
|
||||||
const {
|
const {
|
||||||
octree,
|
octree,
|
||||||
@@ -72,7 +77,10 @@ export function World({ onLoadingStateChange }: WorldProps): React.JSX.Element {
|
|||||||
? PLAYER_SPAWN_POSITION_GAME
|
? PLAYER_SPAWN_POSITION_GAME
|
||||||
: PLAYER_SPAWN_POSITION_PHYSICS;
|
: PLAYER_SPAWN_POSITION_PHYSICS;
|
||||||
const showHandTrackingGloves =
|
const showHandTrackingGloves =
|
||||||
status === "connected" && usageStatus !== "inactive" && hands.length > 0;
|
showHandTrackingModel &&
|
||||||
|
status === "connected" &&
|
||||||
|
usageStatus !== "inactive" &&
|
||||||
|
hands.length > 0;
|
||||||
const showLeftHandTrackingGlove =
|
const showLeftHandTrackingGlove =
|
||||||
showHandTrackingGloves && hasTrackedHand(hands, "left");
|
showHandTrackingGloves && hasTrackedHand(hands, "left");
|
||||||
const showRightHandTrackingGlove =
|
const showRightHandTrackingGlove =
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import { Component, useRef, useState, useEffect } from "react";
|
|||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import { Physics, RigidBody, CuboidCollider } from "@react-three/rapier";
|
import { Physics, RigidBody, CuboidCollider } from "@react-three/rapier";
|
||||||
import { Line } from "@react-three/drei";
|
import { Line } from "@react-three/drei";
|
||||||
|
import { Ebike } from "@/components/ebike/Ebike";
|
||||||
import { RepairGame } from "@/components/three/gameplay/RepairGame";
|
import { RepairGame } from "@/components/three/gameplay/RepairGame";
|
||||||
|
import { RepairFocusBubble } from "@/components/three/gameplay/RepairFocusBubble";
|
||||||
import { GrabbableObject } from "@/components/three/interaction/GrabbableObject";
|
import { GrabbableObject } from "@/components/three/interaction/GrabbableObject";
|
||||||
import { AnimatedModel } from "@/components/three/models/AnimatedModel";
|
import { AnimatedModel } from "@/components/three/models/AnimatedModel";
|
||||||
import { TriggerObject } from "@/components/three/interaction/TriggerObject";
|
import { TriggerObject } from "@/components/three/interaction/TriggerObject";
|
||||||
@@ -239,11 +241,16 @@ export function TestMap({ onOctreeReady }: TestMapProps): React.JSX.Element {
|
|||||||
<group position={zone.position}>
|
<group position={zone.position}>
|
||||||
<RepairPlaygroundZoneMarker color={zone.color} />
|
<RepairPlaygroundZoneMarker color={zone.color} />
|
||||||
</group>
|
</group>
|
||||||
|
{zone.mission === "ebike" ? (
|
||||||
|
<Ebike position={zone.position} snapToTerrain={false} />
|
||||||
|
) : null}
|
||||||
<RepairGame mission={zone.mission} position={zone.position} />
|
<RepairGame mission={zone.mission} position={zone.position} />
|
||||||
</group>
|
</group>
|
||||||
))}
|
))}
|
||||||
</Physics>
|
</Physics>
|
||||||
|
|
||||||
|
<RepairFocusBubble />
|
||||||
|
|
||||||
{/* Dynamic Futuristic 3D GPS Dashboard Preview */}
|
{/* Dynamic Futuristic 3D GPS Dashboard Preview */}
|
||||||
<group
|
<group
|
||||||
position={TEST_SCENE_GPS_PREVIEW_POSITION}
|
position={TEST_SCENE_GPS_PREVIEW_POSITION}
|
||||||
@@ -264,7 +271,7 @@ export function TestMap({ onOctreeReady }: TestMapProps): React.JSX.Element {
|
|||||||
</mesh>
|
</mesh>
|
||||||
*/}
|
*/}
|
||||||
{/* GPS Map screen plane */}
|
{/* GPS Map screen plane */}
|
||||||
<group position={[0, 0, 0.06]}>
|
<group position={[0, -8, 0.06]}>
|
||||||
<EbikeGPSMap
|
<EbikeGPSMap
|
||||||
width={4}
|
width={4}
|
||||||
height={4}
|
height={4}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
isMapModelVisible,
|
isMapModelVisible,
|
||||||
useMapPerformanceStore,
|
useMapPerformanceStore,
|
||||||
} from "@/managers/stores/useMapPerformanceStore";
|
} from "@/managers/stores/useMapPerformanceStore";
|
||||||
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
import { InstancedMapAsset } from "@/world/map-instancing/InstancedMapAsset";
|
import { InstancedMapAsset } from "@/world/map-instancing/InstancedMapAsset";
|
||||||
import {
|
import {
|
||||||
MAP_INSTANCING_ASSETS,
|
MAP_INSTANCING_ASSETS,
|
||||||
@@ -27,6 +28,8 @@ import {
|
|||||||
type MapInstancingAssetConfig,
|
type MapInstancingAssetConfig,
|
||||||
type MapInstancingAssetType,
|
type MapInstancingAssetType,
|
||||||
} from "@/data/world/mapInstancingConfig";
|
} from "@/data/world/mapInstancingConfig";
|
||||||
|
import { REPAIR_MISSION_ANCHOR_IDS } from "@/data/gameplay/repairMissionAnchors";
|
||||||
|
import { isRepairGameStep } from "@/types/gameplay/repairMission";
|
||||||
import { useMapInstancingData } from "@/hooks/world/useMapInstancingData";
|
import { useMapInstancingData } from "@/hooks/world/useMapInstancingData";
|
||||||
import type { MapAssetInstance } from "@/types/map/mapScene";
|
import type { MapAssetInstance } from "@/types/map/mapScene";
|
||||||
import type { GraphicsPreset } from "@/data/world/graphicsConfig";
|
import type { GraphicsPreset } from "@/data/world/graphicsConfig";
|
||||||
@@ -146,6 +149,8 @@ export function MapInstancingSystem({
|
|||||||
const groups = useMapPerformanceStore((state) => state.groups);
|
const groups = useMapPerformanceStore((state) => state.groups);
|
||||||
const models = useMapPerformanceStore((state) => state.models);
|
const models = useMapPerformanceStore((state) => state.models);
|
||||||
const { data, isLoading } = useMapInstancingData();
|
const { data, isLoading } = useMapInstancingData();
|
||||||
|
const mainState = useGameStore((state) => state.mainState);
|
||||||
|
const pylonStep = useGameStore((state) => state.pylon.currentStep);
|
||||||
const streamingEnabled =
|
const streamingEnabled =
|
||||||
streaming &&
|
streaming &&
|
||||||
CHUNK_CONFIG.enabled &&
|
CHUNK_CONFIG.enabled &&
|
||||||
@@ -153,6 +158,15 @@ export function MapInstancingSystem({
|
|||||||
sceneMode === "game" &&
|
sceneMode === "game" &&
|
||||||
cameraMode === "player";
|
cameraMode === "player";
|
||||||
|
|
||||||
|
// During the pylon narrative phase (before the pylon is raised), hide the
|
||||||
|
// repair:pylon instanced mesh so the PylonDownedPylon component takes its place.
|
||||||
|
// Once the pylon is raised (repair-game steps), restore it so the normal model
|
||||||
|
// appears upright in the world while the repair mini-game runs.
|
||||||
|
const hidePylonAnchorId =
|
||||||
|
mainState === "pylon" && !isRepairGameStep(pylonStep)
|
||||||
|
? REPAIR_MISSION_ANCHOR_IDS.pylon
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const chunks = useMemo(() => {
|
const chunks = useMemo(() => {
|
||||||
if (!data) return [];
|
if (!data) return [];
|
||||||
|
|
||||||
@@ -168,12 +182,18 @@ export function MapInstancingSystem({
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const instances = data.get(type);
|
let instances = data.get(type);
|
||||||
if (!instances || instances.length === 0) return [];
|
if (!instances || instances.length === 0) return [];
|
||||||
|
|
||||||
|
// Filter out the repair-mission pylon instance during the narrative phase
|
||||||
|
if (hidePylonAnchorId && config.mapName === "pylone") {
|
||||||
|
instances = instances.filter((inst) => inst.id !== hidePylonAnchorId);
|
||||||
|
if (instances.length === 0) return [];
|
||||||
|
}
|
||||||
|
|
||||||
return createMapAssetChunks(type, config, instances);
|
return createMapAssetChunks(type, config, instances);
|
||||||
});
|
});
|
||||||
}, [data, groups, models, onlyMapName]);
|
}, [data, groups, models, onlyMapName, hidePylonAnchorId]);
|
||||||
|
|
||||||
const visibleChunks = useVisibleWorldChunks(chunks, streamingEnabled, {
|
const visibleChunks = useVisibleWorldChunks(chunks, streamingEnabled, {
|
||||||
loadRadius: graphicsPresetConfig.chunkLoadRadius,
|
loadRadius: graphicsPresetConfig.chunkLoadRadius,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import {
|
|||||||
PLAYER_MAX_DELTA,
|
PLAYER_MAX_DELTA,
|
||||||
PLAYER_XZ_DAMPING_FACTOR,
|
PLAYER_XZ_DAMPING_FACTOR,
|
||||||
} from "@/data/player/playerConfig";
|
} from "@/data/player/playerConfig";
|
||||||
import { useRepairMovementLocked } from "@/hooks/gameplay/useRepairMovementLocked";
|
|
||||||
import { useTerrainHeightSampler } from "@/hooks/three/useTerrainHeight";
|
import { useTerrainHeightSampler } from "@/hooks/three/useTerrainHeight";
|
||||||
import { InteractionManager } from "@/managers/InteractionManager";
|
import { InteractionManager } from "@/managers/InteractionManager";
|
||||||
import { useGameStore } from "@/managers/stores/useGameStore";
|
import { useGameStore } from "@/managers/stores/useGameStore";
|
||||||
@@ -154,9 +153,7 @@ export function PlayerController({
|
|||||||
}: PlayerControllerProps): null {
|
}: PlayerControllerProps): null {
|
||||||
const camera = useThree((state) => state.camera);
|
const camera = useThree((state) => state.camera);
|
||||||
const sceneMode = useSceneMode();
|
const sceneMode = useSceneMode();
|
||||||
const movementLocked = useRepairMovementLocked();
|
|
||||||
const terrainHeight = useTerrainHeightSampler();
|
const terrainHeight = useTerrainHeightSampler();
|
||||||
const movementLockedRef = useRef(movementLocked);
|
|
||||||
const keys = useRef<Keys>({ ...DEFAULT_KEYS });
|
const keys = useRef<Keys>({ ...DEFAULT_KEYS });
|
||||||
const velocity = useRef(new THREE.Vector3());
|
const velocity = useRef(new THREE.Vector3());
|
||||||
const fallDuration = useRef(0);
|
const fallDuration = useRef(0);
|
||||||
@@ -249,17 +246,6 @@ export function PlayerController({
|
|||||||
initializedRef.current = true;
|
initializedRef.current = true;
|
||||||
}, [camera, initialLookAt, spawnPosition]);
|
}, [camera, initialLookAt, spawnPosition]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
movementLockedRef.current = movementLocked;
|
|
||||||
|
|
||||||
if (!movementLocked) return;
|
|
||||||
|
|
||||||
keys.current = { ...DEFAULT_KEYS };
|
|
||||||
wantsJump.current = false;
|
|
||||||
velocity.current.setX(0);
|
|
||||||
velocity.current.setZ(0);
|
|
||||||
}, [movementLocked]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const interaction = InteractionManager.getInstance();
|
const interaction = InteractionManager.getInstance();
|
||||||
|
|
||||||
@@ -267,20 +253,11 @@ export function PlayerController({
|
|||||||
if (isPlayerInputLocked()) return;
|
if (isPlayerInputLocked()) return;
|
||||||
|
|
||||||
if (setMovementKey(keys.current, event.key, true)) {
|
if (setMovementKey(keys.current, event.key, true)) {
|
||||||
if (movementLockedRef.current) {
|
|
||||||
keys.current = { ...DEFAULT_KEYS };
|
|
||||||
}
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === JUMP_KEY) {
|
if (event.key === JUMP_KEY) {
|
||||||
if (movementLockedRef.current) {
|
|
||||||
wantsJump.current = false;
|
|
||||||
event.preventDefault();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wantsJump.current = true;
|
wantsJump.current = true;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return;
|
return;
|
||||||
@@ -386,7 +363,7 @@ export function PlayerController({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_wishDir.set(0, 0, 0);
|
_wishDir.set(0, 0, 0);
|
||||||
if (!movementLocked && !isEbikeBreakdown) {
|
if (!isEbikeBreakdown) {
|
||||||
if (keys.current.forward) _wishDir.add(_forward);
|
if (keys.current.forward) _wishDir.add(_forward);
|
||||||
if (keys.current.backward) _wishDir.sub(_forward);
|
if (keys.current.backward) _wishDir.sub(_forward);
|
||||||
if (!isEbikeMounted) {
|
if (!isEbikeMounted) {
|
||||||
|
|||||||
Reference in New Issue
Block a user