diff --git a/.gitignore b/.gitignore index 345942c..51b6120 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,9 @@ # 运行时上传目录:管理端上传的纹理/模型/图标、用户头像等,不随 git 分发 # (服务器上运行时读的是 bind mount 的 /opt/cosmo/data/upload) -/backend/upload/ +# 例外:assets 是随代码分发的内置资源(火箭模拟的昼/夜地球贴图、滴答音效) +/backend/upload/* +!/backend/upload/assets/ # OS files .DS_Store diff --git a/backend/upload/assets/2k_earth_daymap.jpg b/backend/upload/assets/2k_earth_daymap.jpg new file mode 100644 index 0000000..6cdcffe Binary files /dev/null and b/backend/upload/assets/2k_earth_daymap.jpg differ diff --git a/backend/upload/assets/2k_earth_nightmap.jpg b/backend/upload/assets/2k_earth_nightmap.jpg new file mode 100644 index 0000000..863be2c Binary files /dev/null and b/backend/upload/assets/2k_earth_nightmap.jpg differ diff --git a/backend/upload/assets/tick_sample.m4a b/backend/upload/assets/tick_sample.m4a new file mode 100644 index 0000000..5938594 Binary files /dev/null and b/backend/upload/assets/tick_sample.m4a differ diff --git a/docker-compose.yml b/docker-compose.yml index 5d77d35..9119e08 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -87,6 +87,9 @@ services: HTTPS_PROXY: ${HTTPS_PROXY:-} volumes: - /opt/cosmo/data/upload:/app/upload + # 仓库内置资源(火箭模拟的昼/夜地球贴图、滴答音效)随 git 分发, + # 单独挂到 /app/upload/assets,免得每次升级都要往数据目录里拷一份。 + - ./backend/upload/assets:/app/upload/assets:ro - /opt/cosmo/data/logs/backend:/app/logs ports: - "8000:8000" diff --git a/frontend/src/features/rocket-simulator/RocketFlightScene.tsx b/frontend/src/features/rocket-simulator/RocketFlightScene.tsx index e19f8bc..3c9c1ec 100644 --- a/frontend/src/features/rocket-simulator/RocketFlightScene.tsx +++ b/frontend/src/features/rocket-simulator/RocketFlightScene.tsx @@ -21,11 +21,18 @@ interface RocketFlightSceneProps { const EARTH_RADIUS_METERS = 6_371_000; const EARTH_RADIUS = 34; -const EARTH_TEXTURE = '/upload/texture/2k_earth_daymap.jpg'; +const EARTH_DAY_TEXTURE = '/upload/assets/2k_earth_daymap.jpg'; +const EARTH_NIGHT_TEXTURE = '/upload/assets/2k_earth_nightmap.jpg'; const EARTH_CENTER = new THREE.Vector3(0, -EARTH_RADIUS, 0); const EARTH_ROTATION = new THREE.Euler(0, -1.25, -0.08); const VIEW_SCALE_CALIBRATION = 0.7; +/** 地球贴图按系统时间取用:06:00-18:00 用昼间图,其余时间用夜间的城市灯光图。 */ +function earthTexturePath() { + const hour = new Date().getHours(); + return hour >= 6 && hour < 18 ? EARTH_DAY_TEXTURE : EARTH_NIGHT_TEXTURE; +} + interface LaunchSite { latitude: number; longitude: number; @@ -461,7 +468,8 @@ function Atmosphere({ state, mode }: { state: SimulationState; mode: CameraMode } function SceneContents({ rocket, state, cameraMode, viewScale, viewScaleResetTrigger, onViewScaleChange }: RocketFlightSceneProps) { - const earthTexture = useOptionalTexture(EARTH_TEXTURE); + // 只在挂载时取一次小时数,免得一次飞行中途跨过 6/18 点导致贴图来回跳。 + const earthTexture = useOptionalTexture(useMemo(() => earthTexturePath(), [])); const manualCameraRef = useRef(false); const orbitControlsRef = useRef(null); const manualDistanceRef = useRef(null);