fix(repair-ebike): stop subtitle leak and fake cooling swap
🔍 Lint / 🪄 Check lint (push) Has been cancelled
🔍 Lint / 🎨 Check format (push) Has been cancelled
🔍 Lint / 🔎 Typecheck (push) Has been cancelled
📊 Quality / 🔒 Security Audit (push) Has been cancelled
📊 Quality / 📋 Dependency Freshness (push) Has been cancelled
📊 Quality / 📦 Bundle Size (push) Has been cancelled
🔍 Lint / 🏗 Build (push) Has been cancelled

This commit is contained in:
Tom Boullay
2026-06-03 06:47:10 +02:00
parent 8d66391fa9
commit 08c10acd48
6 changed files with 114 additions and 23 deletions
@@ -1,34 +1,85 @@
import { useState } from "react";
import { GrabbableObject } from "@/components/three/interaction/GrabbableObject";
import { TriggerObject } from "@/components/three/interaction/TriggerObject";
import { RepairObjectModel } from "@/components/three/gameplay/RepairObjectModel";
import { REPAIR_INTERACTION_RADIUS } from "@/data/gameplay/repairGameConfig";
import type { Vector3Tuple } from "@/types/three/three";
interface RepairEbikeRepairTriggerProps {
anchor: Vector3Tuple;
onRepair: () => void;
}
const TRIGGER_POSITION: Vector3Tuple = [0, 1.4, 0];
const REPLACEMENT_MODEL_PATH = "/models/refroidisseur/model.gltf";
const TRIGGER_OFFSET: Vector3Tuple = [0, 0.9, 0];
/**
* Minimal interactable used for the ebike `repairing` step. Replaces
* the heavier RepairRepairingStep (grabbable parts + placeholder
* circles) with a single "Changez le refroidisseur" prompt. The
* collider is invisible — the player just walks up and presses E.
* Ebike-specific fake replacement flow: the broken radiator node is
* hidden in the shared ExplodableModel, a grabbable copy appears at the
* same anchor, then pressing E respawns a fresh part with a halo before
* the reassembly step starts.
*/
export function RepairEbikeRepairTrigger({
anchor,
onRepair,
}: RepairEbikeRepairTriggerProps): React.JSX.Element {
const [isInstalled, setIsInstalled] = useState(false);
function handleRepair(): void {
if (isInstalled) return;
setIsInstalled(true);
window.setTimeout(onRepair, 450);
}
return (
<TriggerObject
position={TRIGGER_POSITION}
colliders="ball"
label="Changez le refroidisseur"
radius={REPAIR_INTERACTION_RADIUS}
onTrigger={onRepair}
>
<mesh>
<sphereGeometry args={[0.6, 16, 16]} />
<meshBasicMaterial colorWrite={false} depthWrite={false} />
</mesh>
</TriggerObject>
<group>
{!isInstalled ? (
<GrabbableObject
position={anchor}
colliders="ball"
handControlled
label="Retirer le refroidisseur"
>
<RepairObjectModel
label="Refroidisseur"
modelPath={REPLACEMENT_MODEL_PATH}
scale={0.24}
/>
</GrabbableObject>
) : (
<group position={anchor}>
<RepairObjectModel
label="Refroidisseur"
modelPath={REPLACEMENT_MODEL_PATH}
scale={0.24}
/>
<mesh>
<sphereGeometry args={[0.65, 32, 16]} />
<meshBasicMaterial color="#22c55e" transparent opacity={0.18} />
</mesh>
<mesh rotation={[Math.PI / 2, 0, 0]}>
<torusGeometry args={[0.72, 0.025, 8, 96]} />
<meshBasicMaterial color="#86efac" transparent opacity={0.85} />
</mesh>
</group>
)}
<TriggerObject
position={[
anchor[0] + TRIGGER_OFFSET[0],
anchor[1] + TRIGGER_OFFSET[1],
anchor[2] + TRIGGER_OFFSET[2],
]}
colliders="ball"
label="Changez le refroidisseur"
radius={REPAIR_INTERACTION_RADIUS}
onTrigger={handleRepair}
>
<mesh>
<sphereGeometry args={[0.55, 16, 16]} />
<meshBasicMaterial colorWrite={false} depthWrite={false} />
</mesh>
</TriggerObject>
</group>
);
}