From 5b9ef0223de8f752a8f6b02233254e8dc192ca28 Mon Sep 17 00:00:00 2001 From: linkong Date: Tue, 7 Apr 2026 09:29:27 +0800 Subject: [PATCH] fix(earth-controls): zoom-aware drag sensitivity and bump version to 0.22.13 --- VERSION | 2 +- docs/CHANGELOG.md | 21 +++++++++++++++++++++ frontend/package.json | 2 +- frontend/public/earth/js/constants.js | 3 +++ frontend/public/earth/js/main.js | 17 ++++++++++++++--- pyproject.toml | 2 +- uv.lock | 2 +- 7 files changed, 42 insertions(+), 7 deletions(-) diff --git a/VERSION b/VERSION index 69ab04c4..6a8640c3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.22.12 +0.22.13 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index cca1b5b8..61325bc9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,6 +7,27 @@ This project follows the repository versioning rule: - `feature` -> `+0.1.0` - `bugfix` -> `+0.0.1` +## 0.22.13 + +Released: 2026-04-07 + +### Highlights + +- Added zoom-aware drag sensitivity on Earth interaction so drag distance naturally becomes finer when zoomed in and faster when zoomed out. +- Shipped as a focused bugfix release (`+0.0.1`) to improve operation feel without changing existing data/visual layers. + +### Improved + +- Improved [main.js](/home/ray/dev/linkong/planet/frontend/public/earth/js/main.js) by replacing fixed drag rotation gain with a dynamic factor derived from current zoom level. +- Improved [main.js](/home/ray/dev/linkong/planet/frontend/public/earth/js/main.js) by introducing `getDragRotationFactor()` so interaction tuning stays centralized instead of mixing formulas in pointer handlers. +- Improved [constants.js](/home/ray/dev/linkong/planet/frontend/public/earth/js/constants.js) by adding explicit drag tuning knobs: + `dragRotationFactorBase`, `dragRotationScaleMin`, and `dragRotationScaleMax`. + +### Fixed + +- Fixed the previous interaction mismatch where drag traveled the same angular distance regardless of zoom level, making close-up inspection too jumpy and far-view browsing too slow. +- Fixed maintainability drift where drag sensitivity had a hardcoded literal in logic code instead of configurable constants. + ## 0.22.12 Released: 2026-04-02 diff --git a/frontend/package.json b/frontend/package.json index dfaceb60..8a995f81 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "planet-frontend", - "version": "0.22.12", + "version": "0.22.13", "private": true, "dependencies": { "@ant-design/icons": "^5.2.6", diff --git a/frontend/public/earth/js/constants.js b/frontend/public/earth/js/constants.js index 9b93ca42..05008c6b 100644 --- a/frontend/public/earth/js/constants.js +++ b/frontend/public/earth/js/constants.js @@ -7,6 +7,9 @@ export const CONFIG = { maxZoom: 5.0, earthRadius: 100, rotationSpeed: 0.0005, + dragRotationFactorBase: 0.005, + dragRotationScaleMin: 0.28, + dragRotationScaleMax: 2.0, }; // Earth coordinate constants diff --git a/frontend/public/earth/js/main.js b/frontend/public/earth/js/main.js index dabe1c76..653be064 100644 --- a/frontend/public/earth/js/main.js +++ b/frontend/public/earth/js/main.js @@ -108,6 +108,7 @@ import { getShowTerrain, setAutoRotate, resetView, + getZoomLevel, teardownControls, } from "./controls.js"; import { @@ -170,7 +171,6 @@ const scratchBGPDirection = new THREE.Vector3(); const scratchBGPWorldPosition = new THREE.Vector3(); const cleanupFns = []; -const DRAG_ROTATION_FACTOR = 0.005; const DRAG_SMOOTHING_FACTOR = 0.18; const INERTIA_DAMPING = 0.92; const INERTIA_MIN_VELOCITY = 0.00008; @@ -201,6 +201,16 @@ function isEventOnHud(event) { return HUD_INTERACTIVE_SELECTORS.some((selector) => target.closest(selector)); } +function getDragRotationFactor() { + const zoom = Math.max(getZoomLevel(), 0.01); + const scale = THREE.MathUtils.clamp( + 1 / zoom, + CONFIG.dragRotationScaleMin, + CONFIG.dragRotationScaleMax, + ); + return CONFIG.dragRotationFactorBase * scale; +} + function disposeMaterial(material) { if (!material) return; if (Array.isArray(material)) { @@ -1142,8 +1152,9 @@ function onMouseMove(event) { const deltaX = event.clientX - previousMousePosition.x; const deltaY = event.clientY - previousMousePosition.y; - const rotationDeltaY = deltaX * DRAG_ROTATION_FACTOR; - const rotationDeltaX = deltaY * DRAG_ROTATION_FACTOR; + const dragRotationFactor = getDragRotationFactor(); + const rotationDeltaY = deltaX * dragRotationFactor; + const rotationDeltaX = deltaY * dragRotationFactor; targetRotation.y += rotationDeltaY; targetRotation.x += rotationDeltaX; diff --git a/pyproject.toml b/pyproject.toml index abfea286..90c1965d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "planet" -version = "0.22.12" +version = "0.22.13" description = "智能星球计划 - 态势感知系统" requires-python = ">=3.14" dependencies = [ diff --git a/uv.lock b/uv.lock index 6463cd15..60f0e781 100644 --- a/uv.lock +++ b/uv.lock @@ -475,7 +475,7 @@ wheels = [ [[package]] name = "planet" -version = "0.22.12" +version = "0.22.13" source = { virtual = "." } dependencies = [ { name = "aiofiles" },