修复
This commit is contained in:
1 parent
d81ab2acaa
commit
639ff1ba57
15 files changed
+227
-151
No files matched your search
@@ -705,40 +705,52 @@ public class CelestialView : Control, IDisposable
|
||||
var tropic = TropicDegrees(runtime);
|
||||
var polar = 90.0 - tropic;
|
||||
|
||||
DrawParallel(ctx, cam, planet, center, radius, 0, EquatorPen,
|
||||
labels ? Texts["lat.equator"] : null, LabelBrush);
|
||||
DrawParallel(ctx, cam, planet, center, radius, tropic, TropicPen,
|
||||
labels ? Texts["lat.tropicN"] : null, TropicBrush);
|
||||
DrawParallel(ctx, cam, planet, center, radius, -tropic, TropicPen,
|
||||
labels ? Texts["lat.tropicS"] : null, TropicBrush);
|
||||
DrawParallel(ctx, cam, planet, center, radius, polar, PolarPen,
|
||||
labels ? Texts["lat.polarN"] : null, PolarBrush);
|
||||
DrawParallel(ctx, cam, planet, center, radius, -polar, PolarPen,
|
||||
labels ? Texts["lat.polarS"] : null, PolarBrush);
|
||||
}
|
||||
|
||||
private void DrawParallel(DrawingContext ctx, Matrix4x4 cam, Matrix4x4 planet,
|
||||
Point center, double radius, double lat, IPen pen, string? label, IBrush labelBrush)
|
||||
{
|
||||
DrawSpherePolyline(ctx, cam, planet, center, radius, pen,
|
||||
t => LatLonToUnit(lat, t * 360.0), 144);
|
||||
if (label == null) return;
|
||||
|
||||
// 找该纬线上「最靠右且可见」的点作为标签锚点:
|
||||
// 地球自转时标签始终留在可见半球右侧,不会忽隐忽现
|
||||
Vector3 best = default;
|
||||
var bestScore = double.NegativeInfinity;
|
||||
for (var lon = -180; lon < 180; lon += 6)
|
||||
// 五条纬线一起画:先画线,再统一布置标签,避免自转时多个标签
|
||||
// 被投影到相近位置而互相覆盖 / 抖动(原来的逐条独立绘制会重叠)。
|
||||
var lines = new (double Lat, IPen Pen, string? Label, IBrush Brush)[]
|
||||
{
|
||||
var world = Vector3.Transform(LatLonToUnit(lat, lon), planet);
|
||||
var c = Vector3.Transform(world, cam);
|
||||
if (c.Z < 0.10f) continue;
|
||||
var score = c.X * 2.0 + c.Z;
|
||||
if (score > bestScore) { bestScore = score; best = c; }
|
||||
(0, EquatorPen, labels ? Texts["lat.equator"] : null, LabelBrush),
|
||||
(tropic, TropicPen, labels ? Texts["lat.tropicN"] : null, TropicBrush),
|
||||
(-tropic, TropicPen, labels ? Texts["lat.tropicS"] : null, TropicBrush),
|
||||
(polar, PolarPen, labels ? Texts["lat.polarN"] : null, PolarBrush),
|
||||
(-polar, PolarPen, labels ? Texts["lat.polarS"] : null, PolarBrush)
|
||||
};
|
||||
|
||||
foreach (var l in lines)
|
||||
DrawSpherePolyline(ctx, cam, planet, center, radius, l.Pen,
|
||||
t => LatLonToUnit(l.Lat, t * 360.0), 144);
|
||||
|
||||
if (!labels) return;
|
||||
|
||||
// 收集每个标签的锚点,按屏幕 Y 排序后做垂直去重叠
|
||||
var placed = new List<(double Y, double X, string Text, IBrush Brush)>();
|
||||
foreach (var l in lines)
|
||||
{
|
||||
if (l.Label == null) continue;
|
||||
Vector3 best = default;
|
||||
var bestScore = double.NegativeInfinity;
|
||||
for (var lon = -180; lon < 180; lon += 6)
|
||||
{
|
||||
var world = Vector3.Transform(LatLonToUnit(l.Lat, lon), planet);
|
||||
var c = Vector3.Transform(world, cam);
|
||||
if (c.Z < 0.10f) continue;
|
||||
var score = c.X * 2.0 + c.Z;
|
||||
if (score > bestScore) { bestScore = score; best = c; }
|
||||
}
|
||||
if (double.IsNegativeInfinity(bestScore)) continue;
|
||||
placed.Add((center.Y - best.Y * radius, center.X + best.X * radius, l.Label, l.Brush));
|
||||
}
|
||||
|
||||
placed.Sort((a, b) => a.Y.CompareTo(b.Y));
|
||||
const double minGap = 16.0;
|
||||
var lastY = double.NegativeInfinity;
|
||||
foreach (var p in placed)
|
||||
{
|
||||
var y = p.Y;
|
||||
if (y - lastY < minGap) y = lastY + minGap;
|
||||
lastY = y;
|
||||
DrawLabelChip(ctx, p.Text, new Point(p.X, y), InsetMode ? 9.0 : 10.5, p.Brush, toRight: false);
|
||||
}
|
||||
if (double.IsNegativeInfinity(bestScore)) return;
|
||||
var p = new Point(center.X + best.X * radius, center.Y - best.Y * radius);
|
||||
DrawLabelChip(ctx, label, p, InsetMode ? 9.0 : 10.5, labelBrush, toRight: false);
|
||||
}
|
||||
|
||||
/// <summary>带深色底衬的标签:压在明亮的地球上也读得清,且不会被画布边缘裁掉。</summary>
|
||||
@@ -746,7 +758,11 @@ public class CelestialView : Control, IDisposable
|
||||
double fontSize, IBrush brush, bool toRight)
|
||||
{
|
||||
var formatted = new FormattedText(text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight,
|
||||
new Typeface(FontFamily.Default, FontStyle.Normal, FontWeight.SemiBold), fontSize, brush);
|
||||
new Typeface(FontFamily.Default, FontStyle.Normal, FontWeight.SemiBold), fontSize, brush)
|
||||
{
|
||||
TextAlignment = TextAlignment.Left,
|
||||
Trimming = TextTrimming.None
|
||||
};
|
||||
var x = toRight ? anchor.X + 9 : Math.Max(3, anchor.X - formatted.Width - 9);
|
||||
var y = anchor.Y - formatted.Height - 4;
|
||||
ctx.DrawRectangle(ChipBg, null,
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
"type": "NeoRF.EarthModels.RevolutionModelFactory",
|
||||
"preview": "preview.png",
|
||||
"apiVersion": 1,
|
||||
"version": "1.0-0a73a257ec",
|
||||
"updatedAt": "2026-11-07T10:46:02Z"
|
||||
"version": "1.0-7380e0cff3",
|
||||
"updatedAt": "2026-11-07T12:01:08Z"
|
||||
}
|
||||
Binary file not shown.
@@ -23,6 +23,6 @@
|
||||
"type": "NeoRF.EarthModels.RotationModelFactory",
|
||||
"preview": "preview.png",
|
||||
"apiVersion": 1,
|
||||
"version": "1.0-6c97454f58",
|
||||
"updatedAt": "2026-11-07T10:46:02Z"
|
||||
"version": "1.0-c74907bbce",
|
||||
"updatedAt": "2026-11-07T12:01:08Z"
|
||||
}
|
||||
Binary file not shown.
+11
-11
@@ -1,30 +1,30 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"generated": "2026-11-07T10:46:02Z",
|
||||
"generated": "2026-11-07T12:01:09Z",
|
||||
"repository": "https://gitcode.com/2509_92447106/GC",
|
||||
"branch": "main",
|
||||
"modelDir": "model",
|
||||
"launcher": {
|
||||
"version": "1.0.0",
|
||||
"revision": "0d59eff631",
|
||||
"version": "1.0.1",
|
||||
"revision": "ba909d4dc3",
|
||||
"packages": {
|
||||
"win-x64": {
|
||||
"path": "dist/GC-win-x64.zip",
|
||||
"url": "",
|
||||
"sha256": "7bfb1cfab07934642eff4c52078a8f5f034f1d2432a7613f04674403c70f2b6d",
|
||||
"size": 78755039
|
||||
"sha256": "2704fbc3e3acba5630a13a313af0eca45128827ed90e4718fd143a554ca70c3c",
|
||||
"size": 39379924
|
||||
},
|
||||
"win-arm64": {
|
||||
"path": "dist/GC-win-arm64.zip",
|
||||
"url": "",
|
||||
"sha256": "9fddf07fa18cbdb368e37204cfb96f5828207e5fe74ecb31fa66b61fa400fd1c",
|
||||
"size": 75360988
|
||||
"sha256": "c8f69370b9e381418a6568aca11cac44cb034e0ab2a99f7e14fcbef1dc503a44",
|
||||
"size": 37684316
|
||||
},
|
||||
"osx-arm64": {
|
||||
"path": "dist/GC-osx-arm64.zip",
|
||||
"url": "",
|
||||
"sha256": "3517548b598eda62c92d873528f39e305c52c6fb246fa5ba5f3613f8b8cb315a",
|
||||
"size": 39847910
|
||||
"sha256": "8588892dcfb982b7b52c3d74f3493fd8f27a327a0571095ab62dd4130857e082",
|
||||
"size": 39852236
|
||||
},
|
||||
"osx-x64": {
|
||||
"path": "dist/GC-osx-x64.zip",
|
||||
@@ -39,12 +39,12 @@
|
||||
"models": [
|
||||
{
|
||||
"id": "earth-revolution",
|
||||
"version": "1.0-0a73a257ec",
|
||||
"version": "1.0-7380e0cff3",
|
||||
"dir": "model/earth-revolution"
|
||||
},
|
||||
{
|
||||
"id": "earth-rotation",
|
||||
"version": "1.0-6c97454f58",
|
||||
"version": "1.0-c74907bbce",
|
||||
"dir": "model/earth-rotation"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user