fix(ebike): sync parked position from config

This commit is contained in:
Tom Boullay
2026-06-01 01:32:29 +02:00
parent aa2d411b0c
commit 597ebcfbd4
3 changed files with 29 additions and 12 deletions
+18 -7
View File
@@ -10,7 +10,6 @@ import { useDebugFolder } from "@/hooks/debug/useDebugFolder";
import { useEbikeSounds } from "@/hooks/ebike/useEbikeSounds"; import { useEbikeSounds } from "@/hooks/ebike/useEbikeSounds";
import { animateCameraTransformTransition } from "@/world/GameCinematics"; import { animateCameraTransformTransition } from "@/world/GameCinematics";
import { useGameStore } from "@/managers/stores/useGameStore"; import { useGameStore } from "@/managers/stores/useGameStore";
import { PLAYER_EYE_HEIGHT } from "@/data/player/playerConfig";
import { import {
EBIKE_CAMERA_TRANSFORM, EBIKE_CAMERA_TRANSFORM,
EBIKE_DROP_PLAYER_TRANSFORM, EBIKE_DROP_PLAYER_TRANSFORM,
@@ -76,7 +75,7 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
// Use ref for internal state, and state for debug visualization (to avoid ref access during render) // Use ref for internal state, and state for debug visualization (to avoid ref access during render)
const restingPositionRef = useRef<Vector3Tuple>([ const restingPositionRef = useRef<Vector3Tuple>([
position[0], position[0],
position[1] - PLAYER_EYE_HEIGHT, position[1],
position[2], position[2],
]); ]);
const restingRotationRef = useRef<number>(EBIKE_WORLD_ROTATION_Y); const restingRotationRef = useRef<number>(EBIKE_WORLD_ROTATION_Y);
@@ -85,11 +84,23 @@ 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] = const [debugRestingPosition, setDebugRestingPosition] =
useState<Vector3Tuple>([ useState<Vector3Tuple>([position[0], position[1], position[2]]);
position[0],
position[1] - PLAYER_EYE_HEIGHT, useEffect(() => {
position[2], if (movementMode === "ebike") return;
]);
restingPositionRef.current = position;
restingRotationRef.current = EBIKE_WORLD_ROTATION_Y;
lastGpsUpdatePos.current.set(...position);
if (groupRef.current) {
groupRef.current.position.set(...position);
groupRef.current.rotation.set(0, EBIKE_WORLD_ROTATION_Y, 0);
}
window.ebikeParkedPosition = position;
window.ebikeParkedRotation = EBIKE_WORLD_ROTATION_Y;
}, [movementMode, position]);
useEffect(() => { useEffect(() => {
if (model) { if (model) {
+3 -3
View File
@@ -15,9 +15,9 @@ export const EBIKE_DROP_PLAYER_TRANSFORM: CameraTransform = {
rotation: [0, 0, 0], rotation: [0, 0, 0],
}; };
export const EBIKE_WORLD_POSITION: Vector3Tuple = [55.8, 1.75, 60.2]; export const EBIKE_WORLD_POSITION: Vector3Tuple = [57.9, 6.3, 58.35];
export const EBIKE_WORLD_ROTATION_Y = 2.4107; export const EBIKE_WORLD_ROTATION_Y = -2.5;
export const EBIKE_WORLD_SCALE = 0.25; export const EBIKE_WORLD_SCALE = 0.35;
export const EBIKE_INTRO_BREAKDOWN_DISTANCE = 15; export const EBIKE_INTRO_BREAKDOWN_DISTANCE = 15;
export const EBIKE_BREAKDOWN_DIALOGUE_DELAY_MS = 250; export const EBIKE_BREAKDOWN_DIALOGUE_DELAY_MS = 250;
+8 -2
View File
@@ -14,7 +14,13 @@ import { useRepairMissionAnchorStore } from "@/managers/stores/useRepairMissionA
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 { EBIKE_WORLD_POSITION } from "@/data/ebike/ebikeConfig"; import {
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;
@@ -82,7 +88,7 @@ export function GameStageContent(): React.JSX.Element {
return ( return (
<> <>
{mainState === "intro" ? <StageAnchor {...INTRO_STAGE_ANCHOR} /> : null} {mainState === "intro" ? <StageAnchor {...INTRO_STAGE_ANCHOR} /> : null}
<Ebike position={EBIKE_WORLD_POSITION} /> <Ebike key={EBIKE_CONFIG_KEY} position={EBIKE_WORLD_POSITION} />
{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;