From 345b6176d2e3aeb10f55fba15bd251a1b1fb60ce Mon Sep 17 00:00:00 2001 From: syui Date: Fri, 21 Nov 2025 20:12:50 +0900 Subject: [PATCH] fix --- atmosphere/src/App.jsx | 76 ++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/atmosphere/src/App.jsx b/atmosphere/src/App.jsx index 031a851b1..722dd77e6 100644 --- a/atmosphere/src/App.jsx +++ b/atmosphere/src/App.jsx @@ -67,11 +67,9 @@ const WEATHER_PRESETS = [ } ]; -// --- Locations --- -// --- Locations --- const LOCATIONS = [ - { name: 'Tokyo', longitude: 139.7671, latitude: 35.6812, heading: 180, pitch: -5, distance: 300 }, - { name: 'Fuji', longitude: 138.7278, latitude: 35.3606, heading: 0, pitch: -10, distance: 4000 }, + { name: 'Tokyo', longitude: 139.7671, latitude: 35.6812, heading: 180, pitch: -5, distance: 1100 }, + { name: 'Fuji', longitude: 138.7278, latitude: 35.3206, heading: 0, pitch: -10, distance: 4000 }, { name: 'Space', longitude: 139.7671, latitude: 35.6812, heading: 0, pitch: -90, distance: 100000 }, ]; @@ -79,7 +77,7 @@ const LOCATIONS = [ // 複数のCanvas間で状態を共有するための簡易ストア const worldState = { // 世界座標 (Atmosphere内での位置 - ECEF) - position: new Vector3(0, EARTH_RADIUS + 2000, 0), + position: new Vector3(0, EARTH_RADIUS + 100000, 0), // ローカル回転 (AvatarLayerでの回転 - Y-up) // Note: This is treated as the "Local" quaternion. quaternion: new Quaternion(), @@ -233,35 +231,55 @@ function AtmosphereScene() { }, []); // 3. 時間進行と太陽移動 (Canvas内なのでuseFrameが使える) - useFrame((state, delta) => { - const currentDate = dateRef.current; - const elapsedMs = delta * TIME_SCALE * 1000; - currentDate.setTime(currentDate.getTime() + elapsedMs); - if (atmosphereRef.current) { - atmosphereRef.current.updateByDate(currentDate); - } - if (sunRef.current) { - const hours = currentDate.getHours() + currentDate.getMinutes() / 60 + currentDate.getSeconds() / 3600; - const sunAngle = MathUtils.mapLinear(hours, 6, 18, 0, Math.PI); - const sunX = -Math.cos(sunAngle); - const sunY = Math.sin(sunAngle); + //useFrame((state, delta) => { + // const currentDate = dateRef.current; + // const elapsedMs = delta * TIME_SCALE * 1000; + // currentDate.setTime(currentDate.getTime() + elapsedMs); + // if (atmosphereRef.current) { + // atmosphereRef.current.updateByDate(currentDate); + // } + // if (sunRef.current) { + // const hours = currentDate.getHours() + currentDate.getMinutes() / 60 + currentDate.getSeconds() / 3600; + // const sunAngle = MathUtils.mapLinear(hours, 6, 18, 0, Math.PI); + // const sunX = -Math.cos(sunAngle); + // const sunY = Math.sin(sunAngle); - if (hours < 6 || hours > 18) { - sunRef.current.position.set(0, -1, 0); - sunRef.current.intensity = 10.0; - } else { - sunRef.current.position.set(sunX, sunY, 0.2); - sunRef.current.intensity = MathUtils.lerp(0.5, 3.0, sunY); - } - } - }); + // if (hours < 6 || hours > 18) { + // sunRef.current.position.set(0, -1, 0); + // sunRef.current.intensity = 10.0; + // } else { + // sunRef.current.position.set(sunX, sunY, 0.2); + // sunRef.current.intensity = MathUtils.lerp(0.5, 3.0, sunY); + // } + // } + //}); + useFrame((state, delta) => { + const currentDate = dateRef.current; + const elapsedMs = delta * TIME_SCALE * 1000; + currentDate.setTime(currentDate.getTime() + elapsedMs); + if (atmosphereRef.current) { + atmosphereRef.current.updateByDate(currentDate); + + const sunDirection = atmosphereRef.current.sunDirection; + + if (sunRef.current && sunDirection) { + + sunRef.current.position.copy(sunDirection); + sunRef.current.intensity = 3.0; // 強度は固定で、時間帯による調整はAtmosphereが担当 + + if (sunDirection.y < -0.1) { + sunRef.current.intensity = 0.1; + } + } + } + }); return ( <> {/* Camera is controlled by FollowCamera component */} @@ -550,7 +568,7 @@ function CameraSync() { function AvatarLayer() { return ( - + @@ -612,7 +630,7 @@ function LocationUI() { function AtmosphereLayer() { // Canvasが親となり、その中にロジックコンポーネント(AtmosphereScene)を入れる return ( - + );