1
0

fix speed camera

This commit is contained in:
2026-03-07 17:10:49 +09:00
parent 9344b9ddc3
commit e16678bd08

View File

@@ -49,7 +49,7 @@ function RotatingStage({ children, speed }) {
// マウス操作検知用の共有状態 // マウス操作検知用の共有状態
const userInteracting = { active: false, timeout: null }; const userInteracting = { active: false, timeout: null };
function CameraBreathing() { function CameraBreathing({ speed }) {
const arrivedRef = useRef(false); const arrivedRef = useRef(false);
useFrame(({ camera, clock }) => { useFrame(({ camera, clock }) => {
@@ -65,7 +65,8 @@ function CameraBreathing() {
// マウス操作中は止める // マウス操作中は止める
if (userInteracting.active) return; if (userInteracting.active) return;
const t = clock.getElapsedTime() * BREATH_SPEED; const breathSpeed = speed != null ? speed * 7 : BREATH_SPEED;
const t = clock.getElapsedTime() * breathSpeed;
const range = (BREATH_FAR - BREATH_NEAR) / 2; const range = (BREATH_FAR - BREATH_NEAR) / 2;
const center = BREATH_NEAR + range; const center = BREATH_NEAR + range;
const dist = center + Math.sin(t) * range; const dist = center + Math.sin(t) * range;
@@ -134,7 +135,7 @@ export default function AvatarScene({ selectedAnimation: animState, onZoomOut, c
<Canvas gl={{ alpha: true, antialias: true }}> <Canvas gl={{ alpha: true, antialias: true }}>
<PerspectiveCamera makeDefault position={CAM_INITIAL_POS} fov={CAM_FOV} /> <PerspectiveCamera makeDefault position={CAM_INITIAL_POS} fov={CAM_FOV} />
<CameraSync /> <CameraSync />
<CameraBreathing /> <CameraBreathing speed={camSpeedProp} />
<CameraDistanceMonitor onDistanceChange={(d) => { <CameraDistanceMonitor onDistanceChange={(d) => {
if (d > ZOOM_OUT_THRESHOLD) onZoomOut?.(); if (d > ZOOM_OUT_THRESHOLD) onZoomOut?.();
}} /> }} />