fix
This commit is contained in:
@@ -67,11 +67,9 @@ const WEATHER_PRESETS = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
// --- Locations ---
|
|
||||||
// --- Locations ---
|
|
||||||
const LOCATIONS = [
|
const LOCATIONS = [
|
||||||
{ name: 'Tokyo', longitude: 139.7671, latitude: 35.6812, heading: 180, pitch: -5, distance: 300 },
|
{ name: 'Tokyo', longitude: 139.7671, latitude: 35.6812, heading: 180, pitch: -5, distance: 1100 },
|
||||||
{ name: 'Fuji', longitude: 138.7278, latitude: 35.3606, heading: 0, pitch: -10, distance: 4000 },
|
{ 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 },
|
{ name: 'Space', longitude: 139.7671, latitude: 35.6812, heading: 0, pitch: -90, distance: 100000 },
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -79,7 +77,7 @@ const LOCATIONS = [
|
|||||||
// 複数のCanvas間で状態を共有するための簡易ストア
|
// 複数のCanvas間で状態を共有するための簡易ストア
|
||||||
const worldState = {
|
const worldState = {
|
||||||
// 世界座標 (Atmosphere内での位置 - ECEF)
|
// 世界座標 (Atmosphere内での位置 - ECEF)
|
||||||
position: new Vector3(0, EARTH_RADIUS + 2000, 0),
|
position: new Vector3(0, EARTH_RADIUS + 100000, 0),
|
||||||
// ローカル回転 (AvatarLayerでの回転 - Y-up)
|
// ローカル回転 (AvatarLayerでの回転 - Y-up)
|
||||||
// Note: This is treated as the "Local" quaternion.
|
// Note: This is treated as the "Local" quaternion.
|
||||||
quaternion: new Quaternion(),
|
quaternion: new Quaternion(),
|
||||||
@@ -233,35 +231,55 @@ function AtmosphereScene() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// 3. 時間進行と太陽移動 (Canvas内なのでuseFrameが使える)
|
// 3. 時間進行と太陽移動 (Canvas内なのでuseFrameが使える)
|
||||||
useFrame((state, delta) => {
|
//useFrame((state, delta) => {
|
||||||
const currentDate = dateRef.current;
|
// const currentDate = dateRef.current;
|
||||||
const elapsedMs = delta * TIME_SCALE * 1000;
|
// const elapsedMs = delta * TIME_SCALE * 1000;
|
||||||
currentDate.setTime(currentDate.getTime() + elapsedMs);
|
// currentDate.setTime(currentDate.getTime() + elapsedMs);
|
||||||
if (atmosphereRef.current) {
|
// if (atmosphereRef.current) {
|
||||||
atmosphereRef.current.updateByDate(currentDate);
|
// atmosphereRef.current.updateByDate(currentDate);
|
||||||
}
|
// }
|
||||||
if (sunRef.current) {
|
// if (sunRef.current) {
|
||||||
const hours = currentDate.getHours() + currentDate.getMinutes() / 60 + currentDate.getSeconds() / 3600;
|
// const hours = currentDate.getHours() + currentDate.getMinutes() / 60 + currentDate.getSeconds() / 3600;
|
||||||
const sunAngle = MathUtils.mapLinear(hours, 6, 18, 0, Math.PI);
|
// const sunAngle = MathUtils.mapLinear(hours, 6, 18, 0, Math.PI);
|
||||||
const sunX = -Math.cos(sunAngle);
|
// const sunX = -Math.cos(sunAngle);
|
||||||
const sunY = Math.sin(sunAngle);
|
// const sunY = Math.sin(sunAngle);
|
||||||
|
|
||||||
if (hours < 6 || hours > 18) {
|
// if (hours < 6 || hours > 18) {
|
||||||
sunRef.current.position.set(0, -1, 0);
|
// sunRef.current.position.set(0, -1, 0);
|
||||||
sunRef.current.intensity = 10.0;
|
// sunRef.current.intensity = 10.0;
|
||||||
} else {
|
// } else {
|
||||||
sunRef.current.position.set(sunX, sunY, 0.2);
|
// sunRef.current.position.set(sunX, sunY, 0.2);
|
||||||
sunRef.current.intensity = MathUtils.lerp(0.5, 3.0, sunY);
|
// 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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* Camera is controlled by FollowCamera component */}
|
{/* Camera is controlled by FollowCamera component */}
|
||||||
<PerspectiveCamera
|
<PerspectiveCamera
|
||||||
makeDefault
|
makeDefault
|
||||||
near={1}
|
near={10}
|
||||||
far={10000000}
|
far={10000000}
|
||||||
fov={45}
|
fov={45}
|
||||||
/>
|
/>
|
||||||
@@ -550,7 +568,7 @@ function CameraSync() {
|
|||||||
|
|
||||||
function AvatarLayer() {
|
function AvatarLayer() {
|
||||||
return (
|
return (
|
||||||
<Canvas gl={{ alpha: true, antialias: true, logarithmicDepthBuffer: true }}>
|
<Canvas gl={{ alpha: true, antialias: true }}>
|
||||||
<PerspectiveCamera makeDefault position={[0, 1.5, 3]} fov={40} />
|
<PerspectiveCamera makeDefault position={[0, 1.5, 3]} fov={40} />
|
||||||
<CameraSync />
|
<CameraSync />
|
||||||
|
|
||||||
@@ -612,7 +630,7 @@ function LocationUI() {
|
|||||||
function AtmosphereLayer() {
|
function AtmosphereLayer() {
|
||||||
// Canvasが親となり、その中にロジックコンポーネント(AtmosphereScene)を入れる
|
// Canvasが親となり、その中にロジックコンポーネント(AtmosphereScene)を入れる
|
||||||
return (
|
return (
|
||||||
<Canvas>
|
<Canvas gl={{ alpha: true, antialias: true }}>
|
||||||
<AtmosphereScene />
|
<AtmosphereScene />
|
||||||
</Canvas>
|
</Canvas>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user