添加部分功能

This commit is contained in:
2509_92447106 committed 2026-11-14 06:40:54 +08:00
1 parent 9293fee3bf
commit 6d4d098681
23 files changed
+994 -89

No files matched your search

+2 -2
View File
@@ -18,7 +18,7 @@
],
"dataDir": "earth-geography.model",
"version": "1.8",
"updatedAt": "2026-11-13T13:56:47Z",
"updatedAt": "2026-11-13T15:19:06Z",
"chrome": {
"titleBar": "#0C1828",
"titleBorder": "#1B2740",
@@ -26,5 +26,5 @@
"button": "#9FB4D4",
"frame": "#0A1524"
},
"build": "103f3400b7"
"build": "912c6d5619"
}
@@ -256,6 +256,7 @@ public sealed class GeographyRuntime : IModelRuntime
{
foreach (var d in _disposables) d.Dispose();
_disposables.Clear();
_view?.StopAnimation();
_view = null;
GC.SuppressFinalize(this);
}
+48 -5
View File
@@ -30,6 +30,8 @@ public sealed class GeographyView : Control
private double _yawDeg = 10;
private double _pitchDeg = 15;
private double _zoom = 1.0;
private double _zoomTarget = 1.0;
private Avalonia.Threading.DispatcherTimer? _zoomTimer;
private Point _lastPointer;
private bool _dragging;
@@ -82,18 +84,59 @@ public sealed class GeographyView : Control
public GeoMode Mode { get => _mode; set { _mode = value; InvalidateVisual(); StateChanged?.Invoke(); } }
/// <summary>缩放倍数(0.55–4.0)。文字大小跟随缩放变化。</summary>
/// <summary>
/// 缩放。写入的是**目标值**,由动画计时器平滑逼近,
/// 直接跳变会让滚轮缩放显得生硬。
/// </summary>
public double Zoom
{
get => _zoom;
get => _zoomTarget;
set
{
_zoom = Math.Clamp(value, 0.55, 4.0);
Redraw();
_zoomTarget = Math.Clamp(value, 0.55, 4.0);
EnsureAnimating();
}
}
/// <summary>立即生效(贴图生成、复位等场景不该有过渡)。</summary>
public void SetZoomImmediate(double value)
{
_zoomTarget = Math.Clamp(value, 0.55, 4.0);
_zoom = _zoomTarget;
Redraw();
}
private void Redraw() { InvalidateVisual(); StateChanged?.Invoke(); }
/// <summary>
/// 缩放动画:60Hz 逼近目标值,差值小于阈值即停,
/// 避免空转白耗 CPU(一体机上尤其明显)。
/// </summary>
private void EnsureAnimating()
{
_zoomTimer ??= new Avalonia.Threading.DispatcherTimer(
TimeSpan.FromMilliseconds(16), Avalonia.Threading.DispatcherPriority.Render, (_, _) => StepZoom());
if (!_zoomTimer.IsEnabled) _zoomTimer.Start();
}
private void StepZoom()
{
var diff = _zoomTarget - _zoom;
if (Math.Abs(diff) < 0.0015)
{
_zoom = _zoomTarget;
_zoomTimer?.Stop();
Redraw();
return;
}
// 指数逼近:手感接近系统级平滑缩放
_zoom += diff * 0.28;
Redraw();
}
/// <summary>释放动画计时器,避免窗口关闭后还在跑。</summary>
public void StopAnimation() => _zoomTimer?.Stop();
/// <summary>文字缩放系数:跟随缩放一起放大/缩小,放大地球时标签也变大。</summary>
private double TextScale => Math.Clamp(_zoom, 0.85, 2.4);
@@ -141,8 +184,8 @@ public sealed class GeographyView : Control
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
{
base.OnPointerWheelChanged(e);
_zoom = Math.Clamp(_zoom * (1 + e.Delta.Y * 0.12), 0.55, 4.0);
Redraw();
// 走 Zoom 属性(带平滑动画),不要在事件里直接改 _zoom
Zoom = _zoomTarget * (1 + e.Delta.Y * 0.12);
e.Handled = true;
}
+2 -2
View File
@@ -24,7 +24,7 @@
"preview": "preview.png",
"apiVersion": 1,
"version": "1.6",
"updatedAt": "2026-11-13T13:56:47Z",
"updatedAt": "2026-11-13T15:19:06Z",
"chrome": {
"titleBar": "#0C1828",
"titleBorder": "#1B2740",
@@ -32,5 +32,5 @@
"button": "#9FB4D4",
"frame": "#0A1524"
},
"build": "c83fbb7799"
"build": "d34ade3c3f"
}
+2 -2
View File
@@ -24,7 +24,7 @@
"preview": "preview.png",
"apiVersion": 1,
"version": "1.6",
"updatedAt": "2026-11-13T13:56:47Z",
"updatedAt": "2026-11-13T15:19:06Z",
"chrome": {
"titleBar": "#0C1828",
"titleBorder": "#1B2740",
@@ -32,5 +32,5 @@
"button": "#9FB4D4",
"frame": "#0A1524"
},
"build": "49f5a18dab"
"build": "033c8f1696"
}
+2 -2
View File
@@ -25,7 +25,7 @@
"preview": "preview.png",
"apiVersion": 1,
"version": "1.5",
"updatedAt": "2026-11-13T13:56:47Z",
"updatedAt": "2026-11-13T15:19:06Z",
"chrome": {
"titleBar": "#FFFFFF",
"titleBorder": "#E3E8F3",
@@ -33,5 +33,5 @@
"button": "#5B6A86",
"frame": "#F4F6FB"
},
"build": "f769728477"
"build": "85a274733d"
}
+6 -6
View File
@@ -1,12 +1,12 @@
{
"schema": 1,
"generated": "2026-11-13T13:56:47Z",
"generated": "2026-11-13T15:19:06Z",
"repository": "https://gitcode.com/2509_92447106/GC",
"branch": "main",
"modelDir": "model",
"launcher": {
"version": "1.0.6",
"revision": "e00b9065c8",
"revision": "6db90790d3",
"packages": {
"win-x64": {
"path": "dist/GC-win-x64.zip",
@@ -34,25 +34,25 @@
{
"id": "earth-geography",
"version": "1.8",
"build": "103f3400b7",
"build": "912c6d5619",
"dir": "model/earth-geography"
},
{
"id": "earth-revolution",
"version": "1.6",
"build": "c83fbb7799",
"build": "d34ade3c3f",
"dir": "model/earth-revolution"
},
{
"id": "earth-rotation",
"version": "1.6",
"build": "49f5a18dab",
"build": "033c8f1696",
"dir": "model/earth-rotation"
},
{
"id": "scale-calculator",
"version": "1.5",
"build": "f769728477",
"build": "85a274733d",
"dir": "model/scale-calculator"
}
]