This commit is contained in:
2509_92447106 committed 2026-11-08 17:29:32 +08:00
commit 1ee49b8966
1125 files changed
+32542

No files matched your search

@@ -0,0 +1,23 @@
{
"id": "earth-geography",
"nameI18n": {
"zh-CN": "地球地理",
"en": "Earth Geography"
},
"descriptionI18n": {
"zh-CN": "五带划分、七大洲四大洋轮廓、六大板块与洲界,纯线稿教学图。",
"en": "Climate zones, continent/ocean outlines, plates and borders — clean line art."
},
"assembly": "EarthGeographyModel.dll",
"type": "NeoRF.EarthModels.GeographyModelFactory",
"author": "Morris GC",
"tags": [
"geography",
"earth",
"atlas"
],
"dataDir": "earth-geography.model",
"version": "1.0",
"updatedAt": "2026-11-08T09:22:29Z",
"build": "883fdf6c57"
}
@@ -0,0 +1 @@
{"borders":[{"between":"亚洲-非洲","name":"苏伊士运河","lines":[[[32.6,31.3],[32.4,30.5],[32.3,29.9]]]},{"between":"亚洲-欧洲","name":"亚欧分界(乌拉尔山—乌拉尔河—里海—大高加索山—黑海—土耳其海峡)","segments":[{"name":"乌拉尔山","nameI18n":{"zh-CN":"乌拉尔山","en":"Ural Mts."},"lines":[[[66.0,68.5],[64.0,64.0],[60.5,60.0],[58.5,54.0],[57.0,51.0]]]},{"name":"乌拉尔河","nameI18n":{"zh-CN":"乌拉尔河","en":"Ural River"},"lines":[[[57.0,51.0],[55.5,49.0],[53.0,47.0],[51.5,46.5]]]},{"name":"里海","nameI18n":{"zh-CN":"里海","en":"Caspian Sea"},"lines":[[[51.5,46.5],[50.5,44.0],[49.5,41.0],[50.0,38.0],[51.0,36.5]]]},{"name":"大高加索山","nameI18n":{"zh-CN":"大高加索山","en":"Greater Caucasus"},"lines":[[[51.0,36.5],[46.0,42.5],[43.0,42.8],[41.0,43.2]]]},{"name":"黑海","nameI18n":{"zh-CN":"黑海","en":"Black Sea"},"lines":[[[41.0,43.2],[36.0,44.5],[31.0,44.0],[29.0,41.5]]]},{"name":"土耳其海峡","nameI18n":{"zh-CN":"土耳其海峡","en":"Turkish Straits"},"lines":[[[29.0,41.5],[28.0,40.5],[26.5,40.0],[26.2,39.5]]]}],"lines":[[[66.0,68.5],[64.0,64.0],[60.5,60.0],[58.5,54.0],[57.0,51.0],[57.0,51.0],[55.5,49.0],[53.0,47.0],[51.5,46.5],[51.5,46.5],[50.5,44.0],[49.5,41.0],[50.0,38.0],[51.0,36.5],[51.0,36.5],[46.0,42.5],[43.0,42.8],[41.0,43.2],[41.0,43.2],[36.0,44.5],[31.0,44.0],[29.0,41.5],[29.0,41.5],[28.0,40.5],[26.5,40.0],[26.2,39.5]]]},{"between":"亚洲-非洲","name":"红海","lines":[[[43.3,12.6],[40.0,18.0],[38.5,22.0],[35.0,27.0],[34.5,29.0]]]},{"between":"欧洲-非洲","name":"直布罗陀海峡","lines":[[[-5.6,36.0],[-4.0,36.2],[0.0,36.5]]]},{"between":"北美-南美","name":"巴拿马运河","lines":[[[-79.6,9.1],[-78.5,8.9],[-77.5,8.6]]]},{"between":"亚洲-北美","name":"白令海峡","lines":[[[-169.0,65.5],[-170.5,65.8],[-172.0,66.0]]]},{"between":"亚洲-大洋洲","name":"印尼群岛","lines":[[[120.0,-1.0],[125.0,-2.0],[130.0,-3.0]]]},{"between":"南极洲","name":"南极圈","lines":[[[-180.0,-66.5],[-170.0,-66.5],[-160.0,-66.5],[-150.0,-66.5],[-140.0,-66.5],[-130.0,-66.5],[-120.0,-66.5],[-110.0,-66.5],[-100.0,-66.5],[-90.0,-66.5],[-80.0,-66.5],[-70.0,-66.5],[-60.0,-66.5],[-50.0,-66.5],[-40.0,-66.5],[-30.0,-66.5],[-20.0,-66.5],[-10.0,-66.5],[0.0,-66.5],[10.0,-66.5],[20.0,-66.5],[30.0,-66.5],[40.0,-66.5],[50.0,-66.5],[60.0,-66.5],[70.0,-66.5],[80.0,-66.5],[90.0,-66.5],[100.0,-66.5],[110.0,-66.5],[120.0,-66.5],[130.0,-66.5],[140.0,-66.5],[150.0,-66.5],[160.0,-66.5],[170.0,-66.5],[180.0,-66.5]]]}]}
@@ -0,0 +1 @@
{"lines":[[[179.999,-16.169],[179.564,-16.637],[179.568,-16.747],[179.93,-16.519],[179.928,-16.744],[179.419,-16.807],[179.202,-16.713],[179.007,-16.9],[178.707,-16.976],[178.604,-16.801],[178.497,-16.788],[178.584,-16.622],[178.805,-16.631],[178.961,-16.483],[179.552,-16.25],[179.999,-16.169]],[[143.179,-11.954],[143.11,-12.304],[143.402,-12.64],[143.587,-13.444],[143.548,-13.741],[143.756,-14.349],[143.962,-14.463],[144.473,-14.232],[144.648,-14.492],[145.288,-14.943],[145.272,-15.477],[145.458,-16.056],[145.426,-16.406],[145.755,-16.879],[145.912,-16.913],[146.126,-17.635],[146.032,-18.273],[146.333,-18.554],[146.297,-18.841],[146.383,-18.977],[147.139,-19.393],[147.419,-19.378],[147.742,-19.77],[148.759,-20.29],[148.885,-20.481],[148.73,-20.468],[148.684,-20.58],[149.205,-21.125],[149.329,-21.476],[149.454,-21.579],[149.704,-22.441],[149.822,-22.39],[149.974,-22.551],[149.942,-22.308],[150.021,-22.168],[150.541,-22.559],[150.623,-22.367],[150.764,-22.576],[150.843,-23.458],[151.154,-23.784],[151.832,-24.123],[152.13,-24.598],[152.456,-24.802],[152.654,-25.202],[152.913,-25.432],[152.921,-25.689],[153.165,-25.964],[153.084,-26.304],[153.117,-27.194],[153.576,-28.241],[153.617,-28.673],[153.605,-28.854],[153.348,-29.29],[153.272,-29.892],[153.031,-30.563],[152.944,-31.435],[152.559,-32.046],[152.47,-32.439],[152.137,-32.678],[152.164,-32.757],[151.813,-32.901],[151.432,-33.522],[151.292,-33.581],[151.28,-33.927],[151.125,-34.005],[151.232,-34.03],[150.871,-34.499],[150.805,-35.013],[150.567,-35.214],[150.195,-35.834],[149.96,-36.846],[149.933,-37.529],[149.481,-37.771],[148.262,-37.831],[147.877,-37.934],[146.857,-38.663],[146.217,-38.727],[146.337,-38.894],[146.467,-38.84],[146.484,-39.065],[146.4,-39.146],[146.158,-38.866],[145.935,-38.902],[145.791,-38.667],[145.397,-38.535],[145.542,-38.394],[145.476,-38.244],[145.293,-38.238],[144.96,-38.501],[144.718,-38.34],[144.911,-38.344],[145.12,-38.091],[144.891,-37.9],[144.396,-38.137],[144.665,-38.21],[143.539,-38.821],[142.456,-38.386],[141.725,-38.271],[141.594,-38.388],[141.424,-38.363],[141.011,-38.077],[140.39,-37.897],[139.784,-37.246],[139.738,-37.06],[139.857,-36.662],[139.729,-36.371],[139.466,-36.01],[138.969,-35.581],[139.178,-35.523],[139.289,-35.611],[139.283,-35.375],[138.522,-35.642],[138.184,-35.613],[138.511,-35.024],[138.49,-34.764],[138.089,-34.17],[137.692,-35.143],[136.884,-35.24],[137.014,-34.916],[137.391,-34.913],[137.494,-34.161],[137.932,-33.579],[137.852,-33.201],[137.993,-33.094],[137.783,-32.578],[137.791,-32.823],[137.442,-33.194],[137.237,-33.629],[136.431,-34.03],[135.891,-34.661],[135.97,-34.982],[135.792,-34.863],[135.648,-34.94],[135.231,-34.58],[135.123,-34.586],[135.217,-34.487],[135.45,-34.581],[135.219,-33.96],[134.889,-33.626],[134.719,-33.255],[134.301,-33.165],[134.1,-32.749],[134.227,-32.731],[134.234,-32.549],[133.665,-32.207],[133.212,-32.184],[132.757,-31.956],[132.215,-32.007],[131.721,-31.696],[131.144,-31.496],[130.783,-31.604],[130.13,-31.579],[128.946,-31.703],[127.32,-32.264],[125.917,-32.297],[124.759,-32.883],[124.244,-33.015],[123.868,-33.596],[123.507,-33.916],[123.208,-33.988],[122.778,-33.891],[122.151,-33.992],[122.061,-33.874],[121.405,-33.827],[119.854,-33.975],[119.635,-34.101],[119.451,-34.368],[118.895,-34.48],[118.136,-34.987],[117.863,-35.055],[116.517,-34.988],[115.987,-34.795],[115.565,-34.426],[115.009,-34.256],[114.994,-33.515],[115.182,-33.643],[115.359,-33.64],[115.515,-33.531],[115.683,-33.193],[115.619,-32.667],[115.725,-32.401],[115.698,-31.695],[115.078,-30.56],[114.857,-29.143],[114.165,-28.081],[114.028,-27.347],[113.185,-26.182],[113.323,-26.244],[113.356,-26.08],[113.582,-26.558],[113.734,-26.595],[113.836,-26.501],[113.853,-26.332],[113.589,-26.099],[113.395,-25.713],[113.451,-25.599],[113.713,-25.831],[113.724,-26.13],[113.854,-26.014],[113.992,-26.321],[114.09,-26.394],[114.216,-26.289],[114.214,-25.852],[113.418,-24.436],[113.49,-23.87],[113.757,-23.418],[113.795,-22.915],[113.683,-22.638],[114.023,-21.881],[114.124,-21.829],[114.142,-22.483],[114.378,-22.342],[114.709,-21.823],[115.456,-21.492],[116.011,-21.03],[116.707,-20.654],[117.406,-20.721],[118.199,-20.375],[118.751,-20.262],[119.104,-19.995],[119.586,-20.038],[120.434,-19.842],[120.998,-19.604],[121.338,-19.32],[121.834,-18.477],[122.345,-18.112],[122.147,-17.549],[122.261,-17.136],[122.72,-16.788],[122.971,-16.437],[123.563,-17.521],[123.594,-17.03],[123.831,-17.121],[123.874,-16.919],[123.49,-16.491],[123.626,-16.416],[123.607,-16.224],[123.729,-16.192],[123.859,-16.382],[124.044,-16.265],[124.3,-16.388],[124.772,-16.403],[124.405,-16.299],[124.416,-16.133],[124.577,-16.114],[124.649,-15.87],[124.648,-15.805],[124.504,-15.972],[124.382,-15.758],[124.44,-15.494],[124.562,-15.496],[124.693,-15.274],[125.063,-15.442],[125.073,-15.307],[124.909,-15.31],[124.839,-15.161],[125.038,-15.004],[125.356,-15.12],[125.384,-15.016],[125.243,-14.945],[125.179,-14.715],[125.285,-14.584],[125.58,-14.483],[125.628,-14.257],[125.705Line truncated
@@ -0,0 +1,7 @@
{
"zones": "Zones",
"coast": "Continents",
"plates": "Plates",
"borders": "Borders",
"reset": "Reset"
}
@@ -0,0 +1,7 @@
{
"zones": "五带",
"coast": "大洲轮廓",
"plates": "板块",
"borders": "洲界",
"reset": "复位"
}
@@ -0,0 +1,103 @@
{
"labels": [
{
"lat": 34,
"lon": 90,
"kind": "continent",
"nameI18n": {
"zh-CN": "亚洲",
"en": "Asia"
}
},
{
"lat": 2,
"lon": 20,
"kind": "continent",
"nameI18n": {
"zh-CN": "非洲",
"en": "Africa"
}
},
{
"lat": 48,
"lon": -100,
"kind": "continent",
"nameI18n": {
"zh-CN": "北美洲",
"en": "North America"
}
},
{
"lat": -15,
"lon": -60,
"kind": "continent",
"nameI18n": {
"zh-CN": "南美洲",
"en": "South America"
}
},
{
"lat": -78,
"lon": 20,
"kind": "continent",
"nameI18n": {
"zh-CN": "南极洲",
"en": "Antarctica"
}
},
{
"lat": 52,
"lon": 18,
"kind": "continent",
"nameI18n": {
"zh-CN": "欧洲",
"en": "Europe"
}
},
{
"lat": -24,
"lon": 134,
"kind": "continent",
"nameI18n": {
"zh-CN": "大洋洲",
"en": "Oceania"
}
},
{
"lat": 0,
"lon": -155,
"kind": "ocean",
"nameI18n": {
"zh-CN": "太平洋",
"en": "Pacific Ocean"
}
},
{
"lat": 12,
"lon": -30,
"kind": "ocean",
"nameI18n": {
"zh-CN": "大西洋",
"en": "Atlantic Ocean"
}
},
{
"lat": -22,
"lon": 78,
"kind": "ocean",
"nameI18n": {
"zh-CN": "印度洋",
"en": "Indian Ocean"
}
},
{
"lat": 85,
"lon": 0,
"kind": "ocean",
"nameI18n": {
"zh-CN": "北冰洋",
"en": "Arctic Ocean"
}
}
]
}
@@ -0,0 +1 @@
{"plates":[{"id":"pacific","lines":[[[-180,60],[-150,55],[-130,45],[-110,25],[-95,10],[-80,0],[-75,-15],[-90,-30],[-110,-45],[-130,-55],[-160,-60],[-180,-55],[-180,60]]]},{"id":"north-american","lines":[[[-168,72],[-140,70],[-120,60],[-100,50],[-80,45],[-60,42],[-52,28],[-62,12],[-82,8],[-95,16],[-110,25],[-130,45],[-150,55],[-168,72]]]},{"id":"south-american","lines":[[[-82,12],[-62,10],[-45,-2],[-35,-8],[-30,-20],[-40,-35],[-55,-42],[-70,-52],[-78,-40],[-80,-20],[-82,12]]]},{"id":"african","lines":[[[-20,35],[10,37],[32,32],[43,12],[51,10],[42,-8],[40,-25],[25,-35],[15,-30],[8,-5],[-8,5],[-17,15],[-20,35]]]},{"id":"eurasian","lines":[[[-10,36],[0,45],[15,55],[30,68],[60,72],[100,76],[140,70],[160,60],[140,42],[120,30],[100,20],[75,8],[60,22],[45,30],[30,32],[10,37],[-10,36]]]},{"id":"indo-australian","lines":[[[95,5],[115,10],[130,5],[145,-5],[150,-20],[145,-35],[130,-42],[115,-38],[105,-25],[95,-10],[95,5]]]},{"id":"antarctic","lines":[[[-180,-60],[-120,-62],[-60,-60],[0,-62],[60,-60],[120,-62],[180,-60],[180,-90],[-180,-90],[-180,-60]]]},{"id":"nazca","lines":[[[-95,-5],[-85,-10],[-75,-25],[-78,-40],[-90,-42],[-100,-30],[-95,-5]]]},{"id":"cocos","lines":[[[-105,10],[-95,12],[-90,5],[-100,2],[-105,10]]]},{"id":"caribbean","lines":[[[-88,15],[-75,18],[-62,15],[-60,8],[-72,6],[-85,8],[-88,15]]]},{"id":"philippine","lines":[[[118,20],[128,18],[130,8],[125,2],[118,8],[118,20]]]},{"id":"arabian","lines":[[[35,32],[48,30],[58,22],[55,12],[42,10],[35,20],[35,32]]]}]}
Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

@@ -0,0 +1,88 @@
{
"schemaVersion": 1,
"type": "geography",
"defaultView": "zones",
"views": [
"zones",
"coast",
"plates"
],
"nameI18n": {
"zh-CN": "地球地理",
"en": "Earth Geography"
},
"descriptionI18n": {
"zh-CN": "五带划分 · 七大洲四大洋 · 六大板块与洲界",
"en": "Climate zones · continents & oceans · plates & borders"
},
"tropicDeg": 23.5,
"axialTiltDeg": 23.5,
"oceanColor": "#0E2A4A",
"zones": [
{
"id": "torrid",
"latMin": -23.5,
"latMax": 23.5,
"nameI18n": {
"zh-CN": "热带",
"en": "Torrid zone"
},
"descI18n": {
"zh-CN": "南北回归线之间,有太阳直射,终年高温。",
"en": "Between the tropics; the Sun is overhead at some time each year."
}
},
{
"id": "north-temperate",
"latMin": 23.5,
"latMax": 66.5,
"nameI18n": {
"zh-CN": "北温带",
"en": "North temperate"
},
"descI18n": {
"zh-CN": "北回归线与北极圈之间,四季分明,无直射也无极昼极夜。",
"en": "Between Tropic of Cancer and Arctic Circle; four distinct seasons."
}
},
{
"id": "south-temperate",
"latMin": -66.5,
"latMax": -23.5,
"nameI18n": {
"zh-CN": "南温带",
"en": "South temperate"
},
"descI18n": {
"zh-CN": "南回归线与南极圈之间,四季分明。",
"en": "Between Tropic of Capricorn and Antarctic Circle; four seasons."
}
},
{
"id": "north-frigid",
"latMin": 66.5,
"latMax": 90,
"nameI18n": {
"zh-CN": "北寒带",
"en": "North frigid zone"
},
"descI18n": {
"zh-CN": "北极圈以北,有极昼极夜,终年寒冷。",
"en": "North of the Arctic Circle; polar day/night, always cold."
}
},
{
"id": "south-frigid",
"latMin": -90,
"latMax": -66.5,
"nameI18n": {
"zh-CN": "南寒带",
"en": "South frigid zone"
},
"descI18n": {
"zh-CN": "南极圈以南,有极昼极夜,终年寒冷。",
"en": "South of the Antarctic Circle; polar day/night, always cold."
}
}
]
}
@@ -0,0 +1,29 @@
{
"schemaVersion": 1,
"id": "earth-revolution",
"name": "Earth Revolution",
"nameI18n": {
"zh-CN": "地球公转",
"en": "Earth Revolution"
},
"author": "NeoRF",
"description": "四季更替、黄赤交角与二分二至",
"descriptionI18n": {
"zh-CN": "地球绕太阳公转一年:地轴指向不变,太阳直射点南北往返,形成四季。",
"en": "One year around the Sun: the fixed axial direction moves the subsolar point and creates the seasons."
},
"tags": [
"astronomy",
"geography",
"revolution"
],
"entry": "scene.json",
"license": "MIT",
"assembly": "EarthRevolutionModel.dll",
"type": "NeoRF.EarthModels.RevolutionModelFactory",
"preview": "preview.png",
"apiVersion": 1,
"version": "1.0",
"updatedAt": "2026-11-08T09:22:29Z",
"build": "a24be3664d"
}
@@ -0,0 +1,33 @@
{
"title": "Earth Revolution",
"view.rotation": "Rotation",
"view.revolution": "Revolution",
"play": "Play",
"pause": "Pause",
"speed": "Speed",
"reset": "Reset",
"labels": "Labels",
"orbit": "Orbit",
"grid": "Graticule",
"tilt": "Exaggerate tilt",
"lessons": "Teaching notes",
"seasons": "Solstices & equinoxes",
"close": "Close window",
"loading": "Preparing scene…",
"subsolar": "Subsolar point",
"north": "North pole",
"south": "South pole",
"northShort": "N",
"southShort": "S",
"sun": "Sun",
"earth": "Earth",
"spinInfo": "Rotation {0}° · period {1} h",
"orbitInfo": "Orbit {0}°",
"declinationInfo": "Subsolar {0}",
"dateInfo": "Date {0}",
"season.springEquinox": "Spring equinox",
"season.summerSolstice": "Summer solstice",
"season.autumnEquinox": "Autumn equinox",
"season.winterSolstice": "Winter solstice",
"hint": "Pinch or scroll to zoom · drag to turn the Earth"
}
@@ -0,0 +1,33 @@
{
"title": "地球自转",
"view.rotation": "自转",
"view.revolution": "公转",
"play": "播放",
"pause": "暂停",
"speed": "速度",
"reset": "重置",
"labels": "标注",
"orbit": "轨道",
"grid": "经纬网",
"tilt": "夸张倾角",
"lessons": "教学要点",
"seasons": "节气定位",
"close": "关闭窗口",
"loading": "正在准备场景…",
"subsolar": "太阳直射点",
"north": "北极",
"south": "南极",
"northShort": "N",
"southShort": "S",
"sun": "太阳",
"earth": "地球",
"spinInfo": "自转 {0}° · 周期 {1} 小时",
"orbitInfo": "公转 {0}°",
"declinationInfo": "太阳直射 {0}",
"dateInfo": "日期 {0}",
"season.springEquinox": "春分",
"season.summerSolstice": "夏至",
"season.autumnEquinox": "秋分",
"season.winterSolstice": "冬至",
"hint": "双指捏合或滚轮缩放 · 拖动可转动地球"
}
@@ -0,0 +1,98 @@
{
"schema": 1,
"note": "简化大陆轮廓(经度,纬度),用于教学演示,非测绘精度",
"polygons": [
{
"name": "north-america",
"points": [[-168,66],[-164,70],[-155,71],[-145,70],[-133,69],[-120,69],[-110,68],[-100,69],[-92,68],[-85,70],[-80,73],[-72,71],[-64,66],[-60,60],[-56,52],[-60,47],[-66,45],[-70,42],[-74,40],[-76,35],[-81,31],[-80,25],[-83,29],[-88,30],[-94,29],[-97,26],[-97,21],[-92,19],[-87,21],[-88,16],[-83,9],[-78,9],[-84,14],[-90,14],[-96,16],[-105,20],[-112,25],[-117,32],[-122,37],[-124,42],[-125,48],[-131,54],[-140,59],[-150,59],[-158,56],[-165,60],[-166,64]]
},
{
"name": "greenland",
"points": [[-45,60],[-52,64],[-55,68],[-60,72],[-63,76],[-56,80],[-42,82],[-28,80],[-21,74],[-23,70],[-31,66],[-38,62]]
},
{
"name": "south-america",
"points": [[-78,8],[-72,11],[-64,10],[-60,8],[-52,5],[-50,0],[-44,-2],[-38,-5],[-35,-8],[-39,-13],[-41,-22],[-48,-25],[-53,-34],[-57,-38],[-62,-40],[-65,-45],[-68,-50],[-70,-55],[-75,-52],[-74,-45],[-73,-37],[-71,-30],[-70,-23],[-70,-18],[-76,-14],[-81,-6],[-80,-2],[-79,2],[-77,6]]
},
{
"name": "africa",
"points": [[-17,15],[-16,20],[-13,28],[-9,32],[-5,36],[10,37],[20,32],[32,31],[35,28],[39,15],[43,11],[51,12],[48,2],[41,-2],[40,-10],[35,-18],[32,-25],[27,-33],[20,-35],[15,-28],[12,-17],[9,-1],[5,4],[-4,5],[-8,4],[-13,8],[-16,12]]
},
{
"name": "europe",
"points": [[-9,38],[-9,43],[-2,44],[0,48],[2,51],[5,53],[8,54],[9,57],[12,56],[13,54],[20,54],[21,57],[24,58],[28,60],[30,60],[29,64],[25,66],[22,69],[30,70],[40,68],[46,66],[55,68],[60,70],[68,68],[62,62],[58,56],[52,50],[48,46],[40,45],[36,44],[30,45],[28,41],[24,40],[23,37],[19,40],[16,41],[12,44],[7,44],[3,42],[-2,37]]
},
{
"name": "asia",
"points": [[60,70],[75,73],[90,75],[105,77],[115,74],[130,73],[145,72],[160,70],[170,68],[180,65],[172,62],[163,58],[155,52],[143,54],[137,50],[130,43],[126,40],[122,40],[120,36],[122,31],[118,25],[110,21],[105,10],[100,13],[98,8],[95,17],[90,22],[88,21],[80,16],[77,8],[73,18],[68,23],[62,25],[57,24],[52,28],[48,30],[44,13],[43,17],[39,21],[35,28],[34,31],[36,36],[30,41],[28,41],[30,45],[34,45],[40,45],[48,46],[52,50],[58,56],[62,62],[68,68]]
},
{
"name": "australia",
"points": [[113,-22],[114,-27],[116,-35],[129,-32],[138,-35],[146,-39],[150,-37],[153,-28],[146,-19],[142,-11],[132,-11],[126,-14],[122,-18]]
},
{
"name": "antarctica",
"points": [[-180,-72],[-150,-76],[-120,-74],[-90,-73],[-60,-64],[-30,-70],[0,-70],[30,-69],[60,-67],[90,-66],[120,-66],[150,-70],[180,-72],[180,-90],[-180,-90]]
},
{
"name": "madagascar",
"points": [[43,-12],[50,-15],[50,-25],[45,-25],[43,-20]]
},
{
"name": "japan",
"points": [[130,32],[136,35],[141,40],[145,44],[142,39],[137,34],[133,33]]
},
{
"name": "britain",
"points": [[-6,50],[-2,53],[-2,58],[-5,58],[-6,54]]
},
{
"name": "ireland",
"points": [[-10,52],[-6,53],[-6,55],[-10,55]]
},
{
"name": "iceland",
"points": [[-24,65],[-14,66],[-14,64],[-22,63]]
},
{
"name": "new-zealand",
"points": [[166,-46],[170,-44],[174,-41],[177,-38],[174,-35],[170,-38],[167,-42]]
},
{
"name": "sumatra",
"points": [[95,5],[100,1],[105,-6],[100,-4],[96,2]]
},
{
"name": "java",
"points": [[105,-6],[114,-8],[114,-9],[106,-7]]
},
{
"name": "borneo",
"points": [[109,2],[117,4],[119,-2],[115,-4],[110,-2]]
},
{
"name": "sulawesi",
"points": [[119,1],[125,1],[123,-5],[120,-3]]
},
{
"name": "new-guinea",
"points": [[131,-1],[141,-3],[150,-6],[147,-9],[140,-9],[134,-5]]
},
{
"name": "sri-lanka",
"points": [[80,9],[82,7],[81,6],[79,7]]
},
{
"name": "philippines",
"points": [[120,18],[124,13],[126,8],[122,6],[120,12]]
},
{
"name": "cuba",
"points": [[-85,22],[-77,20],[-74,20],[-80,23]]
},
{
"name": "taiwan",
"points": [[120,25],[122,24],[121,22],[120,23]]
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

@@ -0,0 +1,139 @@
{
"schemaVersion": 1,
"type": "planet",
"defaultView": "revolution",
"views": [
"revolution"
],
"nameI18n": {
"zh-CN": "地球公转",
"en": "Earth Revolution"
},
"descriptionI18n": {
"zh-CN": "地球绕太阳公转一年:地轴指向不变,太阳直射点南北往返,形成四季。",
"en": "One year around the Sun: the fixed axial direction moves the subsolar point and creates the seasons."
},
"star": {
"name": "Sun",
"nameI18n": {
"zh-CN": "太阳",
"en": "Sun"
},
"color": "#FFC24B",
"radiusScale": 0.5
},
"planet": {
"name": "Earth",
"nameI18n": {
"zh-CN": "地球",
"en": "Earth"
},
"axialTiltDeg": 23.5,
"tropicDeg": 23.5,
"rotationHours": 23.93,
"orbitDays": 365.26,
"oceanColor": "#1C5FA8",
"landColor": "#4E8C4C",
"iceColor": "#E9EFF6",
"landFile": "land.json",
"showGraticule": false
},
"orbit": {
"semiMajorAxis": 4.0,
"eccentricity": 0.0167,
"show": true,
"seasonLayout": "springTopSummerLeft",
"seasons": [
{
"angleDeg": 0,
"key": "season.springEquinox",
"date": "3/21",
"declinationDeg": 0,
"teachingI18n": {
"zh-CN": "太阳直射赤道,全球昼夜平分。此后直射点由赤道向北移动。",
"en": "The Sun is overhead at the equator and day equals night everywhere. The subsolar point now moves north."
}
},
{
"angleDeg": 90,
"key": "season.summerSolstice",
"date": "6/22",
"declinationDeg": 23.5,
"teachingI18n": {
"zh-CN": "太阳直射北回归线 23.5°N。北半球昼最长、夜最短,北极圈内出现极昼。",
"en": "The Sun is overhead at the Tropic of Cancer (23.5°N). The northern hemisphere has its longest day."
}
},
{
"angleDeg": 180,
"key": "season.autumnEquinox",
"date": "9/23",
"declinationDeg": 0,
"teachingI18n": {
"zh-CN": "太阳再次直射赤道,全球昼夜平分。此后直射点向南移动。",
"en": "The Sun is overhead at the equator again. The subsolar point now moves south."
}
},
{
"angleDeg": 270,
"key": "season.winterSolstice",
"date": "12/22",
"declinationDeg": -23.5,
"teachingI18n": {
"zh-CN": "太阳直射南回归线 23.5°S。北半球昼最短、夜最长,北极圈内出现极夜。",
"en": "The Sun is overhead at the Tropic of Capricorn (23.5°S). The northern hemisphere has its shortest day."
}
}
]
},
"lessons": [
{
"titleI18n": {
"zh-CN": "一年绕太阳一圈",
"en": "One lap per year"
},
"bodyI18n": {
"zh-CN": "公转方向与自转相同,周期约 365.26 天;轨道接近圆形。",
"en": "The orbit takes about 365.26 days and runs the same direction as the spin."
},
"view": "revolution",
"angleDeg": 0
},
{
"titleI18n": {
"zh-CN": "地轴指向不变",
"en": "The axis keeps its direction"
},
"bodyI18n": {
"zh-CN": "公转过程中地轴始终指向北极星附近,黄赤交角 23.5° 保持不变。",
"en": "During the whole orbit the axis keeps pointing near Polaris, so the 23.5° tilt stays fixed in space."
},
"view": "revolution",
"angleDeg": 90
},
{
"titleI18n": {
"zh-CN": "夏至与冬至",
"en": "Solstices"
},
"bodyI18n": {
"zh-CN": "夏至太阳直射北回归线 23.5°N,北半球昼最长;冬至直射南回归线 23.5°S。",
"en": "At the June solstice the Sun is overhead at 23.5°N; at the December solstice at 23.5°S."
},
"view": "revolution",
"angleDeg": 90
},
{
"titleI18n": {
"zh-CN": "春分与秋分",
"en": "Equinoxes"
},
"bodyI18n": {
"zh-CN": "春分、秋分太阳直射赤道,全球昼夜平分,是四季的转折点。",
"en": "At the equinoxes the Sun is overhead at the equator and day equals night everywhere."
},
"view": "revolution",
"angleDeg": 180
}
]
}
@@ -0,0 +1,29 @@
{
"schemaVersion": 1,
"id": "earth-rotation",
"name": "Earth Rotation",
"nameI18n": {
"zh-CN": "地球自转",
"en": "Earth Rotation"
},
"author": "NeoRF",
"description": "昼夜交替、晨昏线与太阳直射点",
"descriptionI18n": {
"zh-CN": "观察自转中的地球:昼夜半球、晨昏线与太阳直射点位置。",
"en": "Watch a rotating Earth: day/night hemispheres, terminator and the subsolar point."
},
"tags": [
"astronomy",
"geography",
"rotation"
],
"entry": "scene.json",
"license": "MIT",
"assembly": "EarthRotationModel.dll",
"type": "NeoRF.EarthModels.RotationModelFactory",
"preview": "preview.png",
"apiVersion": 1,
"version": "1.0",
"updatedAt": "2026-11-08T09:22:29Z",
"build": "0bd5b4507c"
}
@@ -0,0 +1,33 @@
{
"title": "Earth Rotation",
"view.rotation": "Rotation",
"view.revolution": "Revolution",
"play": "Play",
"pause": "Pause",
"speed": "Speed",
"reset": "Reset",
"labels": "Labels",
"orbit": "Orbit",
"grid": "Graticule",
"tilt": "Exaggerate tilt",
"lessons": "Teaching notes",
"seasons": "Solstices & equinoxes",
"close": "Close window",
"loading": "Preparing scene…",
"subsolar": "Subsolar point",
"north": "North pole",
"south": "South pole",
"northShort": "N",
"southShort": "S",
"sun": "Sun",
"earth": "Earth",
"spinInfo": "Rotation {0}° · period {1} h",
"orbitInfo": "Orbit {0}°",
"declinationInfo": "Subsolar {0}",
"dateInfo": "Date {0}",
"season.springEquinox": "Spring equinox",
"season.summerSolstice": "Summer solstice",
"season.autumnEquinox": "Autumn equinox",
"season.winterSolstice": "Winter solstice",
"hint": "Pinch or scroll to zoom · drag to turn the Earth"
}
@@ -0,0 +1,33 @@
{
"title": "地球自转",
"view.rotation": "自转",
"view.revolution": "公转",
"play": "播放",
"pause": "暂停",
"speed": "速度",
"reset": "重置",
"labels": "标注",
"orbit": "轨道",
"grid": "经纬网",
"tilt": "夸张倾角",
"lessons": "教学要点",
"seasons": "节气定位",
"close": "关闭窗口",
"loading": "正在准备场景…",
"subsolar": "太阳直射点",
"north": "北极",
"south": "南极",
"northShort": "N",
"southShort": "S",
"sun": "太阳",
"earth": "地球",
"spinInfo": "自转 {0}° · 周期 {1} 小时",
"orbitInfo": "公转 {0}°",
"declinationInfo": "太阳直射 {0}",
"dateInfo": "日期 {0}",
"season.springEquinox": "春分",
"season.summerSolstice": "夏至",
"season.autumnEquinox": "秋分",
"season.winterSolstice": "冬至",
"hint": "双指捏合或滚轮缩放 · 拖动可转动地球"
}
@@ -0,0 +1,98 @@
{
"schema": 1,
"note": "简化大陆轮廓(经度,纬度),用于教学演示,非测绘精度",
"polygons": [
{
"name": "north-america",
"points": [[-168,66],[-164,70],[-155,71],[-145,70],[-133,69],[-120,69],[-110,68],[-100,69],[-92,68],[-85,70],[-80,73],[-72,71],[-64,66],[-60,60],[-56,52],[-60,47],[-66,45],[-70,42],[-74,40],[-76,35],[-81,31],[-80,25],[-83,29],[-88,30],[-94,29],[-97,26],[-97,21],[-92,19],[-87,21],[-88,16],[-83,9],[-78,9],[-84,14],[-90,14],[-96,16],[-105,20],[-112,25],[-117,32],[-122,37],[-124,42],[-125,48],[-131,54],[-140,59],[-150,59],[-158,56],[-165,60],[-166,64]]
},
{
"name": "greenland",
"points": [[-45,60],[-52,64],[-55,68],[-60,72],[-63,76],[-56,80],[-42,82],[-28,80],[-21,74],[-23,70],[-31,66],[-38,62]]
},
{
"name": "south-america",
"points": [[-78,8],[-72,11],[-64,10],[-60,8],[-52,5],[-50,0],[-44,-2],[-38,-5],[-35,-8],[-39,-13],[-41,-22],[-48,-25],[-53,-34],[-57,-38],[-62,-40],[-65,-45],[-68,-50],[-70,-55],[-75,-52],[-74,-45],[-73,-37],[-71,-30],[-70,-23],[-70,-18],[-76,-14],[-81,-6],[-80,-2],[-79,2],[-77,6]]
},
{
"name": "africa",
"points": [[-17,15],[-16,20],[-13,28],[-9,32],[-5,36],[10,37],[20,32],[32,31],[35,28],[39,15],[43,11],[51,12],[48,2],[41,-2],[40,-10],[35,-18],[32,-25],[27,-33],[20,-35],[15,-28],[12,-17],[9,-1],[5,4],[-4,5],[-8,4],[-13,8],[-16,12]]
},
{
"name": "europe",
"points": [[-9,38],[-9,43],[-2,44],[0,48],[2,51],[5,53],[8,54],[9,57],[12,56],[13,54],[20,54],[21,57],[24,58],[28,60],[30,60],[29,64],[25,66],[22,69],[30,70],[40,68],[46,66],[55,68],[60,70],[68,68],[62,62],[58,56],[52,50],[48,46],[40,45],[36,44],[30,45],[28,41],[24,40],[23,37],[19,40],[16,41],[12,44],[7,44],[3,42],[-2,37]]
},
{
"name": "asia",
"points": [[60,70],[75,73],[90,75],[105,77],[115,74],[130,73],[145,72],[160,70],[170,68],[180,65],[172,62],[163,58],[155,52],[143,54],[137,50],[130,43],[126,40],[122,40],[120,36],[122,31],[118,25],[110,21],[105,10],[100,13],[98,8],[95,17],[90,22],[88,21],[80,16],[77,8],[73,18],[68,23],[62,25],[57,24],[52,28],[48,30],[44,13],[43,17],[39,21],[35,28],[34,31],[36,36],[30,41],[28,41],[30,45],[34,45],[40,45],[48,46],[52,50],[58,56],[62,62],[68,68]]
},
{
"name": "australia",
"points": [[113,-22],[114,-27],[116,-35],[129,-32],[138,-35],[146,-39],[150,-37],[153,-28],[146,-19],[142,-11],[132,-11],[126,-14],[122,-18]]
},
{
"name": "antarctica",
"points": [[-180,-72],[-150,-76],[-120,-74],[-90,-73],[-60,-64],[-30,-70],[0,-70],[30,-69],[60,-67],[90,-66],[120,-66],[150,-70],[180,-72],[180,-90],[-180,-90]]
},
{
"name": "madagascar",
"points": [[43,-12],[50,-15],[50,-25],[45,-25],[43,-20]]
},
{
"name": "japan",
"points": [[130,32],[136,35],[141,40],[145,44],[142,39],[137,34],[133,33]]
},
{
"name": "britain",
"points": [[-6,50],[-2,53],[-2,58],[-5,58],[-6,54]]
},
{
"name": "ireland",
"points": [[-10,52],[-6,53],[-6,55],[-10,55]]
},
{
"name": "iceland",
"points": [[-24,65],[-14,66],[-14,64],[-22,63]]
},
{
"name": "new-zealand",
"points": [[166,-46],[170,-44],[174,-41],[177,-38],[174,-35],[170,-38],[167,-42]]
},
{
"name": "sumatra",
"points": [[95,5],[100,1],[105,-6],[100,-4],[96,2]]
},
{
"name": "java",
"points": [[105,-6],[114,-8],[114,-9],[106,-7]]
},
{
"name": "borneo",
"points": [[109,2],[117,4],[119,-2],[115,-4],[110,-2]]
},
{
"name": "sulawesi",
"points": [[119,1],[125,1],[123,-5],[120,-3]]
},
{
"name": "new-guinea",
"points": [[131,-1],[141,-3],[150,-6],[147,-9],[140,-9],[134,-5]]
},
{
"name": "sri-lanka",
"points": [[80,9],[82,7],[81,6],[79,7]]
},
{
"name": "philippines",
"points": [[120,18],[124,13],[126,8],[122,6],[120,12]]
},
{
"name": "cuba",
"points": [[-85,22],[-77,20],[-74,20],[-80,23]]
},
{
"name": "taiwan",
"points": [[120,25],[122,24],[121,22],[120,23]]
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

@@ -0,0 +1,138 @@
{
"schemaVersion": 1,
"type": "planet",
"defaultView": "rotation",
"views": [
"rotation"
],
"nameI18n": {
"zh-CN": "地球自转",
"en": "Earth Rotation"
},
"descriptionI18n": {
"zh-CN": "观察自转中的地球:昼夜半球、晨昏线与太阳直射点位置。",
"en": "Watch a rotating Earth: day/night hemispheres, terminator and the subsolar point."
},
"star": {
"name": "Sun",
"nameI18n": {
"zh-CN": "太阳",
"en": "Sun"
},
"color": "#FFC24B",
"radiusScale": 0.5
},
"planet": {
"name": "Earth",
"nameI18n": {
"zh-CN": "地球",
"en": "Earth"
},
"axialTiltDeg": 23.5,
"tropicDeg": 23.5,
"rotationHours": 23.93,
"orbitDays": 365.26,
"oceanColor": "#1C5FA8",
"landColor": "#4E8C4C",
"iceColor": "#E9EFF6",
"landFile": "land.json",
"showGraticule": true
},
"orbit": {
"semiMajorAxis": 4.0,
"eccentricity": 0.0167,
"show": true,
"seasons": [
{
"angleDeg": 0,
"key": "season.springEquinox",
"date": "3/21",
"declinationDeg": 0,
"teachingI18n": {
"zh-CN": "太阳直射赤道,全球昼夜平分。",
"en": "The Sun is overhead at the equator and day equals night everywhere."
}
},
{
"angleDeg": 90,
"key": "season.summerSolstice",
"date": "6/22",
"declinationDeg": 23.5,
"teachingI18n": {
"zh-CN": "太阳直射北回归线 23.5°N,北半球昼最长。",
"en": "The Sun is overhead at 23.5°N; the northern hemisphere has its longest day."
}
},
{
"angleDeg": 180,
"key": "season.autumnEquinox",
"date": "9/23",
"declinationDeg": 0,
"teachingI18n": {
"zh-CN": "太阳直射赤道,全球昼夜平分。",
"en": "The Sun is overhead at the equator and day equals night everywhere."
}
},
{
"angleDeg": 270,
"key": "season.winterSolstice",
"date": "12/22",
"declinationDeg": -23.5,
"teachingI18n": {
"zh-CN": "太阳直射南回归线 23.5°S,北半球昼最短。",
"en": "The Sun is overhead at 23.5°S; the northern hemisphere has its shortest day."
}
}
]
},
"lessons": [
{
"titleI18n": {
"zh-CN": "自西向东的自转",
"en": "Rotation from west to east"
},
"bodyI18n": {
"zh-CN": "从北极上空看,地球逆时针转动;转一圈用 23 小时 56 分 4 秒。",
"en": "Seen from above the north pole the Earth turns counter-clockwise, once every 23 h 56 min."
},
"view": "rotation",
"angleDeg": 0
},
{
"titleI18n": {
"zh-CN": "昼夜交替",
"en": "Day and night"
},
"bodyI18n": {
"zh-CN": "晨昏线(白色虚线)把地球分成昼半球与夜半球,交替周期 24 小时。",
"en": "The terminator (white dashes) splits the lit and dark hemispheres; one cycle takes 24 h."
},
"view": "rotation",
"angleDeg": 60
},
{
"titleI18n": {
"zh-CN": "太阳直射点",
"en": "Subsolar point"
},
"bodyI18n": {
"zh-CN": "黄色圆环标出太阳光垂直照射的位置,它随季节在南北回归线之间往返。",
"en": "The yellow ring marks where sunlight strikes vertically — it drifts between the tropics over a year."
},
"view": "rotation",
"angleDeg": 120
},
{
"titleI18n": {
"zh-CN": "地轴倾斜 23.5°",
"en": "Axial tilt 23.5°"
},
"bodyI18n": {
"zh-CN": "地轴与黄道面法线成 23.5°,倾斜方向不变,这是四季与五带划分的根本原因。",
"en": "The axis is tilted 23.5° from the ecliptic normal and keeps its direction — the root cause of seasons."
},
"view": "rotation",
"angleDeg": 200
}
]
}
+21
View File
@@ -0,0 +1,21 @@
{
"language": "auto",
"theme": "light",
"renderFps": 120,
"memoryMb": 2048,
"memoryAuto": true,
"checkSourceOnStartup": false,
"sources": [
{
"id": "gitcode-official",
"name": "Morris GC (GitCode)",
"url": "https://gitcode.com/2509_92447106/GC",
"enabled": true,
"builtIn": true
}
],
"recentModels": [],
"autoUpdateOnStartup": true,
"updateRepository": "https://gitcode.com/2509_92447106/GC",
"installedModelVersions": {}
}
+15
View File
@@ -0,0 +1,15 @@
.venv/
venv/
env/
.idea/
.vscode/
.DS_Store
__pycache__/
*.pyc
*.pyo
*.log
node_modules/
dist/
build/
.pytest_cache/
.mypy_cache/
+29
View File
@@ -0,0 +1,29 @@
<Project>
<!--
多目录结构公共属性:
src/main/dotnet/<module> 生产代码
src/test/dotnet/<module> 测试 / 离屏渲染校验
TargetFramework 可由命令行覆盖:dotnet build -p:TargetFramework=net10.0
-->
<PropertyGroup Condition="'$(TargetFramework)' == ''">
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<!--
Avalonia.BuildServices 的遥测任务会向用户目录写 buildtasks.log。
在只读用户目录 / CI / 沙箱里该写入抛 UnauthorizedAccessException(MSB4018),
直接让整个解决方案编译失败(实测)。官方开关是环境变量
AVALONIA_TELEMETRY_OPTOUT=1(MSBuild 属性对 11.3.2 无效),
build.sh / build.ps1 已默认导出;IDE 直接编译时无需此变量。
-->
<AvaloniaVersion>11.3.9</AvaloniaVersion>
<MvvmVersion>8.2.2</MvvmVersion>
<Version>1.0.3</Version>
<Company>NeoRF</Company>
<Product>Earth Model Studio</Product>
<NeutralLanguage>zh-Hans</NeutralLanguage>
</PropertyGroup>
</Project>
+10
View File
@@ -0,0 +1,10 @@
<Project>
<!--
Avalonia.BuildServices 11.3.x 的 AvaloniaStats 任务会向
~/Library/Application Support/AvaloniaUI/BuildServices/buildtasks.log 写遥测日志。
只读用户目录 / CI / 沙箱里该写入抛 UnauthorizedAccessException(MSB4018),
会让整个解决方案编译失败(实测)。这是纯统计任务,不影响产物,直接禁用。
在 buildTransitive/*.targets 之后导入,同名 Target 覆盖即可(MSBuild 后定义者优先)。
-->
<Target Name="AvaloniaStats" />
</Project>
+127
View File
@@ -0,0 +1,127 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "main", "main", "{ABAA6554-252E-13CE-1B40-0464A7DBA771}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dotnet", "dotnet", "{F2BBD9FE-F148-5687-ED21-3ABA515A9B22}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EarthModelStudio", "src\main\dotnet\EarthModelStudio\EarthModelStudio.csproj", "{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3E72BF5C-0B5E-D5BD-DCAE-6B991004B4A5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dotnet", "dotnet", "{09578AA7-0862-3E52-D2AA-D8F7E863B74B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EarthModelStudio.Tests", "src\test\dotnet\EarthModelStudio.Tests\EarthModelStudio.Tests.csproj", "{D15CB92F-5E5C-4516-8D07-C244FC0CD113}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_sdk", "_sdk", "{26AABC0C-8B8D-F9B8-86B4-01B1A96D59F4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EarthModelStudio.ModelSdk", "model\_sdk\EarthModelStudio.ModelSdk\EarthModelStudio.ModelSdk.csproj", "{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "model", "model", "{62B8A37E-7066-D91A-6443-87D4E6CE63FE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "earth-rotation", "earth-rotation", "{EBCD2737-5E64-9C5F-5D8B-D0375EC50F43}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{13F93445-B061-AC9E-97CA-8C4FA55DC418}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EarthRotationModel", "model\earth-rotation\src\EarthRotationModel.csproj", "{64556F71-7456-43B2-890C-CF01AD29D386}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "earth-revolution", "earth-revolution", "{0B92F86C-37C2-3C12-904C-85123CE34F4C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EADF0841-BEC2-9A74-4322-069D7B5A6EBB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EarthRevolutionModel", "model\earth-revolution\src\EarthRevolutionModel.csproj", "{6BD9C21B-8F06-4F60-A087-696B6F03CC25}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}.Debug|x64.ActiveCfg = Debug|Any CPU
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}.Debug|x64.Build.0 = Debug|Any CPU
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}.Debug|x86.ActiveCfg = Debug|Any CPU
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}.Debug|x86.Build.0 = Debug|Any CPU
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}.Release|Any CPU.Build.0 = Release|Any CPU
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}.Release|x64.ActiveCfg = Release|Any CPU
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}.Release|x64.Build.0 = Release|Any CPU
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}.Release|x86.ActiveCfg = Release|Any CPU
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C}.Release|x86.Build.0 = Release|Any CPU
{D15CB92F-5E5C-4516-8D07-C244FC0CD113}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D15CB92F-5E5C-4516-8D07-C244FC0CD113}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D15CB92F-5E5C-4516-8D07-C244FC0CD113}.Debug|x64.ActiveCfg = Debug|Any CPU
{D15CB92F-5E5C-4516-8D07-C244FC0CD113}.Debug|x64.Build.0 = Debug|Any CPU
{D15CB92F-5E5C-4516-8D07-C244FC0CD113}.Debug|x86.ActiveCfg = Debug|Any CPU
{D15CB92F-5E5C-4516-8D07-C244FC0CD113}.Debug|x86.Build.0 = Debug|Any CPU
{D15CB92F-5E5C-4516-8D07-C244FC0CD113}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D15CB92F-5E5C-4516-8D07-C244FC0CD113}.Release|Any CPU.Build.0 = Release|Any CPU
{D15CB92F-5E5C-4516-8D07-C244FC0CD113}.Release|x64.ActiveCfg = Release|Any CPU
{D15CB92F-5E5C-4516-8D07-C244FC0CD113}.Release|x64.Build.0 = Release|Any CPU
{D15CB92F-5E5C-4516-8D07-C244FC0CD113}.Release|x86.ActiveCfg = Release|Any CPU
{D15CB92F-5E5C-4516-8D07-C244FC0CD113}.Release|x86.Build.0 = Release|Any CPU
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}.Debug|x64.ActiveCfg = Debug|Any CPU
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}.Debug|x64.Build.0 = Debug|Any CPU
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}.Debug|x86.ActiveCfg = Debug|Any CPU
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}.Debug|x86.Build.0 = Debug|Any CPU
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}.Release|Any CPU.Build.0 = Release|Any CPU
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}.Release|x64.ActiveCfg = Release|Any CPU
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}.Release|x64.Build.0 = Release|Any CPU
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}.Release|x86.ActiveCfg = Release|Any CPU
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0}.Release|x86.Build.0 = Release|Any CPU
{64556F71-7456-43B2-890C-CF01AD29D386}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64556F71-7456-43B2-890C-CF01AD29D386}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64556F71-7456-43B2-890C-CF01AD29D386}.Debug|x64.ActiveCfg = Debug|Any CPU
{64556F71-7456-43B2-890C-CF01AD29D386}.Debug|x64.Build.0 = Debug|Any CPU
{64556F71-7456-43B2-890C-CF01AD29D386}.Debug|x86.ActiveCfg = Debug|Any CPU
{64556F71-7456-43B2-890C-CF01AD29D386}.Debug|x86.Build.0 = Debug|Any CPU
{64556F71-7456-43B2-890C-CF01AD29D386}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64556F71-7456-43B2-890C-CF01AD29D386}.Release|Any CPU.Build.0 = Release|Any CPU
{64556F71-7456-43B2-890C-CF01AD29D386}.Release|x64.ActiveCfg = Release|Any CPU
{64556F71-7456-43B2-890C-CF01AD29D386}.Release|x64.Build.0 = Release|Any CPU
{64556F71-7456-43B2-890C-CF01AD29D386}.Release|x86.ActiveCfg = Release|Any CPU
{64556F71-7456-43B2-890C-CF01AD29D386}.Release|x86.Build.0 = Release|Any CPU
{6BD9C21B-8F06-4F60-A087-696B6F03CC25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6BD9C21B-8F06-4F60-A087-696B6F03CC25}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6BD9C21B-8F06-4F60-A087-696B6F03CC25}.Debug|x64.ActiveCfg = Debug|Any CPU
{6BD9C21B-8F06-4F60-A087-696B6F03CC25}.Debug|x64.Build.0 = Debug|Any CPU
{6BD9C21B-8F06-4F60-A087-696B6F03CC25}.Debug|x86.ActiveCfg = Debug|Any CPU
{6BD9C21B-8F06-4F60-A087-696B6F03CC25}.Debug|x86.Build.0 = Debug|Any CPU
{6BD9C21B-8F06-4F60-A087-696B6F03CC25}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6BD9C21B-8F06-4F60-A087-696B6F03CC25}.Release|Any CPU.Build.0 = Release|Any CPU
{6BD9C21B-8F06-4F60-A087-696B6F03CC25}.Release|x64.ActiveCfg = Release|Any CPU
{6BD9C21B-8F06-4F60-A087-696B6F03CC25}.Release|x64.Build.0 = Release|Any CPU
{6BD9C21B-8F06-4F60-A087-696B6F03CC25}.Release|x86.ActiveCfg = Release|Any CPU
{6BD9C21B-8F06-4F60-A087-696B6F03CC25}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{ABAA6554-252E-13CE-1B40-0464A7DBA771} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{F2BBD9FE-F148-5687-ED21-3ABA515A9B22} = {ABAA6554-252E-13CE-1B40-0464A7DBA771}
{2E3BE2DB-1C4B-4EA0-9523-43EE910BD54C} = {F2BBD9FE-F148-5687-ED21-3ABA515A9B22}
{3E72BF5C-0B5E-D5BD-DCAE-6B991004B4A5} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{09578AA7-0862-3E52-D2AA-D8F7E863B74B} = {3E72BF5C-0B5E-D5BD-DCAE-6B991004B4A5}
{D15CB92F-5E5C-4516-8D07-C244FC0CD113} = {09578AA7-0862-3E52-D2AA-D8F7E863B74B}
{C8FAB8D5-CAB7-42D7-8A1F-4B79771A2CE0} = {26AABC0C-8B8D-F9B8-86B4-01B1A96D59F4}
{EBCD2737-5E64-9C5F-5D8B-D0375EC50F43} = {62B8A37E-7066-D91A-6443-87D4E6CE63FE}
{13F93445-B061-AC9E-97CA-8C4FA55DC418} = {EBCD2737-5E64-9C5F-5D8B-D0375EC50F43}
{64556F71-7456-43B2-890C-CF01AD29D386} = {13F93445-B061-AC9E-97CA-8C4FA55DC418}
{0B92F86C-37C2-3C12-904C-85123CE34F4C} = {62B8A37E-7066-D91A-6443-87D4E6CE63FE}
{EADF0841-BEC2-9A74-4322-069D7B5A6EBB} = {0B92F86C-37C2-3C12-904C-85123CE34F4C}
{6BD9C21B-8F06-4F60-A087-696B6F03CC25} = {EADF0841-BEC2-9A74-4322-069D7B5A6EBB}
EndGlobalSection
EndGlobal
+174
View File
@@ -0,0 +1,174 @@
# Earth Model Studio
天文教学模型**启动器**:管理/启动模型、启动时自动检查并下载最新版模型与启动器、设置语言与内存。
> **分层约定(重要)**
> - `src/` = 启动器:扫描、下载、开窗口、显示加载进度、自检更新。**不渲染、不含任何模型内容、发布包不内置模型**。
> - `model/` = 模型的一切:**源码、编译后的 dll、场景数据、封面、语言包、共享引擎、契约**,独立分发、独立版本。
> - 模型相关代码全部直接存在模型目录里,仓库根没有 `model-src/` / `model-sdk/` 这类旁路目录。
> - 想加新内容 = 在 `model/<id>/` 里放模型并推送仓库,`src` 一行都不用改,客户端启动自动更新。
- UI:C# + .NET 8(可切 .NET 10)+ Avalonia,跨平台
- 模型加载:`AssemblyLoadContext` 加载模型自带 dll,契约与 Avalonia 走默认上下文,关窗即卸载
- 目标平台:**macOS arm64 / Windows x64 / Windows arm64**,一条命令全部编译
- 更新仓库:<https://gitcode.com/2509_92447106/GC>,模型目录 <https://gitcode.com/2509_92447106/GC/tree/main/model>
## 运行目录(发布包里就长这样)
```
<安装目录>/
EarthModelStudio.exe | EarthModelStudio.app/
.GC/
settings.json 设置 + 已安装版本记录
model/ 启动时下载的模型
cache/ 下载暂存 / 原子替换
update/ 待下次启动应用的启动器更新
```
**发布包不含任何模型**。首次启动联网检查后把模型下载到 `.GC/model/` 并立刻显示;
安装目录不可写时自动退回用户数据目录。`.GC/` 可以随程序一起搬迁,也可以整个删掉重新下载。
## 自动更新
| 检查项 | 不是最新版时 | 生效时机 |
| --- | --- | --- |
| 模型 | 从 gitcode 下载到 `cache/`,校验后原子替换 `.GC/model/<id>` | **下载后立即应用**(本次启动首页就刷新) |
| 启动器 | 下载对应平台 zip 到 `.GC/update/payload`,写 `pending.json` | **下次启动时应用**(独立脚本覆盖程序并重启) |
- 默认更新仓库写在 `.GC/settings.json` 的 `updateRepository`:
`https://gitcode.com/2509_92447106/GC`(也可换成自己的仓库或 `.../tree/main/model` 地址)
- 版本来自仓库根 `version.json`(由 `./build.sh stamp` 生成):模型版本 = **模型包内容指纹**,
所以**改了模型文件,版本号自动变**;启动器版本 = 构建版本。
- `settings.json` 记录 `installedModelVersions` / `pendingLauncherVersion` / `lastUpdateCheck`。
- 断网、仓库还没推 `version.json`、下载失败:**一律保留本地模型,绝不把模型库清空**,底部状态条说明原因。
- 设置页可关闭自动更新;状态条可手动「检查更新」(忽略开关强制检查)。
- 离线教室:把仓库(含 `version.json` + `model/`)拷到 U 盘,在 `settings.json` 填
`updateLocalRoot` 指向它,即可完全离线更新。
- 发新版:把 `dist/GC-<rid>.zip` 上传到 Release / 仓库 `dist/`,把直链填进 `version.json`
对应平台的 `url`(`./build.sh publish` 会生成 zip 并自动写入 `sha256` / `size`)。
更新包只含程序文件,**不会覆盖 `.GC/` 里的模型与设置**。
## 目录结构
```
EarthModelStudio/
├── EarthModelStudio.sln
├── Directory.Build.props # 公共构建属性
├── version.json # ★ 自动生成的版本清单(推送到仓库后才生效)
├── build.sh / build.ps1 # 构建脚本
├── src/ # ★ 启动器(没有渲染逻辑)
│ └── main/dotnet/EarthModelStudio/
│ ├── Models/ Services/ # 清单/设置/目录探测/i18n/模型库/下载/自动更新
│ │ # UpdateService · GitCodeRemote · DirectoryRemote · LauncherUpdate
│ ├── ViewModels/ Views/ # 主页、下载、设置、模型窗口壳、启动更新状态条
│ └── Assets/i18n/ # 启动器界面语言包
├── src/test/dotnet/…Tests/ # 离屏校验 + --update-test 离线更新链路验证
├── model/ # ★ 模型的一切
│ ├── version.json # 与根 version.json 相同(便于按 model/ 地址读取)
│ ├── _sdk/EarthModelStudio.ModelSdk/
│ ├── _engine/
│ │ ├── src/ # CelestialView / PlanetTexture / EarthModelView …
│ │ ├── PreviewGen/ # 用模型渲染器生成封面
│ │ └── VersionStamp/ # 按内容指纹自动打版本、生成 version.json
│ ├── earth-rotation/
│ │ ├── earth-rotation.json
│ │ ├── src/ # 本模型源码
│ │ └── earth-rotation.model/ # dll + scene.json/land.json + preview.png + i18n
│ └── earth-revolution/
└── dist/ # 发布产物(只有启动器 + .GC 骨架)
```
模型库位置:`EMS_MODELS` 覆盖 → 开发态仓库根 `model/` → **发布态 `<可执行文件>/.GC/model/`**。
## 构建与运行
```bash
./build.sh build # 编译整个解决方案
./build.sh models # 编译模型 dll + 生成封面 + 自动打版本
./build.sh stamp # 只重新生成 version.json 与模型版本
./build.sh run # 运行
./build.sh test # 离屏校验:页面 + 真实加载模型窗口截图
./build.sh update-test # 离线验证自动更新链路(不联网、不替换程序)
./build.sh publish # 三平台发布(不内置模型)+ 建 .GC 骨架 + 生成更新包
./build.sh pack-models # 单独打包模型 -> dist/models-<version>.zip
./build.sh pack-launcher # 生成三个平台的启动器更新包 zip
./build.sh clean
```
Windows 用 `.\build.ps1`(参数相同)。
| 产物 | 平台 |
| --- | --- |
| `dist/mac-arm64/EarthModelStudio.app` | macOS Apple Silicon |
| `dist/win-x64/EarthModelStudio.exe` | Windows x64 |
| `dist/win-arm64/EarthModelStudio.exe` | Windows on ARM |
均为自包含单文件启动器,**发布包内不含模型**。改完模型:
`./build.sh models` → 把 `version.json` 和 `model/` 推送到 gitcode → 客户端下次启动自动更新。
## 模型契约
```csharp
public interface IModelFactory // 模型入口
{
int ApiVersion { get; } // 目前为 1
IModelRuntime Create();
}
public interface IModelRuntime : IDisposable
{
void Prepare(IModelContext context); // 后台线程:读数据、烘焙纹理、汇报进度
Control CreateView(IModelContext context); // UI 线程:模型自己做界面
}
public interface IModelContext
{
string ModelId { get; }
string ModelDirectory { get; }
string DataDirectory { get; }
string Language { get; }
int MemoryBudgetMb { get; }
void RequestClose();
void ReportProgress(double value, string? message = null);
void Log(string message);
}
```
启动器先弹进度窗,在后台调用 `Prepare`(模型用 `ReportProgress` 汇报真实进度),
再在 UI 线程调用 `CreateView`,把返回的控件直接铺满窗口 —— 除此之外什么都不做。
详细清单字段、数据格式、封面生成见 [`model/README.md`](model/README.md)。
## 模型窗口
- 启动模型 → **带进度条的加载窗**(读取数据 → 生成地表纹理 → 构建界面,真实进度)→ 新开独立窗口
- 主界面保持原页面,可同时开多个模型窗口;关窗即卸载模型程序集
- 启动器快捷键 `Esc` 关闭、`F11` 全屏;模型窗口内的快捷键由模型自己定义
## 地球模型(model/_engine + model/<id>/src)
- **地表**:加载时烘焙 1024×512 等经纬度纹理 —— 海洋深度、沙漠/雨林/针叶林/苔原分带、极地冰盖、
山脉起伏(高度梯度参与光照)、云层、夜间城市辉光;每帧只做双线性采样 + 地形光照,60 FPS
- **教材数值**:黄赤交角 / 回归线统一为 **23.5°**,极圈 66.5°;夏至直射 **23.5°N**、冬至 **23.5°S**、
春分秋分 **0°(赤道)**。球面上画出赤道、南北回归线、南北极圈与真实日下点黄圈,读数不受「夸张倾角」影响
- **自转**:球面像素渲染、晨昏线、大气边缘光、经纬网、地轴、太阳直射点;只有自转视角,
**没有节气定位**(节气属于公转)
- **公转**:太阳—轨道—地球全景、地轴方向空间固定、二分二至标记与一键定格、HUD(角度 / 直射纬度 / 日期)
- **触控一体机**:双指捏合缩放(跟手)、滚轮缩放、画布左下角大号 + / − / 复位按钮;
所有工具栏按钮 ≥ 40px。单指或鼠标拖动可直接转动地球,**拖动时画面定格但视角俯仰与轨道平面始终不变**,
俯视角只由「俯视」按钮显式切换
- **课堂演示**:点二分二至自动暂停定格并显示节气、教材日期、直射纬度与现象说明;
右侧课堂卡含可放大观察到的「地球特写」;`◀ ▶` 步进 5°、教学要点点击自动定格定位;
快捷键 `空格` 播放/暂停、`← →` 步进、`1–4` 二分二至、`F` 全屏、`+ -` 缩放、`0` 复位视角
- 节气日期、直射纬度、现象说明、教学要点全部写在 `scene.json` 里;夸张倾角只改示意图形,不改教学读数
## 模型源(手动导入)
除了启动时自动更新,「下载」页还支持手动导入普通 git 仓库:
**仓库根目录下的 `model/` 文件夹即模型列表**。支持 GitHub / GitLab / Gitee(zip 归档,
失败回退 `git clone --depth 1`)、zip 直链、本地目录。导入后缓存在 `数据目录/cache/sources/<id>`。
## 启动时运行内存分配
设置页的「启动时运行内存分配」类似启动器的 -Xmx:启动器把这份预算通过 `IModelContext.MemoryBudgetMb`
交给模型,具体怎么用(掩膜分辨率、缓存)由模型自己决定。
+228
View File
@@ -0,0 +1,228 @@
# ---------------------------------------------------------------------------
# Earth Model Studio 构建脚本(Windows PowerShell)
#
# .\build.ps1 编译
# .\build.ps1 run 运行
# .\build.ps1 test 离屏渲染校验
# .\build.ps1 models 编译模型 dll + 生成封面 + 自动打版本
# .\build.ps1 stamp 只重新生成 version.json 与模型版本
# .\build.ps1 publish 编译三个平台启动器(不内置模型)+ 建立 .GC 运行目录
# .\build.ps1 pack-models 单独打包模型数据(含 version.json)
# .\build.ps1 pack-launcher 生成三个平台的启动器更新包 zip
# .\build.ps1 update-test 离线验证自动更新链路
# .\build.ps1 clean 清理
#
# 分层:src\ 只是启动器;模型全部在 model\;**发布包不内置模型**。
#
# 运行目录(发布包里就长这样):
# <安装目录>\
# EarthModelStudio.exe
# .GC\settings.json
# .GC\model\ 启动时从 gitcode 下载的模型
# .GC\cache\ 下载暂存
# .GC\update\ 待下次启动应用的启动器更新
# ---------------------------------------------------------------------------
param(
[Parameter(Position = 0)]
[ValidateSet('build', 'run', 'test', 'publish', 'models', 'stamp', 'pack-models',
'pack-launcher', 'update-test', 'bundle', 'clean', 'doctor')]
[string]$Task = 'build'
)
$ErrorActionPreference = 'Stop'
$Root = $PSScriptRoot
Set-Location $Root
# Avalonia 遥测任务在只读用户目录/CI/沙箱会因写日志失败而中断编译(MSB4018)。
# 官方 opt-out;Directory.Build.targets 里还有一层项目内的兜底。
$env:AVALONIA_TELEMETRY_OPTOUT = '1'
$AppProj = 'src/main/dotnet/EarthModelStudio/EarthModelStudio.csproj'
$TestProj = 'src/test/dotnet/EarthModelStudio.Tests/EarthModelStudio.Tests.csproj'
$PreviewProj = 'model/_engine/PreviewGen/PreviewGen.csproj'
$StampProj = 'model/_engine/VersionStamp/VersionStamp.csproj'
$Sln = 'EarthModelStudio.sln'
$Version = '1.0.3'
function Stamp-Versions {
Write-Host '==> 自动计算模型版本并生成 version.json'
dotnet run --project $StampProj -c Release -- $Root $Version
}
function Build-Models {
Write-Host '==> 编译模型功能程序集(源码就在各模型目录的 src\ 里)'
Get-ChildItem "$Root/model" -Directory | ForEach-Object {
$id = $_.Name
$src = Join-Path $_.FullName 'src'
if (-not (Test-Path $src)) { return }
$proj = Get-ChildItem $src -Filter *.csproj | Select-Object -First 1
if ($null -eq $proj) { return }
dotnet build $proj.FullName -c Release
$data = Join-Path $_.FullName "$id.model"
if (Test-Path $data) {
Get-ChildItem (Join-Path $src 'bin/Release/net8.0') -Filter *.dll | ForEach-Object {
if ($_.Name -eq 'EarthModelStudio.ModelSdk.dll') { return }
Copy-Item -Force $_.FullName $data
Write-Host " -> model/$id/$id.model/$($_.Name)"
}
}
}
Write-Host '==> 用模型自己的渲染器生成封面'
dotnet run --project $PreviewProj -c Release -- $Root
Stamp-Versions
}
# 发布目录只放启动器 + 空的 .GC 运行骨架,绝不放模型
function Prepare-RuntimeLayout([string]$RelDir) {
$dest = "$Root/$RelDir"
if (-not (Test-Path $dest)) { return }
foreach ($old in @("$dest/model", "$dest/examples")) {
if (Test-Path $old) { Remove-Item -Recurse -Force $old }
}
foreach ($dir in @("$dest/.GC/model", "$dest/.GC/cache", "$dest/.GC/update")) {
New-Item -ItemType Directory -Force -Path $dir | Out-Null
}
$readme = @'
模型库目录(.GC/model/)
启动时程序会读取 gitcode 仓库的 version.json,把最新版模型下载到这里。
离线使用也可以手动放入 <模型id>/<模型id>.json + <模型id>/<模型id>.model/。
运行目录:
<可执行文件>
.GC/settings.json
.GC/model/ 本目录(下载的模型)
.GC/cache/ 下载暂存
.GC/update/ 待下次启动应用的启动器更新
'@
Set-Content -Path "$dest/.GC/model/README.txt" -Value $readme -Encoding UTF8
$settingsPath = "$dest/.GC/settings.json"
if (-not (Test-Path $settingsPath)) {
$json = @'
{
"language": "auto",
"theme": "light",
"renderFps": 30,
"memoryMb": 2048,
"autoUpdateOnStartup": true,
"updateRepository": "https://gitcode.com/2509_92447106/GC",
"updateManifestUrl": "",
"updateLocalRoot": "",
"installedModelVersions": {},
"launcherVersion": "",
"pendingLauncherVersion": "",
"lastUpdateCheck": "",
"sources": [],
"recentModels": []
}
'@
Set-Content -Path $settingsPath -Value $json -Encoding UTF8
}
Write-Host " 运行目录 -> $RelDir/.GC (settings.json + model/ + cache/ + update/)"
}
function Publish-Rid([string]$Rid, [string]$OutDir) {
Write-Host "==> 编译 $Rid -> $OutDir"
# 先删旧产物目录,避免残留文件混进新包
if (Test-Path "$Root/$OutDir") { Remove-Item -Recurse -Force "$Root/$OutDir" }
dotnet publish $AppProj -c Release -r $Rid --self-contained true `
-p:Version=$Version -p:DebugType=none -p:PublishSingleFile=true `
-p:IncludeNativeLibrariesForSelfExtract=true -p:PublishTrimmed=false -o "$Root/$OutDir"
foreach ($old in @("$Root/$OutDir/model", "$Root/$OutDir/examples")) {
if (Test-Path $old) { Remove-Item -Recurse -Force $old }
}
}
function Pack-Models {
New-Item -ItemType Directory -Force -Path "$Root/dist" | Out-Null
$zip = "$Root/dist/models-$Version.zip"
if (Test-Path $zip) { Remove-Item -Force $zip }
Write-Host "==> 打包模型数据 -> dist/models-$Version.zip"
$stage = Join-Path $env:TEMP "ems-models-stage"
if (Test-Path $stage) { Remove-Item -Recurse -Force $stage }
New-Item -ItemType Directory -Force -Path $stage | Out-Null
Get-ChildItem "$Root/model" -Recurse -File | Where-Object {
$_.FullName -notmatch '\\(bin|obj)\\' -and $_.Extension -ne '.user'
} | ForEach-Object {
$rel = $_.FullName.Substring("$Root/model".Length + 1)
$dest = Join-Path $stage $rel
New-Item -ItemType Directory -Force -Path (Split-Path $dest) | Out-Null
Copy-Item -Force $_.FullName $dest
}
Compress-Archive -Path "$stage/*" -DestinationPath $zip -Force
Remove-Item -Recurse -Force $stage
}
# 启动器更新包:只包含程序文件,排除 .GC(否则会覆盖用户模型与设置)
function Pack-Launcher {
Write-Host '==> 生成启动器更新包(不含 .GC)'
$targets = @{
'GC-win-x64.zip' = "$Root/dist/win-x64"
'GC-win-arm64.zip' = "$Root/dist/win-arm64"
'GC-osx-arm64.zip' = "$Root/dist/mac-arm64/EarthModelStudio.app/Contents/MacOS"
}
if (-not (Test-Path $targets['GC-osx-arm64.zip'])) {
$targets['GC-osx-arm64.zip'] = "$Root/dist/mac-arm64"
}
foreach ($name in $targets.Keys) {
$src = $targets[$name]
if (-not (Test-Path $src)) { continue }
$stage = Join-Path $env:TEMP ("ems-launcher-" + [IO.Path]::GetFileNameWithoutExtension($name))
if (Test-Path $stage) { Remove-Item -Recurse -Force $stage }
New-Item -ItemType Directory -Force -Path $stage | Out-Null
Get-ChildItem $src -Recurse -File | Where-Object {
$_.FullName -notmatch '\\\.GC\\' -and $_.Name -ne '.DS_Store'
} | ForEach-Object {
$rel = $_.FullName.Substring($src.Length).TrimStart('\', '/')
$dest = Join-Path $stage $rel
New-Item -ItemType Directory -Force -Path (Split-Path $dest) | Out-Null
Copy-Item -Force $_.FullName $dest
}
$zip = "$Root/dist/$name"
if (Test-Path $zip) { Remove-Item -Force $zip }
Compress-Archive -Path "$stage/*" -DestinationPath $zip -Force
Remove-Item -Recurse -Force $stage
}
Stamp-Versions
Get-ChildItem "$Root/dist/GC-*.zip" | Select-Object Name, Length
}
switch ($Task) {
'build' {
Get-ChildItem "$Root/dist/GC-*.zip","$Root/dist/models-*.zip" -ErrorAction SilentlyContinue |
Remove-Item -Force
dotnet build $Sln -c Debug
}
'run' { dotnet run --project $AppProj -c Debug }
'test' { dotnet run --project $TestProj -c Debug -- "$Root/build/screenshots" }
'publish' {
# 先清理 dist 旧产物,再重新生成
if (Test-Path "$Root/dist") { Remove-Item -Recurse -Force "$Root/dist" }
New-Item -ItemType Directory -Force -Path "$Root/dist" | Out-Null
Stamp-Versions
Publish-Rid 'osx-arm64' 'dist/mac-arm64'
Publish-Rid 'win-x64' 'dist/win-x64'
Publish-Rid 'win-arm64' 'dist/win-arm64'
Prepare-RuntimeLayout 'dist/win-x64'
Prepare-RuntimeLayout 'dist/win-arm64'
Prepare-RuntimeLayout 'dist/mac-arm64'
Pack-Launcher
Write-Host '==> 三个平台编译完成(发布包不含模型,首次启动自动下载),见 dist\' -ForegroundColor Green
Write-Host ' 把 version.json / model/ 推送到 gitcode,启动器就会自动检查更新'
}
'models' { Build-Models }
'stamp' { Stamp-Versions }
'bundle' { Write-Host '已弃用:发布包不再内置模型。请改用 .\build.ps1 stamp 与 gitcode 自动更新。' }
'pack-models' {
Build-Models
Pack-Models
}
'pack-launcher' { Pack-Launcher }
'update-test' { dotnet run --project $TestProj -c Debug -- '--update-test' $Root }
'clean' {
Remove-Item -Recurse -Force "$Root/build", "$Root/dist" -ErrorAction SilentlyContinue
Get-ChildItem "$Root/src" -Recurse -Directory -Include bin, obj |
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
}
'doctor' { dotnet --info }
}
Executable
+329
View File
@@ -0,0 +1,329 @@
#!/bin/sh
# ---------------------------------------------------------------------------
# Earth Model Studio 构建脚本(macOS / Linux)
#
# ./build.sh build 编译(Debug)
# ./build.sh run 本机运行
# ./build.sh test 离屏渲染校验,截图输出到 build/screenshots
# ./build.sh models 编译模型 dll + 生成封面 + 自动打版本
# ./build.sh stamp 只重新生成 version.json 与模型版本
# ./build.sh publish 编译三个平台启动器(不内置模型)+ 建立 .GC 运行目录
# ./build.sh pack-models 单独打包模型数据(含 version.json)
# ./build.sh pack-launcher 生成三个平台的启动器更新包 zip
# ./build.sh update-test 离线验证自动更新链路
# ./build.sh clean 清理
#
# 分层:src/ 只是启动器;模型全部在 model/;**发布包不内置模型**。
#
# 运行目录(发布包里就长这样):
# <安装目录>/
# EarthModelStudio(.exe | .app/...)
# .GC/
# settings.json 设置与已安装版本
# model/ 启动时从 gitcode 下载的模型
# cache/ 下载暂存
# update/ 待下次启动应用的启动器更新
# ---------------------------------------------------------------------------
set -eu
# Avalonia 遥测任务在只读用户目录/CI/沙箱会因写日志失败而中断编译(MSB4018)。
# 官方 opt-out;Directory.Build.targets 里还有一层项目内的兜底。
export AVALONIA_TELEMETRY_OPTOUT=1
ROOT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
cd "$ROOT_DIR"
APP_PROJ="src/main/dotnet/EarthModelStudio/EarthModelStudio.csproj"
PREVIEW_PROJ="model/_engine/PreviewGen/PreviewGen.csproj"
STAMP_PROJ="model/_engine/VersionStamp/VersionStamp.csproj"
TEST_PROJ="src/test/dotnet/EarthModelStudio.Tests/EarthModelStudio.Tests.csproj"
SLN="EarthModelStudio.sln"
VERSION="1.0.3"
TASK="${1:-build}"
# 按模型包内容指纹自动写回 <id>.json 的 version,并生成 version.json
stamp_versions() {
echo "==> 自动计算模型版本并生成 version.json"
dotnet run --project "$STAMP_PROJ" -c Release -- "$ROOT_DIR" "$VERSION"
}
# 编译模型自己的功能程序集,并把 dll / 封面直接写进模型包
build_models() {
echo "==> 编译模型功能程序集(源码就在各模型目录的 src/ 里)"
for DIR in "$ROOT_DIR"/model/*/; do
ID=$(basename "$DIR")
[ -d "$DIR/src" ] || continue
PROJ=$(ls "$DIR"src/*.csproj 2>/dev/null | head -1)
[ -n "$PROJ" ] || continue
dotnet build "$PROJ" -c Release
if [ -d "$DIR$ID.model" ]; then
for DLL in "$DIR"src/bin/Release/net8.0/*.dll; do
[ -f "$DLL" ] || continue
NAME=$(basename "$DLL")
[ "$NAME" = "EarthModelStudio.ModelSdk.dll" ] && continue
cp "$DLL" "$DIR$ID.model/"
echo " -> model/$ID/$ID.model/$NAME"
done
fi
done
echo "==> 用模型自己的渲染器生成封面"
dotnet run --project "$PREVIEW_PROJ" -c Release -- "$ROOT_DIR"
stamp_versions
}
# 发布目录只放启动器 + 空的 .GC 运行骨架,绝不放模型
prepare_runtime_layout() {
REL="$1"
DEST="$ROOT_DIR/$REL"
[ -d "$DEST" ] || return 0
rm -rf "$DEST/model" "$DEST/examples"
mkdir -p "$DEST/.GC/model" "$DEST/.GC/cache" "$DEST/.GC/update"
cat > "$DEST/.GC/model/README.txt" <<'TXT'
模型库目录(.GC/model/)
启动时程序会读取 gitcode 仓库的 version.json,把最新版模型下载到这里。
离线使用也可以手动放入 <模型id>/<模型id>.json + <模型id>/<模型id>.model/。
运行目录:
<可执行文件>
.GC/settings.json
.GC/model/ 本目录(下载的模型)
.GC/cache/ 下载暂存
.GC/update/ 待下次启动应用的启动器更新
TXT
if [ ! -f "$DEST/.GC/settings.json" ]; then
cat > "$DEST/.GC/settings.json" <<'JSON'
{
"language": "auto",
"theme": "light",
"renderFps": 30,
"memoryMb": 2048,
"autoUpdateOnStartup": true,
"updateRepository": "https://gitcode.com/2509_92447106/GC",
"updateManifestUrl": "",
"updateLocalRoot": "",
"installedModelVersions": {},
"launcherVersion": "",
"pendingLauncherVersion": "",
"lastUpdateCheck": "",
"sources": [],
"recentModels": []
}
JSON
fi
echo " 运行目录 -> $REL/.GC (settings.json + model/ + cache/ + update/)"
}
# $1=RID $2=输出目录 $3=singlefile(true/false)
publish_rid() {
RID="$1"; OUT="$2"; SINGLE="${3:-true}"
echo ""
echo "==> 编译 ${RID} (single-file=${SINGLE}) -> ${OUT}"
# 先删旧产物,避免上次 publish 的残留文件混进新包
rm -rf "$ROOT_DIR/$OUT"
dotnet publish "$APP_PROJ" \
-c Release \
-r "$RID" \
--self-contained true \
-p:Version="$VERSION" \
-p:DebugType=none \
-p:PublishSingleFile="$SINGLE" \
-p:IncludeNativeLibrariesForSelfExtract="$SINGLE" \
-p:PublishTrimmed=false \
-o "$ROOT_DIR/$OUT"
rm -rf "$ROOT_DIR/$OUT/model" "$ROOT_DIR/$OUT/examples"
}
# 把 model/ 里的模型数据单独打包(与启动器分开分发)
pack_models() {
mkdir -p "$ROOT_DIR/dist"
ZIP="$ROOT_DIR/dist/models-$VERSION.zip"
rm -f "$ZIP"
echo "==> 打包模型数据 -> dist/models-$VERSION.zip"
( cd "$ROOT_DIR" && zip -qr "$ZIP" model \
-x "*.DS_Store" "*/bin/*" "*/obj/*" "*.user" )
du -sh "$ZIP"
}
# 启动器更新包:只包含程序文件,排除 .GC(否则会覆盖用户已下载的模型与设置)
# 产物命名:GC-<版本>-<系统>-<架构>.exe / GC-<版本>-<系统>-<架构>.app.zip
# Windows: 单文件 exe 直接改名(本身就是可执行产物)
# macOS: .app 必须打成 zip 才能作为单文件分发;文件名用 .app.zip,
# 这样 macOS 双击会用归档工具解压出可运行的 .app。
# 若直接命名 .app,系统会把 zip 当成应用包解析 => 报「已损坏/打不开」。
pack_launcher() {
echo "==> 生成启动器产物(GC-<版本>-<系统>-<架构>)"
# --- Windows:exe 单文件 ---
for pair in "win-x64:win-amd64" "win-arm64:win-arm64"; do
RID="${pair%%:*}"; LABEL="${pair##*:}"
SRC="$ROOT_DIR/dist/$RID"
[ -d "$SRC" ] || continue
EXE=$(ls "$SRC"/*.exe 2>/dev/null | head -1)
[ -n "$EXE" ] || continue
DEST="$ROOT_DIR/dist/GC-${VERSION}-${LABEL}.exe"
cp "$EXE" "$DEST"
chmod +x "$DEST"
echo " -> $(basename "$DEST")"
done
# --- macOS:先得到真实 .app 目录(改名 + 同步 Info.plist)---
MACAPP="$ROOT_DIR/dist/mac-arm64/EarthModelStudio.app"
if [ -d "$MACAPP" ]; then
FINAL="$ROOT_DIR/dist/GC-${VERSION}-mac-arm64.app"
rm -rf "$FINAL"
mv "$MACAPP" "$FINAL"
chmod +x "$FINAL/Contents/MacOS/EarthModelStudio" 2>/dev/null || true
PLIST="$FINAL/Contents/Info.plist"
if [ -f "$PLIST" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleName Morris GC" "$PLIST" 2>/dev/null || true
/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName Morris GC" "$PLIST" 2>/dev/null || true
fi
xattr -cr "$FINAL" 2>/dev/null || true
echo " -> $(basename "$FINAL")/"
fi
# --- 统一压缩:每个产物都打成同名 .zip ---
# GC-1.0.3-win-amd64.exe -> GC-1.0.3-win-amd64.zip
# GC-1.0.3-win-arm64.exe -> GC-1.0.3-win-arm64.zip
# GC-1.0.3-mac-arm64.app -> GC-1.0.3-mac-arm64.zip
# 客户端下载时按「原名去掉扩展名 + .zip」取包,再解压回原名。
echo "==> 压缩为 zip"
for art in "$ROOT_DIR"/dist/GC-"$VERSION"-*.exe "$ROOT_DIR"/dist/GC-"$VERSION"-*.app; do
[ -e "$art" ] || continue
base=$(basename "$art")
name="${base%.*}" # 去掉 .exe / .app
ZIP="$ROOT_DIR/dist/${name}.zip"
rm -f "$ZIP"
if [ -d "$art" ]; then
# 目录(.app):保留权限与符号链接
if command -v ditto >/dev/null 2>&1; then
ditto -c -k --sequesterRsrc --keepParent "$art" "$ZIP"
else
( cd "$(dirname "$art")" && zip -qry "$ZIP" "$base" -x "*.DS_Store" )
fi
else
( cd "$(dirname "$art")" && zip -q "$ZIP" "$base" )
fi
echo " -> ${name}.zip"
done
# 原始产物(.exe / .app 目录)不再保留:只发布 zip
rm -f "$ROOT_DIR"/dist/GC-"$VERSION"-*.exe
rm -rf "$ROOT_DIR"/dist/GC-"$VERSION"-*.app
strip_intermediate_dirs
stamp_versions
echo ""
echo "==> dist 只保留可发布的 zip:"
ls -lh "$ROOT_DIR"/dist/GC-"$VERSION"-*.zip 2>/dev/null || true
}
# 删除 publish 过程中的中间目录,dist 里只留最终附件
strip_intermediate_dirs() {
for d in win-x64 win-arm64 mac-arm64; do
[ -d "$ROOT_DIR/dist/$d" ] && rm -rf "$ROOT_DIR/dist/$d"
done
find "$ROOT_DIR/dist" -name ".DS_Store" -delete 2>/dev/null || true
}
package_mac_app() {
DIST="$ROOT_DIR/dist/mac-arm64"
APP="$DIST/EarthModelStudio.app"
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cat > "$APP/Contents/Info.plist" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key><string>Earth Model Studio</string>
<key>CFBundleDisplayName</key><string>Earth Model Studio</string>
<key>CFBundleIdentifier</key><string>cn.neorf.earthmodelstudio</string>
<key>CFBundleVersion</key><string>${VERSION}</string>
<key>CFBundleShortVersionString</key><string>${VERSION}</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleExecutable</key><string>EarthModelStudio</string>
<key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
<key>LSMinimumSystemVersion</key><string>11.0</string>
<key>NSHighResolutionCapable</key><true/>
</dict>
</plist>
PLIST
for f in "$DIST"/*; do
base=$(basename "$f")
[ "$base" = "EarthModelStudio.app" ] && continue
[ "$base" = ".DS_Store" ] && continue
mv "$f" "$APP/Contents/MacOS/"
done
# 发布包不带 .GC 运行骨架(用户首次启动自行创建),避免覆盖用户数据
rm -rf "$APP/Contents/MacOS/.GC"
chmod +x "$APP/Contents/MacOS/EarthModelStudio"
echo "==> 已打包 $APP"
}
case "$TASK" in
build)
# 清理上次遗留的发布包 zip,避免误用旧产物
rm -f "$ROOT_DIR"/dist/GC-*.zip "$ROOT_DIR"/dist/models-*.zip 2>/dev/null || true
dotnet build "$SLN" -c Debug
;;
run)
dotnet run --project "$APP_PROJ" -c Debug
;;
test)
dotnet run --project "$TEST_PROJ" -c Debug -- "$ROOT_DIR/build/screenshots"
;;
publish)
# 先清掉 dist 旧产物(含历史 zip / 目录),再重新生成
echo "==> 清理 dist 旧产物"
rm -rf "$ROOT_DIR/dist"
mkdir -p "$ROOT_DIR/dist"
stamp_versions
# macOS 用目录形式(非单文件):单文件包启动时需要解压缓存目录,
# 在受限/沙箱环境下创建失败会直接报「打不开」。目录形式无此依赖。
publish_rid "osx-arm64" "dist/mac-arm64" false
publish_rid "win-x64" "dist/win-x64" true
publish_rid "win-arm64" "dist/win-arm64" true
package_mac_app
prepare_runtime_layout "dist/win-x64"
prepare_runtime_layout "dist/win-arm64"
prepare_runtime_layout "dist/mac-arm64/EarthModelStudio.app/Contents/MacOS"
pack_launcher
echo ""
echo "==> 三个平台编译完成(发布包不含模型,首次启动自动下载):"
du -sh "$ROOT_DIR/dist"/* 2>/dev/null || true
echo " 把 version.json / model/ 推送到 gitcode,启动器就会自动检查更新"
;;
models)
build_models
;;
stamp)
stamp_versions
;;
bundle)
echo "已弃用:发布包不再内置模型。请改用 ./build.sh stamp 与 gitcode 自动更新。"
;;
pack-models)
build_models
pack_models
;;
pack-launcher)
pack_launcher
;;
update-test)
dotnet run --project "$TEST_PROJ" -c Debug -- --update-test "$ROOT_DIR"
;;
clean)
rm -rf "$ROOT_DIR/build" "$ROOT_DIR/dist"
find "$ROOT_DIR/src" -type d \( -name bin -o -name obj \) -prune -exec rm -rf {} + 2>/dev/null || true
echo "==> 已清理"
;;
doctor)
dotnet --info | head -20
;;
*)
echo "未知任务: $TASK"
echo "可用: build | run | test | publish | models | stamp | pack-models | pack-launcher | update-test | clean | doctor"
exit 1
;;
esac
+57
View File
@@ -0,0 +1,57 @@
#!/bin/sh
# buildsh/build.sh —— 完整发布(原 publish)
# 步骤及权重按实测耗时设定,供进度条估算总进度与剩余时间:
# 清理(2) 版本(3) Mac(35) WinX64(25) WinArm(25) 骨架(3) 打包(5) 收尾(2) = 100
bs_build() {
ROOT_DIR="$1"
: "${APP_PROJ:?}" "${SLN:?}" "${VERSION:?}"
progress_init 100 2 3 35 25 25 3 5 2
progress_step "清理旧产物"; progress_tick 100
rm -rf "$ROOT_DIR/dist"; mkdir -p "$ROOT_DIR/dist"
progress_step "版本戳"; progress_tick 100
stamp_versions
# 每个 publish 用后台任务包裹,边跑边按「已用时/预估用时」推进当前步骤进度
_run_publish() {
_label="$1"; _est="$2"; shift 2
( "$@" >"$ROOT_DIR/build/logs/publish-$_label.log" 2>&1 ) &
_pid=$!
_t0=$(date +%s)
while kill -0 "$_pid" 2>/dev/null; do
_elapsed=$(( $(date +%s) - _t0 ))
_p=$(( _elapsed * 100 / _est ))
[ "$_p" -gt 96 ] && _p=96
progress_tick "$_p"
sleep 1
done
wait "$_pid" || { echo; echo "!! $_label 编译失败,见 build/logs/publish-$_label.log"; return 1; }
progress_tick 100
}
progress_step "编译 Mac"
_run_publish mac 90 publish_rid "osx-arm64" "dist/mac-arm64" false || return 1
progress_step "编译 Win-x64"
_run_publish winx64 70 publish_rid "win-x64" "dist/win-x64" true || return 1
progress_step "编译 Win-arm64"
_run_publish winarm 70 publish_rid "win-arm64" "dist/win-arm64" true || return 1
progress_step "运行骨架"; progress_tick 100
package_mac_app
prepare_runtime_layout "dist/win-x64"
prepare_runtime_layout "dist/win-arm64"
prepare_runtime_layout "dist/mac-arm64/EarthModelStudio.app/Contents/MacOS"
progress_step "打包 zip"; progress_tick 100
pack_launcher
progress_step "收尾"; progress_tick 100
progress_done
echo "==> 完成,产物:"
ls -lh "$ROOT_DIR"/dist/GC-"$VERSION"-*.zip 2>/dev/null || true
}
+227
View File
@@ -0,0 +1,227 @@
#!/bin/sh
# buildsh/lib/build_funcs.sh —— 构建函数库(由入口脚本 source)
# 依赖调用方提供:ROOT_DIR, APP_PROJ, PREVIEW_PROJ, STAMP_PROJ, TEST_PROJ, SLN, VERSION
# 以及任务进度上报函数 step / progress(由进度条引擎提供,未定义时降级为 echo)
if ! type step >/dev/null 2>&1; then step() { echo "==> $1"; }; fi
if ! type progress >/dev/null 2>&1; then progress() { :; }; fi
stamp_versions() {
echo "==> 自动计算模型版本并生成 version.json"
dotnet run --project "$STAMP_PROJ" -c Release -- "$ROOT_DIR" "$VERSION"
}
# 编译模型自己的功能程序集,并把 dll / 封面直接写进模型包
build_models() {
echo "==> 编译模型功能程序集(源码就在各模型目录的 src/ 里)"
for DIR in "$ROOT_DIR"/model/*/; do
ID=$(basename "$DIR")
[ -d "$DIR/src" ] || continue
PROJ=$(ls "$DIR"src/*.csproj 2>/dev/null | head -1)
[ -n "$PROJ" ] || continue
dotnet build "$PROJ" -c Release
if [ -d "$DIR$ID.model" ]; then
for DLL in "$DIR"src/bin/Release/net8.0/*.dll; do
[ -f "$DLL" ] || continue
NAME=$(basename "$DLL")
[ "$NAME" = "EarthModelStudio.ModelSdk.dll" ] && continue
cp "$DLL" "$DIR$ID.model/"
echo " -> model/$ID/$ID.model/$NAME"
done
fi
done
echo "==> 用模型自己的渲染器生成封面"
dotnet run --project "$PREVIEW_PROJ" -c Release -- "$ROOT_DIR"
stamp_versions
}
# 发布目录只放启动器 + 空的 .GC 运行骨架,绝不放模型
prepare_runtime_layout() {
REL="$1"
DEST="$ROOT_DIR/$REL"
[ -d "$DEST" ] || return 0
rm -rf "$DEST/model" "$DEST/examples"
mkdir -p "$DEST/.GC/model" "$DEST/.GC/cache" "$DEST/.GC/update"
cat > "$DEST/.GC/model/README.txt" <<'TXT'
模型库目录(.GC/model/)
启动时程序会读取 gitcode 仓库的 version.json,把最新版模型下载到这里。
离线使用也可以手动放入 <模型id>/<模型id>.json + <模型id>/<模型id>.model/。
运行目录:
<可执行文件>
.GC/settings.json
.GC/model/ 本目录(下载的模型)
.GC/cache/ 下载暂存
.GC/update/ 待下次启动应用的启动器更新
TXT
if [ ! -f "$DEST/.GC/settings.json" ]; then
cat > "$DEST/.GC/settings.json" <<'JSON'
{
"language": "auto",
"theme": "light",
"renderFps": 30,
"memoryMb": 2048,
"autoUpdateOnStartup": true,
"updateRepository": "https://gitcode.com/2509_92447106/GC",
"updateManifestUrl": "",
"updateLocalRoot": "",
"installedModelVersions": {},
"launcherVersion": "",
"pendingLauncherVersion": "",
"lastUpdateCheck": "",
"sources": [],
"recentModels": []
}
JSON
fi
echo " 运行目录 -> $REL/.GC (settings.json + model/ + cache/ + update/)"
}
# $1=RID $2=输出目录 $3=singlefile(true/false)
publish_rid() {
RID="$1"; OUT="$2"; SINGLE="${3:-true}"
echo ""
echo "==> 编译 ${RID} (single-file=${SINGLE}) -> ${OUT}"
# 先删旧产物,避免上次 publish 的残留文件混进新包
rm -rf "$ROOT_DIR/$OUT"
dotnet publish "$APP_PROJ" \
-c Release \
-r "$RID" \
--self-contained true \
-p:Version="$VERSION" \
-p:DebugType=none \
-p:PublishSingleFile="$SINGLE" \
-p:IncludeNativeLibrariesForSelfExtract="$SINGLE" \
-p:PublishTrimmed=false \
-o "$ROOT_DIR/$OUT"
rm -rf "$ROOT_DIR/$OUT/model" "$ROOT_DIR/$OUT/examples"
}
# 把 model/ 里的模型数据单独打包(与启动器分开分发)
pack_models() {
mkdir -p "$ROOT_DIR/dist"
ZIP="$ROOT_DIR/dist/models-$VERSION.zip"
rm -f "$ZIP"
echo "==> 打包模型数据 -> dist/models-$VERSION.zip"
( cd "$ROOT_DIR" && zip -qr "$ZIP" model \
-x "*.DS_Store" "*/bin/*" "*/obj/*" "*.user" )
du -sh "$ZIP"
}
# 启动器更新包:只包含程序文件,排除 .GC(否则会覆盖用户已下载的模型与设置)
# 产物命名:GC-<版本>-<系统>-<架构>.exe / GC-<版本>-<系统>-<架构>.app.zip
# Windows: 单文件 exe 直接改名(本身就是可执行产物)
# macOS: .app 必须打成 zip 才能作为单文件分发;文件名用 .app.zip,
# 这样 macOS 双击会用归档工具解压出可运行的 .app。
# 若直接命名 .app,系统会把 zip 当成应用包解析 => 报「已损坏/打不开」。
pack_launcher() {
echo "==> 生成启动器产物(GC-<版本>-<系统>-<架构>)"
# --- Windows:exe 单文件 ---
for pair in "win-x64:win-amd64" "win-arm64:win-arm64"; do
RID="${pair%%:*}"; LABEL="${pair##*:}"
SRC="$ROOT_DIR/dist/$RID"
[ -d "$SRC" ] || continue
EXE=$(ls "$SRC"/*.exe 2>/dev/null | head -1)
[ -n "$EXE" ] || continue
DEST="$ROOT_DIR/dist/GC-${VERSION}-${LABEL}.exe"
cp "$EXE" "$DEST"
chmod +x "$DEST"
echo " -> $(basename "$DEST")"
done
# --- macOS:先得到真实 .app 目录(改名 + 同步 Info.plist)---
MACAPP="$ROOT_DIR/dist/mac-arm64/EarthModelStudio.app"
if [ -d "$MACAPP" ]; then
FINAL="$ROOT_DIR/dist/GC-${VERSION}-mac-arm64.app"
rm -rf "$FINAL"
mv "$MACAPP" "$FINAL"
chmod +x "$FINAL/Contents/MacOS/EarthModelStudio" 2>/dev/null || true
PLIST="$FINAL/Contents/Info.plist"
if [ -f "$PLIST" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleName Morris GC" "$PLIST" 2>/dev/null || true
/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName Morris GC" "$PLIST" 2>/dev/null || true
fi
xattr -cr "$FINAL" 2>/dev/null || true
echo " -> $(basename "$FINAL")/"
fi
# --- 统一压缩:每个产物都打成同名 .zip ---
# GC-1.0.3-win-amd64.exe -> GC-1.0.3-win-amd64.zip
# GC-1.0.3-win-arm64.exe -> GC-1.0.3-win-arm64.zip
# GC-1.0.3-mac-arm64.app -> GC-1.0.3-mac-arm64.zip
# 客户端下载时按「原名去掉扩展名 + .zip」取包,再解压回原名。
echo "==> 压缩为 zip"
for art in "$ROOT_DIR"/dist/GC-"$VERSION"-*.exe "$ROOT_DIR"/dist/GC-"$VERSION"-*.app; do
[ -e "$art" ] || continue
base=$(basename "$art")
name="${base%.*}" # 去掉 .exe / .app
ZIP="$ROOT_DIR/dist/${name}.zip"
rm -f "$ZIP"
if [ -d "$art" ]; then
# 目录(.app):保留权限与符号链接
if command -v ditto >/dev/null 2>&1; then
ditto -c -k --sequesterRsrc --keepParent "$art" "$ZIP"
else
( cd "$(dirname "$art")" && zip -qry "$ZIP" "$base" -x "*.DS_Store" )
fi
else
( cd "$(dirname "$art")" && zip -q "$ZIP" "$base" )
fi
echo " -> ${name}.zip"
done
# 原始产物(.exe / .app 目录)不再保留:只发布 zip
rm -f "$ROOT_DIR"/dist/GC-"$VERSION"-*.exe
rm -rf "$ROOT_DIR"/dist/GC-"$VERSION"-*.app
strip_intermediate_dirs
stamp_versions
echo ""
echo "==> dist 只保留可发布的 zip:"
ls -lh "$ROOT_DIR"/dist/GC-"$VERSION"-*.zip 2>/dev/null || true
}
# 删除 publish 过程中的中间目录,dist 里只留最终附件
strip_intermediate_dirs() {
for d in win-x64 win-arm64 mac-arm64; do
[ -d "$ROOT_DIR/dist/$d" ] && rm -rf "$ROOT_DIR/dist/$d"
done
find "$ROOT_DIR/dist" -name ".DS_Store" -delete 2>/dev/null || true
}
package_mac_app() {
DIST="$ROOT_DIR/dist/mac-arm64"
APP="$DIST/EarthModelStudio.app"
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cat > "$APP/Contents/Info.plist" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key><string>Earth Model Studio</string>
<key>CFBundleDisplayName</key><string>Earth Model Studio</string>
<key>CFBundleIdentifier</key><string>cn.neorf.earthmodelstudio</string>
<key>CFBundleVersion</key><string>${VERSION}</string>
<key>CFBundleShortVersionString</key><string>${VERSION}</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleExecutable</key><string>EarthModelStudio</string>
<key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
<key>LSMinimumSystemVersion</key><string>11.0</string>
<key>NSHighResolutionCapable</key><true/>
</dict>
</plist>
PLIST
for f in "$DIST"/*; do
base=$(basename "$f")
[ "$base" = "EarthModelStudio.app" ] && continue
[ "$base" = ".DS_Store" ] && continue
mv "$f" "$APP/Contents/MacOS/"
done
# 发布包不带 .GC 运行骨架(用户首次启动自行创建),避免覆盖用户数据
rm -rf "$APP/Contents/MacOS/.GC"
chmod +x "$APP/Contents/MacOS/EarthModelStudio"
echo "==> 已打包 $APP"
}
+93
View File
@@ -0,0 +1,93 @@
#!/bin/sh
# buildsh/lib/progress.sh —— apt 风格底部实时进度条
#
# 底部一行:任务 当前任务进度 总进度 剩余时间
# 编译MacOS 95% 30% 10s
#
# 用法:
# progress_init <总步骤数> <每步权重...>
# progress_step <步骤名> # 开始某步骤
# progress_tick <0-100> # 更新当前步骤完成度
# progress_done # 结束
PROGRESS_TOTAL=1
PROGRESS_WEIGHTS=""
PROGRESS_IDX=0
PROGRESS_CUR=0
PROGRESS_STARTED=0
PROGRESS_LAST=0
PROGRESS_HISTORY=""
_now() { date +%s; }
# 加权总进度:前序步骤权重之和 + 当前步骤权重*完成度
_progress_overall() {
_sum=0; _i=0
for _w in $PROGRESS_WEIGHTS; do
if [ "$_i" -lt "$PROGRESS_IDX" ]; then _sum=$((_sum + _w)); fi
_i=$((_i + 1))
done
_cw=$(echo "$PROGRESS_WEIGHTS" | awk -v i="$((PROGRESS_IDX+1))" '{print $i}')
[ -z "$_cw" ] && _cw=1
_sum=$((_sum + _cw * PROGRESS_CUR / 100))
echo $((_sum * 100 / PROGRESS_TOTAL))
}
# 剩余时间:基于「已完成总进度 / 已用时间」线性外推
_progress_eta() {
_p=$(_progress_overall)
[ "$_p" -le 0 ] && { echo "--"; return; }
_t=$(( $(_now) - PROGRESS_STARTED ))
[ "$_t" -le 0 ] && { echo "--"; return; }
_eta=$(( _t * (100 - _p) / _p ))
if [ "$_eta" -ge 60 ]; then echo "$(( _eta / 60 ))m$((_eta % 60))s"; else echo "${_eta}s"; fi
}
progress_draw() {
_task="$PROGRESS_TASK"
_cur=$PROGRESS_CUR
_overall=$(_progress_overall)
_eta=$(_progress_eta)
# 进度条(20 格)
_filled=$((_overall * 20 / 100))
_bar=""
_i=0
while [ "$_i" -lt 20 ]; do
if [ "$_i" -lt "$_filled" ]; then _bar="${_bar}#"; else _bar="${_bar}."; fi
_i=$((_i + 1))
done
# \r 回到行首,用 \033[K 清到行尾;底部固定一行
printf '\r\033[K[%s] %-16s %3d%% 总 %3d%% %s' \
"$_bar" "$_task" "$_cur" "$_overall" "$_eta"
}
progress_init() {
PROGRESS_TOTAL=$1
shift
PROGRESS_WEIGHTS="$*"
PROGRESS_IDX=0
PROGRESS_CUR=0
PROGRESS_STARTED=$(_now)
PROGRESS_TASK="准备"
progress_draw
}
progress_step() {
PROGRESS_TASK="$1"
PROGRESS_CUR=0
PROGRESS_IDX=$((PROGRESS_IDX + 1))
progress_draw
}
progress_tick() {
PROGRESS_CUR=$1
progress_draw
}
progress_done() {
PROGRESS_CUR=100
progress_tick 100
printf '\n'
}
+156
View File
@@ -0,0 +1,156 @@
# 模型库(model/)
这个目录是**模型**,包含模型自己的**源码 + 数据 + 功能程序集 + 封面 + 语言包**。
`src/`(启动器)只做四件事:扫描模型、下载模型、开窗口加载模型、检查更新。**启动器没有任何渲染逻辑,发布包也不内置模型**。
> 模型相关的一切都在 `model/` 里:共享引擎源码 `model/_engine/`、契约源码 `model/_sdk/`、
> 每个模型自己的源码 `model/<id>/src/`,编译产物与数据 `model/<id>/<id>.model/`。
> 仓库根目录只有 `src/`(启动器)和 `model/`,没有任何旁路目录。
- 发布态模型库在 **`<可执行文件>/.GC/model/`**;开发态直接用仓库根 `model/`
- 优先级:`EMS_MODELS` 环境变量 → 开发态仓库根 `model/` → 发布态 `.GC/model/`
- 一个模型 = 一个文件夹,文件夹名即模型 id;`_sdk/`、`_engine/` 是下划线开头的共享目录,不会被当成模型
- 模型可以单独打包、单独分发,也可以放进 git 仓库当模型源
## 目录结构
```
model/
version.json # 版本清单(与仓库根 version.json 相同,自动生成)
_sdk/EarthModelStudio.ModelSdk/ # 模型契约(启动器与模型唯一的共享代码)
_engine/ # 共享引擎源码
src/ # CelestialView / PlanetTexture / EarthModelView / SphereRaster…
PreviewGen/ # 用模型渲染器生成封面的小工具
VersionStamp/ # 按内容指纹自动打版本、生成 version.json
<模型 id>/
<模型 id>.json # 清单:名称、i18n、版本、程序集入口、封面
src/ # 模型自己的源码(csproj + IModelFactory 实现)
<模型 id>.model/ # 模型包(可分发的部分)
EarthRotationModel.dll # 功能程序集(实现 IModelFactory)
scene.json # 场景数据(内容由模型定义)
land.json # 贴图/轮廓数据(可选)
preview.png # 封面图(启动器只显示,不渲染)
i18n/zh-CN.json # 界面文案(模型自己读)
i18n/en.json
```
## 版本是自动改的
`./build.sh models`(或 `./build.sh stamp`)会调用 `model/_engine/VersionStamp`:
1. 对每个模型,把 `<id>.json`(去掉 `version` / `updatedAt`)与 `<id>.model/` 下所有文件
按路径排序做 SHA-256 指纹,得到版本号 `1.0-<10位指纹>`;
2. 把这个版本写回 `<id>.json` 的 `version` 与 `updatedAt`;
3. 生成仓库根 `version.json` 和 `model/version.json`(内容相同),里面记录
启动器版本、各平台更新包地址、每个模型的 id / 版本 / 仓库目录。
**所以只要改了模型文件,版本号就自动变**,不需要手工维护;内容没变时重复构建版本号保持不变。
客户端启动时读 `version.json`,和 `.GC/settings.json` 里记录的版本一比对就知道要不要下载。
> 改了 `scene.json` 或引擎源码后,跑 `./build.sh models`,再把 `version.json` 和 `model/`
> 推送到 gitcode;客户端下次启动会下载新模型并**本次启动立即生效**。
> 启动器自身更新包由 `./build.sh publish` 生成(`dist/GC-<rid>.zip`),下载后**下次启动才应用**。
## `<id>.json`(模型清单,启动器只读它)
```json
{
"id": "earth-rotation",
"name": "Earth Rotation",
"nameI18n": { "zh-CN": "地球自转", "en": "Earth Rotation" },
"description": "……",
"descriptionI18n": { "zh-CN": "……", "en": "……" },
"version": "1.0-3f9a2c1b7d",
"updatedAt": "2026-11-07T08:00:00Z",
"author": "NeoRF",
"tags": ["astronomy", "geography"],
"assembly": "EarthRotationModel.dll",
"type": "NeoRF.EarthModels.RotationModelFactory",
"preview": "preview.png",
"apiVersion": 1
}
```
| 字段 | 作用 |
| --- | --- |
| `version` | **自动生成**,模型包内容指纹;客户端靠它判断是否需要更新 |
| `assembly` | 功能程序集文件名,相对 `<id>.model`;留空按 `<id>.dll` 找 |
| `type` | 实现 `IModelFactory` 的完整类型名;留空则自动找第一个实现 |
| `preview` | 封面图,默认 `preview.png` |
| `apiVersion` | 模型契约版本,目前为 1 |
## 模型契约(model/_sdk)
模型只依赖一个极小的契约程序集 `EarthModelStudio.ModelSdk`(源码在 `model/_sdk/`):
```csharp
public interface IModelFactory
{
int ApiVersion { get; }
IModelRuntime Create();
}
public interface IModelRuntime : IDisposable
{
void Prepare(IModelContext context); // 后台线程:读数据、算纹理,可汇报进度
Control CreateView(IModelContext context); // UI 线程:构建界面
}
public interface IModelContext
{
string ModelId { get; }
string ModelDirectory { get; }
string DataDirectory { get; }
string Language { get; }
int MemoryBudgetMb { get; }
void RequestClose();
void ReportProgress(double value, string? message = null);
void Log(string message);
}
```
模型 `CreateView` 返回的控件会铺满窗口客户区 —— **工具栏、动画、文字、交互全由模型自己实现**。
启动器只提供窗口、语言、内存预算和关闭能力。
## `scene.json` / `land.json`
这两个文件的内容完全由模型自己定义(启动器不解析)。地球模型用的是:
- `scene.json`:`defaultView`、`views`、行星参数、颜色、轨道、`lessons` 教学要点
- `orbit.seasonLayout`:`springTopSummerLeft` = **上春分、左夏至**(下秋分、右冬至),季节角度与直射纬度读数不变
- `planet.axialTiltDeg` / `planet.tropicDeg`:教材值 **23.5°**(极圈自动算 90 − 23.5 = 66.5°)
- `orbit.seasons[].declinationDeg`:二分二至的太阳直射纬度(0 / +23.5 / 0 / −23.5),
定格时读数直接取这个值,不用近似公式
- `orbit.seasons[].teachingI18n`:该节气的课堂现象说明(中英双语,写在模型数据里)
- `orbit.seasons[].date`:教材日期(3/21、6/22、9/23、12/22),定格时 HUD 与课堂卡都用它
- `land.json`:大陆轮廓,`{ "polygons": [ { "name": "...", "points": [[lon,lat], ...] } ] }`
## 语言包
`<id>.model/i18n/<language>.json` 是扁平的 `键: 文案` 映射,模型自己读取。
地球模型用到的键:`title`、`view.rotation`、`play`、`pause`、`speed`、`reset`、`labels`、`orbit`、`grid`、`tilt`、
`lessons`、`seasons`、`close`、`sun`、`earth`、`north`、`south`、`subsolar`、`spinInfo`、`orbitInfo`、
`declinationInfo`、`dateInfo`、`season.*`。
## 封面
封面是 `preview.png`,由 `model/_engine/PreviewGen` 用**模型自己的渲染器**生成:
```bash
./build.sh models # 编译模型 dll + 生成所有模型封面 + 自动打版本
```
## 做一个新模型
1. 在 `model/<id>/src/` 里新建类库项目(可引用 `model/_engine/src` 的共享代码,也可完全自己写)
2. 写一个 `IModelFactory` 实现:`Prepare` 里读数据算纹理并 `ReportProgress`,`CreateView` 里返回控件
3. 在 `model/<id>/` 放清单和 `<id>.model/` 数据目录,用 `assembly` / `type` 指向你的 dll
4. `./build.sh models` 会自动编译每个模型、把 dll 复制进对应 `<id>.model/`、生成封面、打版本并写进 `version.json`
5. 推送仓库,客户端下次启动自动下载 —— 不用改启动器、不用重新发布程序
## 作为模型源分发
- **自动更新(推荐)**:把 `version.json` 和 `model/` 推到 gitcode 仓库,启动器开机自检并下载到 `.GC/model/`
- **离线源**:把整个仓库目录(含 `version.json` + `model/`)拷到 U 盘 / 共享盘,
在 `.GC/settings.json` 填 `updateLocalRoot` 指向它
- **手动导入**:在「下载」页粘贴任意 git 仓库 / zip / 本地目录,读取其中的 `model/` 文件夹
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<RootNamespace>NeoRF.EarthModels</RootNamespace>
<AssemblyName>EarthModelPreview</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<!-- 直接编译共享引擎源码:封面必须由模型自己的渲染器画 -->
<Compile Include="../src/**/*.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Headless" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Skia" Version="$(AvaloniaVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\_sdk\EarthModelStudio.ModelSdk\EarthModelStudio.ModelSdk.csproj" />
</ItemGroup>
</Project>
+113
View File
@@ -0,0 +1,113 @@
using System;
using System.IO;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Headless;
using Avalonia.Media.Imaging;
using NeoRF.EarthModels;
namespace NeoRF.EarthModels.Preview;
/// <summary>
/// 封面生成工具:用模型自己的渲染器给每个模型画一张封面 preview.png。
/// 封面在模型包里,启动器只负责显示 —— 所以公转模型的封面一定就是公转场景。
/// 用法:dotnet run --project model-src/tools/PreviewGen -- &lt;仓库根&gt;
/// </summary>
internal static class Program
{
private const int Width = 768;
private const int Height = 316;
[STAThread]
public static int Main(string[] args)
{
var root = args.Length > 0 ? args[0] : Directory.GetCurrentDirectory();
var modelRoot = Path.Combine(root, "model");
if (!Directory.Exists(modelRoot))
{
Console.Error.WriteLine($"找不到模型库: {modelRoot}");
return 1;
}
var bench = args.Contains("--bench");
AppBuilder.Configure<Application>()
.UseSkia()
.UseHeadless(new AvaloniaHeadlessPlatformOptions { UseHeadlessDrawing = false })
.SetupWithoutStarting();
foreach (var modelDir in Directory.GetDirectories(modelRoot))
{
var id = Path.GetFileName(modelDir);
if (id.StartsWith(".")) continue;
var dataDir = Path.Combine(modelDir, id + ".model");
var sceneFile = Path.Combine(dataDir, "scene.json");
if (!File.Exists(sceneFile)) continue;
var runtime = SceneRuntime.Load(dataDir, 2048);
var texts = ModelStrings.Load(dataDir, "zh-CN");
var revolution = string.Equals(runtime.Scene.DefaultView, "revolution", StringComparison.OrdinalIgnoreCase);
var view = new CelestialView
{
Scene = runtime,
Texts = texts,
View = revolution ? SceneView.Revolution : SceneView.Rotation,
IsPlaying = false,
ShowHud = false,
ShowLabels = false,
ShowOrbit = true,
ShowGraticule = true,
Width = Width,
Height = Height
};
view.Measure(new Size(Width, Height));
view.Arrange(new Rect(0, 0, Width, Height));
view.JumpToOrbit(revolution ? 45 : 0);
view.JumpToSpin(20);
if (bench)
{
// 真实窗口尺寸下的帧耗时
view.Width = 1240;
view.Height = 820;
view.Measure(new Size(1240, 820));
view.Arrange(new Rect(0, 0, 1240, 820));
// 模拟播放态(运动时降分辨率),分别测静止高清帧与运动帧
var animField = typeof(NeoRF.EarthModels.CelestialView)
.GetField("_animating", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var sw = System.Diagnostics.Stopwatch.StartNew();
for (var frame = 0; frame < 20; frame++)
{
view.JumpToSpin(20 + frame * 3);
using var tmp = new RenderTargetBitmap(new PixelSize(1240, 820), new Vector(96, 96));
tmp.Render(view);
}
sw.Stop();
var still = sw.Elapsed.TotalMilliseconds / 20;
animField?.SetValue(view, true);
sw.Restart();
for (var frame = 0; frame < 20; frame++)
{
view.JumpToSpin(20 + frame * 3);
using var tmp = new RenderTargetBitmap(new PixelSize(1240, 820), new Vector(96, 96));
tmp.Render(view);
}
sw.Stop();
Console.WriteLine($"{id}: 静止 {still:0.0} ms/frame · 播放 {sw.Elapsed.TotalMilliseconds / 20:0.0} ms/frame");
continue;
}
var outFile = Path.Combine(dataDir, "preview.png");
using (var bitmap = new RenderTargetBitmap(new PixelSize(Width, Height), new Vector(96, 96)))
{
bitmap.Render(view);
bitmap.Save(outFile);
}
Console.WriteLine($"preview -> {outFile}");
}
return 0;
}
}
+164
View File
@@ -0,0 +1,164 @@
using System.Security.Cryptography;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Nodes;
// VersionStamp:构建时自动给模型打版本。
// 用法:dotnet run --project model/_engine/VersionStamp -- <仓库根> <启动器版本>
// 输出:更新 model/<id>/<id>.json 的 version / updatedAt,并生成
// 仓库根 version.json 与 model/version.json(内容相同,便于两种源地址读取)。
// 仓库地址(编译产物的 Release 也发在这里):与启动器默认 updateRepository 保持一致。
const string Repository = "https://gitcode.com/2509_92447106/GC";
var root = args.Length > 0 ? Path.GetFullPath(args[0]) : Directory.GetCurrentDirectory();
var launcherVersion = args.Length > 1 && !string.IsNullOrWhiteSpace(args[1]) ? args[1] : "1.0.0";
var modelRoot = Path.Combine(root, "model");
if (!Directory.Exists(modelRoot))
{
Console.Error.WriteLine($"找不到模型库: {modelRoot}");
return 1;
}
var relaxed = new JsonSerializerOptions
{
WriteIndented = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
};
static string Rel(string baseDir, string file) =>
Path.GetRelativePath(baseDir, file).Replace('\\', '/');
static bool Distributable(string file)
{
var name = Path.GetFileName(file);
if (name.StartsWith('.')) return false;
if (name.EndsWith(".user", StringComparison.OrdinalIgnoreCase)) return false;
var rel = file.Replace('\\', '/');
return !rel.Contains("/bin/", StringComparison.OrdinalIgnoreCase) &&
!rel.Contains("/obj/", StringComparison.OrdinalIgnoreCase) &&
!rel.EndsWith(".installing", StringComparison.OrdinalIgnoreCase);
}
static string Fingerprint(IEnumerable<byte[]> chunks)
{
using var hash = IncrementalHash.CreateHash(HashAlgorithmName.SHA256);
foreach (var chunk in chunks) hash.AppendData(chunk);
return Convert.ToHexString(hash.GetHashAndReset()).ToLowerInvariant();
}
Console.WriteLine("==> 自动计算模型版本(按模型包内容指纹)");
var models = new List<Dictionary<string, string>>();
foreach (var dir in Directory.GetDirectories(modelRoot)
.OrderBy(p => Path.GetFileName(p), StringComparer.Ordinal))
{
var id = Path.GetFileName(dir);
if (id.StartsWith('_')) continue; // _sdk / _engine 是共享源码,不是模型
var manifestPath = Path.Combine(dir, id + ".json");
var dataDir = Path.Combine(dir, id + ".model");
if (!File.Exists(manifestPath) || !Directory.Exists(dataDir)) continue;
var manifest = JsonNode.Parse(File.ReadAllText(manifestPath))?.AsObject();
if (manifest == null) continue;
// 版本号由模型清单里手写的 version 决定(作者手动升到 1.0 / 1.1 …),
// 不再用内容指纹覆盖:指纹形式(1.0-393cb2b7d4)对用户不可读、也没有语义。
var declared = manifest["version"]?.GetValue<string>();
var version = string.IsNullOrWhiteSpace(declared) ? "1.0" : declared!.Trim();
// 内容指纹保留在 build 字段,仅用于构建溯源,不参与版本比较
manifest.Remove("build");
var canonical = manifest.ToJsonString(new JsonSerializerOptions { WriteIndented = false });
var chunks = new List<byte[]> { Encoding.UTF8.GetBytes(canonical) };
foreach (var file in Directory.GetFiles(dataDir, "*", SearchOption.AllDirectories)
.Where(Distributable)
.OrderBy(f => Rel(dataDir, f), StringComparer.Ordinal))
{
chunks.Add(Encoding.UTF8.GetBytes("\n" + Rel(dataDir, file) + "\n"));
chunks.Add(File.ReadAllBytes(file));
}
var fingerprint = Fingerprint(chunks)[..10];
manifest["version"] = version;
manifest["build"] = fingerprint;
manifest["updatedAt"] = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
File.WriteAllText(manifestPath, manifest.ToJsonString(relaxed) + "\n");
models.Add(new Dictionary<string, string>
{
["id"] = id,
["version"] = version,
["build"] = fingerprint,
["dir"] = "model/" + id
});
Console.WriteLine($" {id,-20} {version,-8} (build {fingerprint})");
}
// 启动器源码指纹(只展示,不触发升级;升级看 launcher.version)
var srcRoot = Path.Combine(root, "src");
var srcChunks = new List<byte[]>();
if (Directory.Exists(srcRoot))
{
foreach (var file in Directory.GetFiles(srcRoot, "*", SearchOption.AllDirectories)
.Where(Distributable)
.Where(f => f.EndsWith(".cs", StringComparison.OrdinalIgnoreCase) ||
f.EndsWith(".axaml", StringComparison.OrdinalIgnoreCase) ||
f.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase) ||
f.EndsWith(".json", StringComparison.OrdinalIgnoreCase) ||
f.EndsWith(".props", StringComparison.OrdinalIgnoreCase))
.OrderBy(f => Rel(srcRoot, f), StringComparer.Ordinal))
{
srcChunks.Add(Encoding.UTF8.GetBytes(Rel(srcRoot, file) + "\n"));
srcChunks.Add(File.ReadAllBytes(file));
}
}
var launcherRevision = srcChunks.Count > 0 ? Fingerprint(srcChunks)[..10] : "";
var packages = new Dictionary<string, Dictionary<string, object>>();
// 启动器更新只访问「编译的产物」:gitcode Release 里发布的 dist/GC-<rid>.zip 附件。
// 运行时若存在同名 Release,GitCodeReleaseRemote 会用附件真实直链覆盖下面的 url;
// 下面的地址是兜底(编译产物尚未发 Release 时也能指向正确的编译产物位置)。
var releaseBase = $"{Repository}/releases/download/v{launcherVersion}";
foreach (var rid in new[] { "win-x64", "win-arm64", "osx-arm64", "osx-x64", "linux-x64" })
{
var entry = new Dictionary<string, object>
{
["path"] = $"dist/GC-{rid}.zip",
["url"] = $"{releaseBase}/GC-{rid}.zip"
};
// 已生成的启动器更新包:把校验值和体积写进清单,供下载端校验
var zipPath = Path.Combine(root, "dist", $"GC-{rid}.zip");
if (File.Exists(zipPath))
{
var bytes = File.ReadAllBytes(zipPath);
entry["sha256"] = Convert.ToHexString(SHA256.HashData(bytes)).ToLowerInvariant();
entry["size"] = bytes.LongLength;
}
packages[rid] = entry;
}
var versionDoc = new Dictionary<string, object>
{
["schema"] = 1,
["generated"] = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"),
["repository"] = Repository,
["branch"] = "main",
["modelDir"] = "model",
["launcher"] = new Dictionary<string, object>
{
["version"] = launcherVersion,
["revision"] = launcherRevision,
["packages"] = packages
},
["models"] = models
};
var json = JsonSerializer.Serialize(versionDoc, relaxed) + "\n";
File.WriteAllText(Path.Combine(root, "version.json"), json);
File.WriteAllText(Path.Combine(modelRoot, "version.json"), json);
Console.WriteLine($"==> version.json 已生成(启动器 {launcherVersion},模型 {models.Count} 个)");
return 0;
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>VersionStamp</AssemblyName>
<RootNamespace>VersionStamp</RootNamespace>
</PropertyGroup>
</Project>
Binary file not shown.
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"VersionStamp/1.0.3": {
"runtime": {
"VersionStamp.dll": {}
}
}
}
},
"libraries": {
"VersionStamp/1.0.3": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
@@ -0,0 +1,13 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("NeoRF")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.3.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.3")]
[assembly: System.Reflection.AssemblyProductAttribute("Earth Model Studio")]
[assembly: System.Reflection.AssemblyTitleAttribute("VersionStamp")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.3.0")]
[assembly: System.Resources.NeutralResourcesLanguageAttribute("zh-Hans")]
// Generated by the MSBuild WriteCodeFragment class.
@@ -0,0 +1 @@
74f99e4d9cbf91b981ea8bb9ca826e7a8f5f09eeb43c6922e054b3d03a9b8acf
@@ -0,0 +1,18 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetFrameworkIdentifier = .NETCoreApp
build_property.TargetFrameworkVersion = v8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property.EntryPointFilePath =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = VersionStamp
build_property.ProjectDir = /Users/morris/Downloads/GC#/model/_engine/VersionStamp/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 8.0
build_property.EnableCodeStyleSeverity =
@@ -0,0 +1,8 @@
// <auto-generated/>
global using System;
global using System.Collections.Generic;
global using System.IO;
global using System.Linq;
global using System.Net.Http;
global using System.Threading;
global using System.Threading.Tasks;
@@ -0,0 +1 @@
85742ef80cf2152cf4a4430f83d458331bf993698b5083cd8b3b2fcfbf3691ce
@@ -0,0 +1,14 @@
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/bin/Release/net8.0/VersionStamp
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/bin/Release/net8.0/VersionStamp.deps.json
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/bin/Release/net8.0/VersionStamp.runtimeconfig.json
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/bin/Release/net8.0/VersionStamp.dll
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/bin/Release/net8.0/VersionStamp.pdb
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/obj/Release/net8.0/VersionStamp.GeneratedMSBuildEditorConfig.editorconfig
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/obj/Release/net8.0/VersionStamp.AssemblyInfoInputs.cache
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/obj/Release/net8.0/VersionStamp.AssemblyInfo.cs
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/obj/Release/net8.0/VersionStamp.csproj.CoreCompileInputs.cache
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/obj/Release/net8.0/VersionStamp.dll
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/obj/Release/net8.0/refint/VersionStamp.dll
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/obj/Release/net8.0/VersionStamp.pdb
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/obj/Release/net8.0/VersionStamp.genruntimeconfig.cache
/Users/morris/Downloads/GC#/model/_engine/VersionStamp/obj/Release/net8.0/ref/VersionStamp.dll
@@ -0,0 +1 @@
d0976149c15255acc8dcb9e033721a42927c784807f5fd87fba864a81ecce360
Binary file not shown.
@@ -0,0 +1,69 @@
{
"format": 1,
"restore": {
"/Users/morris/Downloads/GC#/model/_engine/VersionStamp/VersionStamp.csproj": {}
},
"projects": {
"/Users/morris/Downloads/GC#/model/_engine/VersionStamp/VersionStamp.csproj": {
"version": "1.0.3",
"restore": {
"projectUniqueName": "/Users/morris/Downloads/GC#/model/_engine/VersionStamp/VersionStamp.csproj",
"projectName": "VersionStamp",
"projectPath": "/Users/morris/Downloads/GC#/model/_engine/VersionStamp/VersionStamp.csproj",
"packagesPath": "/Users/morris/.nuget/packages/",
"outputPath": "/Users/morris/Downloads/GC#/model/_engine/VersionStamp/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/Users/morris/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"framework": "net8.0",
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "10.0.400"
},
"frameworks": {
"net8.0": {
"framework": "net8.0",
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/10.0.401/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/morris/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/morris/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">7.0.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/Users/morris/.nuget/packages/" />
</ItemGroup>
</Project>
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
@@ -0,0 +1,74 @@
{
"version": 4,
"targets": {
"net8.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net8.0": []
},
"packageFolders": {
"/Users/morris/.nuget/packages/": {}
},
"project": {
"version": "1.0.3",
"restore": {
"projectUniqueName": "/Users/morris/Downloads/GC#/model/_engine/VersionStamp/VersionStamp.csproj",
"projectName": "VersionStamp",
"projectPath": "/Users/morris/Downloads/GC#/model/_engine/VersionStamp/VersionStamp.csproj",
"packagesPath": "/Users/morris/.nuget/packages/",
"outputPath": "/Users/morris/Downloads/GC#/model/_engine/VersionStamp/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/Users/morris/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"framework": "net8.0",
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "10.0.400"
},
"frameworks": {
"net8.0": {
"framework": "net8.0",
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/10.0.401/PortableRuntimeIdentifierGraph.json"
}
}
}
}
@@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "tJZIToOhfvc=",
"success": true,
"projectFilePath": "/Users/morris/Downloads/GC#/model/_engine/VersionStamp/VersionStamp.csproj",
"expectedPackageFiles": [],
"logs": []
}
File diff suppressed because it is too large. Load diff
+904
View File
@@ -0,0 +1,904 @@
using System;
using System.Collections.Generic;
using Avalonia;
using Avalonia.Animation;
using Avalonia.Animation.Easings;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Threading;
using EarthModelStudio.ModelSdk;
namespace NeoRF.EarthModels;
/// <summary>
/// 模型自己的界面:画布 + 触控友好工具栏 + 课堂演示卡 + 节气定格与步进。
/// 启动器只负责下载、开窗口和进度条,不参与任何模型渲染或教学交互。
/// </summary>
public sealed class EarthModelView : UserControl, IDisposable
{
private static readonly IBrush PanelBg = new SolidColorBrush(Color.Parse("#C40A1020"));
private static readonly IBrush ControlBg = new SolidColorBrush(Color.Parse("#16233C"));
private static readonly IBrush Accent = new SolidColorBrush(Color.Parse("#2E6BE6"));
private static readonly IBrush TitleBrush = new SolidColorBrush(Color.Parse("#F2F6FF"));
private static readonly IBrush TextBrush = new SolidColorBrush(Color.Parse("#DCE7FA"));
private static readonly IBrush MutedBrush = new SolidColorBrush(Color.Parse("#7E93B8"));
private static readonly IBrush FaintBrush = new SolidColorBrush(Color.Parse("#61779C"));
private static readonly IBrush BodyBrush = new SolidColorBrush(Color.Parse("#8CA0C4"));
private static readonly IBrush WarmBrush = new SolidColorBrush(Color.Parse("#FFC46B"));
private static readonly TimeSpan HoverDuration = TimeSpan.FromMilliseconds(120);
private static readonly TimeSpan PanelDuration = TimeSpan.FromMilliseconds(190);
private readonly IModelContext _context;
private readonly ModelStrings _texts;
private readonly SceneRuntime _runtime;
private readonly List<string> _views;
private readonly List<ModelButton> _viewButtons = new();
private readonly CelestialView _canvas;
private readonly CelestialView _closeup;
private readonly DispatcherTimer _uiTimer;
private Border? _viewSwitch;
private StackPanel? _seasonPanel;
private Border? _lessons;
private Border? _closeupHost;
private TextBlock? _closeupLabel;
private ModelButton? _playButton;
private ModelButton? _overheadButton;
private ModelButton? _closeupButton;
private TextBlock? _zoomText;
private TextBlock? _cardState;
private TextBlock? _cardTitle;
private TextBlock? _cardDate;
private TextBlock? _cardDirect;
private TextBlock? _cardNote;
private bool _playing = true;
private bool _labels = true;
private bool _orbit = true;
private bool _grid = true;
private bool _tilt;
private bool _showLessons = true;
private bool _showCloseup = true;
private bool _overhead;
private double _lastDeclination = double.NaN;
public EarthModelView(IModelContext context, SceneRuntime runtime)
{
_context = context;
_runtime = runtime;
_texts = ModelStrings.Load(context.DataDirectory, context.Language);
_views = ResolveViews(runtime.Scene);
// 自转模型主画布本身就是放大的地球,不需要再来一份特写
_showCloseup = IsRevolution;
Background = new SolidColorBrush(Color.Parse("#05070F"));
_canvas = new CelestialView
{
Scene = runtime,
Texts = _texts,
ShowLabels = true,
ShowOrbit = true,
ShowGraticule = true,
ShowKeyLatitudes = true,
FrameRate = 120,
View = IsRevolution ? SceneView.Revolution : SceneView.Rotation
};
_canvas.JumpToOrbit(StartAngle);
_canvas.JumpToSpin(20);
_canvas.ZoomChanged += zoom =>
{
if (_zoomText != null) _zoomText.Text = $"{zoom * 100:0}%";
};
// 课堂特写:同一套渲染器,把当前直射纬度放大给全班看
_closeup = new CelestialView
{
Scene = runtime,
Texts = _texts,
View = SceneView.Rotation,
IsPlaying = false,
ShowHud = false,
ShowLabels = true,
ShowGraticule = false,
ShowKeyLatitudes = true,
InsetMode = true,
Width = 240,
Height = 240
};
_closeup.JumpToSpin(20);
_uiTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(140),
DispatcherPriority.Render, (_, _) => RefreshTeaching());
var root = new Grid { RowDefinitions = new RowDefinitions("Auto,Auto,*,Auto") };
var top = BuildTopBar();
root.Children.Add(top);
var options = BuildOptionsBar();
Grid.SetRow(options, 1);
root.Children.Add(options);
var stage = new Grid();
stage.Children.Add(_canvas);
stage.Children.Add(BuildZoomPad());
_lessons = BuildClassroomCard();
stage.Children.Add(_lessons);
Grid.SetRow(stage, 2);
root.Children.Add(stage);
var bottom = BuildBottomBar();
Grid.SetRow(bottom, 3);
root.Children.Add(bottom);
Content = root;
ApplyVisibility();
RefreshTeaching();
// 打开时整窗淡入,避免「啪」地出现
Opacity = 0;
Transitions = new Transitions
{
new DoubleTransition
{
Property = OpacityProperty,
Duration = TimeSpan.FromMilliseconds(260),
Easing = new CubicEaseOut()
}
};
AttachedToVisualTree += (_, _) =>
{
Opacity = 1;
_uiTimer.Start();
if (TopLevel.GetTopLevel(this) is Window window)
{
_hostWindow = window;
window.KeyDown += OnKeyDown;
}
};
DetachedFromVisualTree += (_, _) =>
{
_uiTimer.Stop();
if (_hostWindow != null)
{
_hostWindow.KeyDown -= OnKeyDown;
_hostWindow = null;
}
};
}
private Window? _hostWindow;
/// <summary>
/// 窗口关闭时释放计时器、解绑窗口事件并释放两块球面位图,
/// 否则 DispatcherTimer / KeyDown 会持有控件,使 collectible ALC 无法卸载。
/// </summary>
public void Dispose()
{
_uiTimer.Stop();
if (_hostWindow != null)
{
_hostWindow.KeyDown -= OnKeyDown;
_hostWindow = null;
}
_canvas.Dispose();
_closeup.Dispose();
GC.SuppressFinalize(this);
}
private string CurrentView { get; set; } = "rotation";
private double StartAngle => IsRevolution ? 60 : 0;
private bool IsRevolution => string.Equals(CurrentView, "revolution", StringComparison.OrdinalIgnoreCase);
private bool HasViewSwitch => _views.Count > 1;
private List<SeasonPoint> Seasons => _runtime.Scene.Orbit.Seasons;
private static string NormalizeView(string? view)
=> string.Equals(view, "revolution", StringComparison.OrdinalIgnoreCase) ? "revolution" : "rotation";
private List<string> ResolveViews(SceneDefinition scene)
{
var list = new List<string>();
foreach (var v in scene.Views)
{
var normalized = NormalizeView(v);
if (!list.Contains(normalized)) list.Add(normalized);
}
if (list.Count == 0) list.Add(NormalizeView(scene.DefaultView));
CurrentView = list[0];
return list;
}
// ---------------------------------------------------------------- 顶部主工具栏
private Control BuildTopBar()
{
// 关闭按钮统一放在窗口右上角的自建标题栏,这里不再重复放左上角
var title = new StackPanel { Spacing = 1, VerticalAlignment = VerticalAlignment.Center };
title.Children.Add(new TextBlock
{
Text = _texts.Pick(_runtime.Scene.NameI18n, _texts["title"]),
Foreground = TitleBrush,
FontSize = 14,
FontWeight = FontWeight.SemiBold
});
title.Children.Add(new TextBlock
{
Text = _texts.Pick(_runtime.Scene.DescriptionI18n, ""),
Foreground = MutedBrush,
FontSize = 10.5,
MaxWidth = 330,
TextTrimming = TextTrimming.CharacterEllipsis
});
var switchPanel = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 3 };
switchPanel.Children.Add(MakeViewButton("rotation", _texts["view.rotation"]));
switchPanel.Children.Add(MakeViewButton("revolution", _texts["view.revolution"]));
_viewSwitch = new Border
{
Background = ControlBg,
CornerRadius = new CornerRadius(10),
Padding = new Thickness(3),
Margin = new Thickness(16, 0, 0, 0),
VerticalAlignment = VerticalAlignment.Center,
Child = switchPanel
};
var actions = new StackPanel
{
Orientation = Orientation.Horizontal,
Spacing = 8,
VerticalAlignment = VerticalAlignment.Center
};
_playButton = MakeButton(_texts["pause"], TogglePlay);
_playButton.MinWidth = 74;
actions.Children.Add(_playButton);
actions.Children.Add(MakeButton(_texts["reset"], () =>
{
_canvas.ResetAnimation();
_canvas.JumpToOrbit(StartAngle);
RefreshTeaching();
}));
actions.Children.Add(MakeButton("◀", () => Step(-5), large: true));
actions.Children.Add(MakeButton("▶", () => Step(5), large: true));
actions.Children.Add(MakeButton(_texts["classroom"], () => SetLessonsVisible(!_showLessons)));
actions.Children.Add(MakeButton("⛶", ToggleFullScreen, large: true));
var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,Auto,*,Auto") };
Grid.SetColumn(title, 0);
title.Margin = new Thickness(14, 0, 0, 0);
grid.Children.Add(title);
Grid.SetColumn(_viewSwitch, 1);
grid.Children.Add(_viewSwitch);
Grid.SetColumn(actions, 3);
grid.Children.Add(actions);
return new Border { Background = PanelBg, Padding = new Thickness(16, 9), Child = grid };
}
// ---------------------------------------------------------------- 显示选项行
private Control BuildOptionsBar()
{
var row = new StackPanel
{
Orientation = Orientation.Horizontal,
Spacing = 7,
VerticalAlignment = VerticalAlignment.Center
};
row.Children.Add(MakeToggle(_texts["labels"], _labels, on => { _labels = on; _canvas.ShowLabels = on; }));
row.Children.Add(MakeToggle(_texts["orbit"], _orbit, on => { _orbit = on; _canvas.ShowOrbit = on; }));
row.Children.Add(MakeToggle(_texts["grid"], _grid, on => { _grid = on; _canvas.ShowGraticule = on; }));
row.Children.Add(MakeToggle(_texts["tilt"], _tilt, on => { _tilt = on; _canvas.ExaggerateTilt = on; }));
_closeupButton = MakeToggle(_texts["closeup"], _showCloseup, on =>
{
_showCloseup = on;
ApplyVisibility();
});
row.Children.Add(_closeupButton);
_overheadButton = MakeToggle(_texts["overhead"], _overhead, on =>
{
_overhead = on;
// 视角只由这个显式控件改变;拖动永远不会碰它
_canvas.CameraElevation = on ? (IsRevolution ? 74 : 62) : double.NaN;
});
row.Children.Add(_overheadButton);
var shortcut = new TextBlock
{
Text = _texts["shortcutHint"],
Foreground = FaintBrush,
FontSize = 10.5,
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(12, 0, 0, 0)
};
var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*") };
grid.Children.Add(row);
Grid.SetColumn(shortcut, 1);
grid.Children.Add(shortcut);
return new Border
{
Background = new SolidColorBrush(Color.Parse("#A00A1020")),
Padding = new Thickness(16, 7),
Child = grid
};
}
private ModelButton MakeViewButton(string view, string label)
{
var button = MakeButton(label, () => SwitchView(view));
button.SetBase(string.Equals(CurrentView, view, StringComparison.OrdinalIgnoreCase) ? Accent : ControlBg);
button.Tag = view;
button.IsVisible = _views.Contains(view);
_viewButtons.Add(button);
return button;
}
private ModelButton MakeToggle(string label, bool initial, Action<bool> changed)
{
var state = initial;
ModelButton? button = null;
button = MakeButton(label, () =>
{
state = !state;
changed(state);
button?.SetBase(state ? Accent : ControlBg);
});
button.SetBase(initial ? Accent : ControlBg);
return button;
}
private void SwitchView(string view)
{
CurrentView = NormalizeView(view);
_canvas.View = IsRevolution ? SceneView.Revolution : SceneView.Rotation;
_canvas.JumpToOrbit(StartAngle);
_canvas.CameraElevation = _overhead ? (IsRevolution ? 74 : 62) : double.NaN;
foreach (var button in _viewButtons)
button.SetBase(string.Equals(button.Tag as string, CurrentView, StringComparison.OrdinalIgnoreCase)
? Accent
: ControlBg);
ApplyVisibility();
RefreshTeaching();
}
// ---------------------------------------------------------------- 画布浮动缩放板(触控大按钮)
private Control BuildZoomPad()
{
var plus = MakeButton("+", () => _canvas.ZoomBy(1.25), large: true);
var minus = MakeButton("-", () => _canvas.ZoomBy(1 / 1.25), large: true);
var reset = MakeButton("⟲", () => _canvas.ResetView(), large: true);
foreach (var b in new[] { plus, minus, reset })
{
b.MinWidth = 62;
b.MinHeight = 48;
b.HorizontalAlignment = HorizontalAlignment.Stretch;
}
_zoomText = new TextBlock
{
Text = "100%",
Foreground = TextBrush,
FontSize = 13,
FontWeight = FontWeight.SemiBold,
TextAlignment = TextAlignment.Center,
Margin = new Thickness(0, 2, 0, 2)
};
var stack = new StackPanel { Spacing = 6, Width = 62 };
stack.Children.Add(new TextBlock
{
Text = _texts["zoom"],
Foreground = MutedBrush,
FontSize = 10.5,
TextAlignment = TextAlignment.Center
});
stack.Children.Add(plus);
stack.Children.Add(_zoomText);
stack.Children.Add(minus);
stack.Children.Add(reset);
return new Border
{
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Bottom,
Margin = new Thickness(16, 0, 0, 16),
Background = new SolidColorBrush(Color.Parse("#C00B1226")),
BorderBrush = new SolidColorBrush(Color.Parse("#26374F")),
BorderThickness = new Thickness(1),
CornerRadius = new CornerRadius(14),
Padding = new Thickness(10),
Child = stack
};
}
// ---------------------------------------------------------------- 底部
private Control BuildBottomBar()
{
var speedLabel = new TextBlock
{
Text = _texts["speed"],
Foreground = new SolidColorBrush(Color.Parse("#9DB0D0")),
VerticalAlignment = VerticalAlignment.Center
};
var slider = new Slider
{
Minimum = 0.25,
Maximum = 4,
Value = 1,
Margin = new Thickness(12, 0, 0, 0),
Width = 180,
Height = 38
};
var speedText = new TextBlock
{
Text = "1×",
Foreground = TextBrush,
VerticalAlignment = VerticalAlignment.Center,
Width = 46,
Margin = new Thickness(6, 0, 0, 0)
};
slider.ValueChanged += (_, e) =>
{
_canvas.Speed = e.NewValue;
speedText.Text = $"{e.NewValue:0.##}×";
};
var hint = new TextBlock
{
Text = _texts["hint"],
Foreground = FaintBrush,
FontSize = 10.5,
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(20, 0, 0, 0),
TextTrimming = TextTrimming.CharacterEllipsis
};
_seasonPanel = new StackPanel
{
Orientation = Orientation.Horizontal,
Spacing = 7,
VerticalAlignment = VerticalAlignment.Center
};
_seasonPanel.Children.Add(new TextBlock
{
Text = _texts["seasons"],
Foreground = MutedBrush,
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(0, 0, 6, 0)
});
foreach (var season in Seasons) _seasonPanel.Children.Add(MakeSeasonButton(season));
var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,Auto,Auto,*,Auto") };
grid.Children.Add(speedLabel);
Grid.SetColumn(slider, 1);
grid.Children.Add(slider);
Grid.SetColumn(speedText, 2);
grid.Children.Add(speedText);
Grid.SetColumn(hint, 3);
grid.Children.Add(hint);
Grid.SetColumn(_seasonPanel, 4);
grid.Children.Add(_seasonPanel);
return new Border { Background = PanelBg, Padding = new Thickness(16, 8), Child = grid };
}
private ModelButton MakeSeasonButton(SeasonPoint season)
{
var captured = season;
var button = MakeButton(_texts[season.Key], () => JumpToSeason(captured));
button.MinHeight = 44;
return button;
}
// ---------------------------------------------------------------- 课堂演示卡
private Border BuildClassroomCard()
{
var header = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto") };
header.Children.Add(new TextBlock
{
Text = _texts["classroom"],
Foreground = TitleBrush,
FontWeight = FontWeight.SemiBold,
FontSize = 13,
VerticalAlignment = VerticalAlignment.Center
});
var close = MakeButton("✕", () => SetLessonsVisible(false));
close.SetBase(Brushes.Transparent);
Grid.SetColumn(close, 1);
header.Children.Add(close);
_cardState = new TextBlock
{
Text = _texts["running"],
Foreground = MutedBrush,
FontSize = 11,
Margin = new Thickness(0, 6, 0, 0)
};
_cardTitle = new TextBlock
{
Foreground = TitleBrush,
FontSize = 20,
FontWeight = FontWeight.Bold
};
_cardDate = new TextBlock { Foreground = MutedBrush, FontSize = 12 };
_cardDirect = new TextBlock
{
Foreground = WarmBrush,
FontSize = 27,
FontWeight = FontWeight.Bold
};
_cardNote = new TextBlock
{
Foreground = BodyBrush,
FontSize = 12,
TextWrapping = TextWrapping.Wrap,
LineHeight = 18
};
_closeupHost = new Border
{
CornerRadius = new CornerRadius(10),
BorderBrush = new SolidColorBrush(Color.Parse("#26374F")),
BorderThickness = new Thickness(1),
HorizontalAlignment = HorizontalAlignment.Center,
Margin = new Thickness(0, 4, 0, 2),
Child = _closeup
};
var readouts = new StackPanel { Spacing = 2 };
readouts.Children.Add(_cardState);
readouts.Children.Add(_cardTitle);
readouts.Children.Add(_cardDate);
readouts.Children.Add(new TextBlock
{
Text = _texts["directPoint"],
Foreground = MutedBrush,
FontSize = 11,
Margin = new Thickness(0, 8, 0, 0)
});
readouts.Children.Add(_cardDirect);
readouts.Children.Add(_cardNote);
_closeupLabel = new TextBlock
{
Text = _texts["closeup"],
Foreground = MutedBrush,
FontSize = 11,
Margin = new Thickness(0, 6, 0, 0)
};
readouts.Children.Add(_closeupLabel);
readouts.Children.Add(_closeupHost);
var list = new StackPanel { Spacing = 2 };
foreach (var lesson in _runtime.Scene.Lessons)
{
var title = new TextBlock
{
Text = _texts.Pick(lesson.TitleI18n, ""),
Foreground = new SolidColorBrush(Color.Parse("#CFE0FF")),
FontSize = 12,
FontWeight = FontWeight.SemiBold,
TextWrapping = TextWrapping.Wrap
};
var body = new TextBlock
{
Text = _texts.Pick(lesson.BodyI18n, ""),
Foreground = BodyBrush,
FontSize = 11,
TextWrapping = TextWrapping.Wrap
};
var stack = new StackPanel { Spacing = 3 };
stack.Children.Add(title);
stack.Children.Add(body);
var button = new Button
{
Content = stack,
Background = Brushes.Transparent,
BorderThickness = new Thickness(0),
HorizontalAlignment = HorizontalAlignment.Stretch,
HorizontalContentAlignment = HorizontalAlignment.Left,
Padding = new Thickness(8, 9),
Margin = new Thickness(0, 1),
MinHeight = 44,
Cursor = new Cursor(StandardCursorType.Hand),
Transitions = new Transitions
{
new BrushTransition { Property = BackgroundProperty, Duration = HoverDuration }
}
};
var captured = lesson;
button.Click += (_, _) => ApplyLesson(captured);
button.PointerEntered += (_, _) => button.Background = new SolidColorBrush(Color.Parse("#1B2A47"));
button.PointerExited += (_, _) => button.Background = Brushes.Transparent;
list.Children.Add(button);
}
var content = new StackPanel { Spacing = 8 };
content.Children.Add(readouts);
content.Children.Add(new TextBlock
{
Text = _texts["lessons"],
Foreground = TitleBrush,
FontWeight = FontWeight.SemiBold,
FontSize = 12.5
});
content.Children.Add(list);
var bodyGrid = new Grid { RowDefinitions = new RowDefinitions("Auto,*") };
bodyGrid.Children.Add(header);
var scroller = new ScrollViewer
{
Content = content,
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
Margin = new Thickness(0, 8, 0, 0)
};
Grid.SetRow(scroller, 1);
bodyGrid.Children.Add(scroller);
var panel = new Border
{
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Stretch,
Width = 296,
Margin = new Thickness(0, 12, 16, 12),
Background = new SolidColorBrush(Color.Parse("#D00B1226")),
CornerRadius = new CornerRadius(14),
Padding = new Thickness(13),
BorderBrush = new SolidColorBrush(Color.Parse("#26374F")),
BorderThickness = new Thickness(1),
Child = bodyGrid,
RenderTransform = new TranslateTransform(0, 0)
};
panel.Transitions = new Transitions
{
new DoubleTransition { Property = OpacityProperty, Duration = PanelDuration, Easing = new CubicEaseOut() },
new DoubleTransition
{
Property = TranslateTransform.XProperty,
Duration = PanelDuration,
Easing = new CubicEaseOut()
}
};
return panel;
}
private void SetLessonsVisible(bool visible)
{
_showLessons = visible;
if (_lessons == null) return;
if (visible)
{
_lessons.IsVisible = true;
_lessons.Opacity = 1;
if (_lessons.RenderTransform is TranslateTransform transform) transform.X = 0;
return;
}
_lessons.Opacity = 0;
if (_lessons.RenderTransform is TranslateTransform hidden) hidden.X = 26;
var timer = new DispatcherTimer { Interval = PanelDuration };
timer.Tick += (_, _) =>
{
timer.Stop();
if (!_showLessons && _lessons != null) _lessons.IsVisible = false;
};
timer.Start();
}
/// <summary>课堂卡与地球特写跟随当前轨道位置刷新(播放时每 140ms 更新一次)。</summary>
private void RefreshTeaching()
{
if (_cardTitle == null) return;
var season = IsRevolution ? _canvas.NearestSeason(6) : null;
var decl = _canvas.SubsolarLatitude;
_cardState!.Text = _playing ? _texts["running"] : _texts["frozen"];
_cardState.Foreground = _playing ? MutedBrush : WarmBrush;
_cardTitle.Text = season != null
? _texts[season.Key]
: (IsRevolution ? _texts["seasons"] : _texts.Pick(_runtime.Scene.NameI18n, _texts["title"]));
_cardDate!.Text = IsRevolution ? _canvas.CurrentDate : _texts["dayNight"];
_cardDirect!.Text = season?.DeclinationDeg.HasValue == true
? FormatDeclination(season.DeclinationDeg.Value)
: _canvas.DeclinationLabel;
_cardNote!.Text = !IsRevolution
? _texts["rotationTeach"]
: season != null
? _texts.Pick(season.TeachingI18n, _texts["orbitTeach"])
: _texts["orbitTeach"];
// 特写的直射纬度用缓动逼近目标,而不是瞬间跳变:
// 公转时拖动/改变轨道角,晨昏线会平滑地移过去(每次 timer 步进一帧)。
if (_showCloseup)
{
var target = decl;
var current = _closeup.DeclinationDeg;
var diff = target - current;
if (Math.Abs(diff) < 0.02)
{
_closeup.DeclinationDeg = target;
}
else
{
// 每 140ms 走剩余距离的 ~18%,形成自然的 ease-out 动画
_closeup.DeclinationDeg = current + diff * 0.18;
}
_lastDeclination = target;
}
}
private string FormatDeclination(double d)
=> Math.Abs(d) < 0.05
? "0° " + _texts["lat.equator"]
: $"{Math.Abs(d):0.0}°" + (d > 0 ? _texts["northShort"] : _texts["southShort"]);
private void ApplyLesson(Lesson lesson)
{
if (!string.IsNullOrWhiteSpace(lesson.View))
{
var view = NormalizeView(lesson.View);
if (!string.Equals(view, CurrentView, StringComparison.OrdinalIgnoreCase)) SwitchView(view);
}
// 讲要点时自动定格,读数不再跳动,方便指读板书
SetPlaying(false);
if (lesson.AngleDeg.HasValue) _canvas.JumpToOrbit(lesson.AngleDeg.Value);
RefreshTeaching();
}
// ---------------------------------------------------------------- 教学操作
private void SetPlaying(bool play)
{
_playing = play;
_canvas.IsPlaying = play;
if (_playButton?.Content is TextBlock block)
block.Text = play ? _texts["pause"] : _texts["play"];
RefreshTeaching();
}
private void TogglePlay() => SetPlaying(!_playing);
private void Step(double deltaDeg)
{
SetPlaying(false);
if (IsRevolution) _canvas.StepOrbit(deltaDeg);
else _canvas.StepSpin(deltaDeg);
RefreshTeaching();
}
private void JumpToSeason(SeasonPoint season)
{
if (!IsRevolution) SwitchView("revolution");
SetPlaying(false);
_canvas.JumpToOrbit(season.AngleDeg);
RefreshTeaching();
}
private void JumpToSeasonIndex(int index)
{
if (index < 0 || index >= Seasons.Count) return;
JumpToSeason(Seasons[index]);
}
private void ToggleFullScreen()
{
try
{
if (TopLevel.GetTopLevel(this) is Window window)
window.WindowState = window.WindowState == WindowState.FullScreen
? WindowState.Normal
: WindowState.FullScreen;
}
catch (Exception ex)
{
_context.Log("全屏切换失败: " + ex.Message);
}
}
private void OnKeyDown(object? sender, KeyEventArgs e)
{
switch (e.Key)
{
case Key.Space:
TogglePlay();
e.Handled = true;
break;
case Key.Left:
Step(-5);
e.Handled = true;
break;
case Key.Right:
Step(5);
e.Handled = true;
break;
case Key.D1: JumpToSeasonIndex(0); e.Handled = true; break;
case Key.D2: JumpToSeasonIndex(1); e.Handled = true; break;
case Key.D3: JumpToSeasonIndex(2); e.Handled = true; break;
case Key.D4: JumpToSeasonIndex(3); e.Handled = true; break;
case Key.F: ToggleFullScreen(); e.Handled = true; break;
case Key.Add: _canvas.ZoomBy(1.25); e.Handled = true; break;
case Key.Subtract: _canvas.ZoomBy(1 / 1.25); e.Handled = true; break;
case Key.D0: _canvas.ResetView(); e.Handled = true; break;
}
}
// ---------------------------------------------------------------- 工具
private ModelButton MakeButton(string text, Action onClick, bool large = false)
{
var button = new ModelButton
{
Content = new TextBlock { Text = text, FontSize = large ? 20 : 12.5 },
Foreground = TextBrush,
BorderThickness = new Thickness(0),
CornerRadius = new CornerRadius(9),
Padding = large ? new Thickness(10, 8) : new Thickness(13, 9),
MinWidth = large ? 46 : 44,
MinHeight = 40,
HorizontalContentAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Cursor = new Cursor(StandardCursorType.Hand)
};
button.SetBase(ControlBg);
button.Click += (_, _) => onClick();
return button;
}
private void ApplyVisibility()
{
if (_viewSwitch != null) _viewSwitch.IsVisible = HasViewSwitch;
if (_lessons != null) _lessons.IsVisible = _showLessons;
if (_seasonPanel != null) _seasonPanel.IsVisible = IsRevolution;
if (_closeupHost != null) _closeupHost.IsVisible = _showCloseup;
if (_closeupLabel != null) _closeupLabel.IsVisible = _showCloseup;
}
/// <summary>带悬停过渡的按钮:本地基础色 + 悬停提亮。</summary>
private sealed class ModelButton : Button
{
private IBrush _base = ControlBg;
private IBrush _hover = ControlBg;
public ModelButton()
{
Transitions = new Transitions
{
new BrushTransition { Property = BackgroundProperty, Duration = HoverDuration }
};
}
public void SetBase(IBrush brush)
{
_base = brush;
_hover = Lighten(brush);
Background = brush;
}
protected override void OnPointerEntered(PointerEventArgs e)
{
base.OnPointerEntered(e);
Background = _hover;
}
protected override void OnPointerExited(PointerEventArgs e)
{
base.OnPointerExited(e);
Background = _base;
}
private static IBrush Lighten(IBrush brush)
{
if (brush is not SolidColorBrush solid) return brush;
var c = solid.Color;
return new SolidColorBrush(Color.FromArgb(c.A,
(byte)Math.Min(255, c.R + 26),
(byte)Math.Min(255, c.G + 26),
(byte)Math.Min(255, c.B + 30)));
}
}
}
+45
View File
@@ -0,0 +1,45 @@
using System;
using Avalonia.Controls;
using EarthModelStudio.ModelSdk;
namespace NeoRF.EarthModels;
/// <summary>
/// 地球模型共享运行时:读自己目录下的 scene.json / land.json / i18n,
/// 然后把自带界面交给启动器。启动器完全不知道“地球”“节气”这些东西。
/// </summary>
public sealed class EarthModelRuntime : IModelRuntime
{
public const int SupportedApiVersion = 1;
private SceneRuntime? _scene;
/// <summary>后台准备:读场景、生成地表纹理(耗时都花在这里,进度条能实时走)。</summary>
public void Prepare(IModelContext context)
{
context.ReportProgress(0.03, "读取场景数据");
_scene = SceneRuntime.Load(context.DataDirectory, context.MemoryBudgetMb, context.ReportProgress);
context.Log($"[{context.ModelId}] 场景已加载:{_scene.Scene.DefaultView}," +
$"地表纹理 {(_scene.Texture == null ? "无" : _scene.Texture.Width + "×" + _scene.Texture.Height)}");
}
/// <summary>UI 线程构建界面(很快)。</summary>
public Control CreateView(IModelContext context)
{
context.ReportProgress(0.78, "构建界面");
_scene ??= SceneRuntime.Load(context.DataDirectory, context.MemoryBudgetMb, context.ReportProgress);
var view = new EarthModelView(context, _scene);
context.ReportProgress(1.0, "准备就绪");
return view;
}
/// <summary>
/// 释放预烘焙纹理(约 3MB 托管数组)与场景引用。窗口关闭时由启动器调用,
/// 避免 collectible ALC 里的类型被长生命周期引用拖住而无法卸载。
/// </summary>
public void Dispose()
{
_scene = null;
GC.SuppressFinalize(this);
}
}
+110
View File
@@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using System.Numerics;
namespace NeoRF.EarthModels;
/// <summary>
/// 地理模型的球面几何工具:经纬度 ↔ 单位球坐标、正交投影到屏幕、
/// 以及把一条经纬度折线投影成「可见弧段」(背面自动裁掉)。
/// 纯 CPU、无依赖,供 GeographyView 画线稿用。
/// </summary>
public static class Geometry
{
public const float DegToRad = (float)(Math.PI / 180.0);
public const float RadToDeg = (float)(180.0 / Math.PI);
/// <summary>经纬度 → 单位球坐标(y 轴为地轴,lon 向东为正)。</summary>
public static Vector3 LatLonToUnit(double latDeg, double lonDeg)
{
var lat = (float)(latDeg * Math.PI / 180.0);
var lon = (float)(lonDeg * Math.PI / 180.0);
var cosLat = (float)Math.Cos(lat);
return new Vector3(cosLat * (float)Math.Sin(lon), (float)Math.Sin(lat), cosLat * (float)Math.Cos(lon));
}
/// <summary>把世界坐标旋转到相机空间(先用 planet 旋转地球,再用 cam 转到屏幕)。</summary>
public static Vector3 ToCamera(Vector3 world, Matrix4x4 planet, Matrix4x4 cam)
=> Vector3.Transform(Vector3.Transform(world, planet), cam);
/// <summary>相机空间的正交投影:球心在原点,半径 radius。</summary>
public static Vector2 Project(Vector3 camPos, float radius, float centerX, float centerY)
=> new(centerX + camPos.X * radius, centerY - camPos.Y * radius);
/// <summary>相机空间里该点是否朝向观察者(z>0 为正面)。</summary>
public static bool IsVisible(Vector3 camPos, float threshold = 0f) => camPos.Z > threshold;
/// <summary>
/// 把一条经纬度折线拆成若干段「可见」的屏幕折线。
/// 跨越地平线的相邻两点用线性插值求出交点作为端点,保证线不会穿过球体背面。
/// </summary>
public static List<List<Vector2>> ProjectPolyline(
IReadOnlyList<double[]> latLonPoints,
Matrix4x4 planet, Matrix4x4 cam,
float radius, float centerX, float centerY,
bool closed = false)
{
var result = new List<List<Vector2>>();
if (latLonPoints.Count < 2) return result;
var count = latLonPoints.Count;
var total = closed ? count + 1 : count;
List<Vector2>? current = null;
Vector3 prevCam = default;
var havePrev = false;
for (var i = 0; i < total; i++)
{
var p = latLonPoints[i % count];
if (p.Length < 2) { havePrev = false; continue; }
var camPos = ToCamera(LatLonToUnit(p[1], p[0]), planet, cam);
var visible = camPos.Z > 0f;
if (!havePrev)
{
if (visible)
{
current = new List<Vector2>();
current.Add(Project(camPos, radius, centerX, centerY));
}
prevCam = camPos;
havePrev = true;
continue;
}
var prevVisible = prevCam.Z > 0f;
if (visible && prevVisible)
{
current ??= new List<Vector2>();
current.Add(Project(camPos, radius, centerX, centerY));
}
else if (visible != prevVisible)
{
// 求出与地平线(z=0)的交点
var t = prevCam.Z / (prevCam.Z - camPos.Z);
var hit = Vector3.Lerp(prevCam, camPos, t);
hit.Z = 0f;
var hitScreen = Project(hit, radius, centerX, centerY);
if (visible)
{
current = new List<Vector2> { hitScreen };
current.Add(Project(camPos, radius, centerX, centerY));
}
else
{
current?.Add(hitScreen);
if (current is { Count: > 1 }) result.Add(current);
current = null;
}
}
prevCam = camPos;
}
if (current is { Count: > 1 }) result.Add(current);
return result;
}
}
+159
View File
@@ -0,0 +1,159 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace NeoRF.EarthModels;
/// <summary>&lt;id&gt;.model/land.json —— 简化的大陆轮廓(经纬度多边形)。</summary>
public sealed class LandData
{
[JsonPropertyName("polygons")] public List<LandPolygon> Polygons { get; set; } = new();
public static LandData? Load(string path)
{
if (!File.Exists(path)) return null;
try
{
return JsonSerializer.Deserialize<LandData>(File.ReadAllText(path), ModelJson.Options);
}
catch (Exception ex)
{
Console.Error.WriteLine($"解析地表数据失败 {path}: {ex.Message}");
return null;
}
}
}
public sealed class LandPolygon
{
[JsonPropertyName("name")] public string? Name { get; set; }
/// <summary>[[lon, lat], ...]</summary>
[JsonPropertyName("points")] public List<double[]> Points { get; set; } = new();
}
/// <summary>
/// 等经纬度栅格地表掩膜(0=海洋 255=陆地),双线性采样。
/// 每个模型只生成一次,受内存预算约束。
/// </summary>
public sealed class LandMask
{
public int Width { get; init; }
public int Height { get; init; }
public byte[] Bits { get; init; } = Array.Empty<byte>();
public long ByteSize => Bits.LongLength;
public static LandMask Build(LandData data, int width = 1440, int height = 720)
{
var bits = new byte[width * height];
foreach (var poly in data.Polygons)
{
if (poly.Points.Count < 3) continue;
var pts = Unwrap(poly.Points);
if (pts.Count < 3) continue;
for (var shift = -1; shift <= 1; shift++)
Rasterize(bits, width, height, pts, shift * 360.0);
}
return new LandMask { Width = width, Height = height, Bits = bits };
}
private static List<(double Lon, double Lat)> Unwrap(List<double[]> points)
{
var result = new List<(double, double)>(points.Count);
if (points.Count == 0 || points[0].Length < 2) return result;
var prev = points[0][0];
result.Add((prev, points[0][1]));
for (var i = 1; i < points.Count; i++)
{
if (points[i].Length < 2) continue;
var lon = points[i][0];
while (lon - prev > 180) lon -= 360;
while (prev - lon > 180) lon += 360;
result.Add((lon, points[i][1]));
prev = lon;
}
return result;
}
private static void Rasterize(byte[] bits, int w, int h, List<(double Lon, double Lat)> pts, double lonShift)
{
var n = pts.Count;
var xs = new double[n];
var ys = new double[n];
double minY = double.MaxValue, maxY = double.MinValue;
for (var i = 0; i < n; i++)
{
xs[i] = (pts[i].Lon + lonShift + 180.0) / 360.0 * w;
ys[i] = (90.0 - pts[i].Lat) / 180.0 * h;
if (ys[i] < minY) minY = ys[i];
if (ys[i] > maxY) maxY = ys[i];
}
var y0 = Math.Max(0, (int)Math.Floor(minY));
var y1 = Math.Min(h - 1, (int)Math.Ceiling(maxY));
var crossings = new List<double>(16);
for (var y = y0; y <= y1; y++)
{
var sy = y + 0.5;
crossings.Clear();
for (var i = 0; i < n; i++)
{
var j = (i + 1) % n;
double ya = ys[i], yb = ys[j];
if (!((ya <= sy && yb > sy) || (yb <= sy && ya > sy))) continue;
var t = (sy - ya) / (yb - ya);
crossings.Add(xs[i] + t * (xs[j] - xs[i]));
}
if (crossings.Count < 2) continue;
crossings.Sort();
for (var k = 0; k + 1 < crossings.Count; k += 2)
{
var xa = (int)Math.Ceiling(crossings[k] - 0.5);
var xb = (int)Math.Floor(crossings[k + 1] - 0.5);
if (xb < xa) continue;
if (xb - xa >= w - 1)
{
for (var x = 0; x < w; x++) bits[y * w + x] = 255;
continue;
}
for (var x = xa; x <= xb; x++)
{
var mx = x % w;
if (mx < 0) mx += w;
bits[y * w + mx] = 255;
}
}
}
}
/// <summary>返回 0..1 的陆地覆盖度。</summary>
public double Sample(double lonDeg, double latDeg)
{
var u = (lonDeg + 180.0) / 360.0 * Width - 0.5;
var v = (90.0 - latDeg) / 180.0 * Height - 0.5;
var x0 = (int)Math.Floor(u);
var y0 = (int)Math.Floor(v);
var fx = u - x0;
var fy = v - y0;
double sum = 0;
for (var dy = 0; dy < 2; dy++)
{
var y = y0 + dy;
if (y < 0) y = 0;
if (y >= Height) y = Height - 1;
var wy = dy == 0 ? 1 - fy : fy;
for (var dx = 0; dx < 2; dx++)
{
var x = x0 + dx;
var mx = x % Width;
if (mx < 0) mx += Width;
var wx = dx == 0 ? 1 - fx : fx;
sum += Bits[y * Width + mx] * wx * wy;
}
}
return sum / 255.0;
}
}
+27
View File
@@ -0,0 +1,27 @@
using System.IO;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace NeoRF.EarthModels;
/// <summary>模型自己的 JSON 读写(不依赖启动器)。</summary>
public static class ModelJson
{
public static readonly JsonSerializerOptions Options = new()
{
PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
AllowTrailingCommas = true,
ReadCommentHandling = JsonCommentHandling.Skip
};
public static T? Read<T>(string path)
{
if (!File.Exists(path)) return default;
return JsonSerializer.Deserialize<T>(File.ReadAllText(path), Options);
}
}
+186
View File
@@ -0,0 +1,186 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text.Json;
namespace NeoRF.EarthModels;
/// <summary>
/// 模型自己的一份文案。优先读模型数据目录里的 <c>i18n/&lt;language&gt;.json</c>,
/// 缺失时回退到代码内的默认文案,保证模型在没有语言包时也能完整显示。
/// 启动器不再持有任何模型相关文案。
/// </summary>
public sealed class ModelStrings
{
private readonly Dictionary<string, string> _texts;
public string Language { get; }
private ModelStrings(string language, Dictionary<string, string> texts)
{
Language = language;
_texts = texts;
}
public static ModelStrings Default { get; } = new("zh-CN", DefaultTexts.Zh);
public string this[string key]
=> _texts.TryGetValue(key, out var value) ? value
: DefaultTexts.Zh.TryGetValue(key, out var fallback) ? fallback
: key;
public string F(string key, params object[] args)
=> string.Format(CultureInfo.InvariantCulture, this[key], args);
public string Pick(Dictionary<string, string>? i18n, string fallback)
{
if (i18n == null) return fallback;
if (i18n.TryGetValue(Language, out var exact) && !string.IsNullOrWhiteSpace(exact)) return exact;
foreach (var pair in i18n)
{
if (Language.StartsWith(pair.Key, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(pair.Value))
return pair.Value;
}
if (i18n.TryGetValue("zh-CN", out var zh) && !string.IsNullOrWhiteSpace(zh)) return zh;
return fallback;
}
public static ModelStrings Load(string dataDirectory, string language)
{
var zh = new Dictionary<string, string>(DefaultTexts.Zh);
var isEnglish = language.StartsWith("en", StringComparison.OrdinalIgnoreCase);
var chosen = isEnglish ? new Dictionary<string, string>(DefaultTexts.En) : new Dictionary<string, string>(zh);
// 语言包可以覆盖任意键:i18n/<language>.json
var dir = Path.Combine(dataDirectory, "i18n");
Overlay(Path.Combine(dir, language + ".json"), chosen);
if (!isEnglish) Overlay(Path.Combine(dir, "zh-CN.json"), chosen);
return new ModelStrings(isEnglish ? "en" : "zh-CN", chosen);
}
private static void Overlay(string path, Dictionary<string, string> target)
{
if (!File.Exists(path)) return;
try
{
var map = JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(path), ModelJson.Options);
if (map == null) return;
foreach (var pair in map) target[pair.Key] = pair.Value;
}
catch (Exception ex)
{
Console.Error.WriteLine($"读取模型语言包失败 {path}: {ex.Message}");
}
}
}
internal static class DefaultTexts
{
public static readonly Dictionary<string, string> Zh = new()
{
["title"] = "地球模型",
["view.rotation"] = "自转",
["view.revolution"] = "公转",
["play"] = "播放",
["pause"] = "暂停",
["speed"] = "速度",
["reset"] = "重置",
["labels"] = "标注",
["orbit"] = "轨道",
["grid"] = "经纬网",
["tilt"] = "夸张倾角",
["lessons"] = "教学要点",
["seasons"] = "节气定位",
["close"] = "关闭窗口",
["hint"] = "双指捏合或滚轮缩放 · 拖动可转动地球",
["shortcutHint"] = "空格 播放/暂停 · ←→ 步进 · 1–4 二分二至 · F 全屏",
["classroom"] = "课堂演示",
["directPoint"] = "太阳直射",
["frozen"] = "已定格",
["running"] = "播放中",
["step"] = "步进",
["closeup"] = "地球特写",
["overhead"] = "俯视",
["sideview"] = "侧视",
["zoom"] = "缩放",
["orbitTeach"] = "太阳直射点在南北回归线之间往返,形成四季更替。",
["rotationTeach"] = "晨昏线把地球分成昼半球与夜半球;自转产生昼夜交替与地方时差。",
["dayNight"] = "昼夜交替周期 24 小时",
["lat.equator"] = "赤道",
["lat.tropicN"] = "北回归线 23.5°N",
["lat.tropicS"] = "南回归线 23.5°S",
["lat.polarN"] = "北极圈 66.5°N",
["lat.polarS"] = "南极圈 66.5°S",
["loading"] = "正在准备场景…",
["subsolar"] = "太阳直射点",
["north"] = "北极",
["south"] = "南极",
["northShort"] = "N",
["southShort"] = "S",
["sun"] = "太阳",
["earth"] = "地球",
["spinInfo"] = "自转 {0}° · 周期 {1} 小时",
["orbitInfo"] = "公转 {0}°",
["declinationInfo"] = "太阳直射 {0}",
["dateInfo"] = "日期 {0}",
["season.springEquinox"] = "春分",
["season.summerSolstice"] = "夏至",
["season.autumnEquinox"] = "秋分",
["season.winterSolstice"] = "冬至"
};
public static readonly Dictionary<string, string> En = new()
{
["title"] = "Earth model",
["view.rotation"] = "Rotation",
["view.revolution"] = "Revolution",
["play"] = "Play",
["pause"] = "Pause",
["speed"] = "Speed",
["reset"] = "Reset",
["labels"] = "Labels",
["orbit"] = "Orbit",
["grid"] = "Graticule",
["tilt"] = "Exaggerate tilt",
["lessons"] = "Teaching notes",
["seasons"] = "Solstices & equinoxes",
["close"] = "Close window",
["hint"] = "Pinch or scroll to zoom · drag to turn the Earth",
["shortcutHint"] = "Space play/pause · ←→ step · 1–4 solstices & equinoxes · F fullscreen",
["classroom"] = "Classroom",
["directPoint"] = "Subsolar",
["frozen"] = "Frozen",
["running"] = "Playing",
["step"] = "Step",
["closeup"] = "Earth close-up",
["overhead"] = "Top view",
["sideview"] = "Side view",
["zoom"] = "Zoom",
["orbitTeach"] = "The subsolar point travels between the tropics, producing the seasons.",
["rotationTeach"] = "The terminator splits day and night; rotation drives the day–night cycle and local time.",
["dayNight"] = "Day–night cycle: 24 h",
["lat.equator"] = "Equator",
["lat.tropicN"] = "Tropic of Cancer 23.5°N",
["lat.tropicS"] = "Tropic of Capricorn 23.5°S",
["lat.polarN"] = "Arctic Circle 66.5°N",
["lat.polarS"] = "Antarctic Circle 66.5°S",
["loading"] = "Preparing scene…",
["subsolar"] = "Subsolar point",
["north"] = "North pole",
["south"] = "South pole",
["northShort"] = "N",
["southShort"] = "S",
["sun"] = "Sun",
["earth"] = "Earth",
["spinInfo"] = "Rotation {0}° · period {1} h",
["orbitInfo"] = "Orbit {0}°",
["declinationInfo"] = "Subsolar {0}",
["dateInfo"] = "Date {0}",
["season.springEquinox"] = "Spring equinox",
["season.summerSolstice"] = "Summer solstice",
["season.autumnEquinox"] = "Autumn equinox",
["season.winterSolstice"] = "Winter solstice"
};
}
+76
View File
@@ -0,0 +1,76 @@
using System.Collections.Generic;
namespace NeoRF.EarthModels;
/// <summary>&lt;id&gt;.model/scene.json —— 模型数据(可视化场景描述)。</summary>
public sealed class SceneDefinition
{
public int SchemaVersion { get; set; } = 1;
public string Type { get; set; } = "planet";
/// <summary>rotation | revolution</summary>
public string DefaultView { get; set; } = "rotation";
/// <summary>模型支持的视图;为空表示只有 defaultView。</summary>
public List<string> Views { get; set; } = new();
public Dictionary<string, string>? NameI18n { get; set; }
public Dictionary<string, string>? DescriptionI18n { get; set; }
public StarDefinition Star { get; set; } = new();
public PlanetDefinition Planet { get; set; } = new();
public OrbitDefinition Orbit { get; set; } = new();
public List<Lesson> Lessons { get; set; } = new();
}
public sealed class StarDefinition
{
public string Name { get; set; } = "Sun";
public Dictionary<string, string>? NameI18n { get; set; }
public string Color { get; set; } = "#FFC24B";
/// <summary>相对行星半径的视觉倍率</summary>
public double RadiusScale { get; set; } = 0.5;
}
public sealed class PlanetDefinition
{
public string Name { get; set; } = "Earth";
public Dictionary<string, string>? NameI18n { get; set; }
/// <summary>黄赤交角:教材值 23.5°(23°26′),决定南北回归线纬度。</summary>
public double AxialTiltDeg { get; set; } = 23.5;
/// <summary>回归线纬度,默认与黄赤交角一致;极圈 = 90 − 回归线。</summary>
public double TropicDeg { get; set; } = 23.5;
public double RotationHours { get; set; } = 23.93;
public double OrbitDays { get; set; } = 365.26;
public string OceanColor { get; set; } = "#1B5FA8";
public string LandColor { get; set; } = "#4F8C4C";
public string? IceColor { get; set; } = "#E8EEF4";
public string? LandFile { get; set; } = "land.json";
public bool ShowGraticule { get; set; } = true;
}
public sealed class OrbitDefinition
{
public double SemiMajorAxis { get; set; } = 4.0;
public double Eccentricity { get; set; } = 0.0167;
public bool Show { get; set; } = true;
/// <summary>节气方位声明:springTopSummerLeft = 上春分 / 左夏至(引擎按此布局绘制轨道)。</summary>
public string SeasonLayout { get; set; } = "springTopSummerLeft";
public List<SeasonPoint> Seasons { get; set; } = new();
}
public sealed class SeasonPoint
{
/// <summary>0=春分 90=夏至 180=秋分 270=冬至</summary>
public double AngleDeg { get; set; }
public string Key { get; set; } = "";
public string? Date { get; set; }
/// <summary>该节气的太阳直射纬度:春分/秋分 0,夏至 +23.5,冬至 −23.5。</summary>
public double? DeclinationDeg { get; set; }
/// <summary>课堂现象说明(写在模型数据里,启动器不参与)。</summary>
public Dictionary<string, string>? TeachingI18n { get; set; }
}
public sealed class Lesson
{
public Dictionary<string, string>? TitleI18n { get; set; }
public Dictionary<string, string>? BodyI18n { get; set; }
public string? View { get; set; }
public double? AngleDeg { get; set; }
}
+65
View File
@@ -0,0 +1,65 @@
using System;
using System.IO;
using Avalonia.Media;
namespace NeoRF.EarthModels;
/// <summary>
/// 模型自己的场景运行时:场景描述 + 预烘焙地表纹理 + 调色板。
/// 数据来自模型数据目录,不依赖启动器。
/// </summary>
public sealed class SceneRuntime
{
public SceneDefinition Scene { get; init; } = new();
public PlanetTexture? Texture { get; init; }
public Color Ocean { get; init; } = Color.Parse("#1B5FA8");
public Color Land { get; init; } = Color.Parse("#4F8C4C");
public Color Ice { get; init; } = Color.Parse("#E6EDF4");
public Color Star { get; init; } = Color.Parse("#FFC24B");
public long MemoryBytes => Texture?.ByteSize ?? 0;
public static SceneRuntime Load(string dataDirectory, int memoryBudgetMb,
Action<double, string?>? progress = null)
{
progress?.Invoke(0.06, "读取场景数据");
var scenePath = Path.Combine(dataDirectory, "scene.json");
var scene = ModelJson.Read<SceneDefinition>(scenePath) ?? new SceneDefinition();
var ocean = Parse(scene.Planet.OceanColor, "#1B5FA8");
var land = Parse(scene.Planet.LandColor, "#4F8C4C");
var ice = Parse(scene.Planet.IceColor, "#E6EDF4");
LandData? landData = null;
var landFile = scene.Planet.LandFile;
if (!string.IsNullOrWhiteSpace(landFile))
{
var path = Path.IsPathRooted(landFile!) ? landFile! : Path.Combine(dataDirectory, landFile!);
progress?.Invoke(0.12, "读取地表轮廓");
landData = LandData.Load(path);
}
// 内存预算决定纹理分辨率(1024 宽约 3 MB)
var width = memoryBudgetMb >= 1024 ? PlanetTexture.DefaultWidth
: memoryBudgetMb >= 512 ? 768
: 512;
progress?.Invoke(0.16, "生成地表纹理");
var texture = PlanetTexture.Build(landData, width, ocean, land, ice,
t => progress?.Invoke(0.16 + t * 0.48, "生成地表纹理"));
progress?.Invoke(0.68, "场景就绪");
return new SceneRuntime
{
Scene = scene,
Texture = texture,
Ocean = ocean,
Land = land,
Ice = ice,
Star = Parse(scene.Star.Color, "#FFC24B")
};
}
private static Color Parse(string? value, string fallback)
=> Color.TryParse(string.IsNullOrWhiteSpace(value) ? fallback : value, out var c) ? c : Color.Parse(fallback);
}
+476
View File
@@ -0,0 +1,476 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Avalonia.Media;
namespace NeoRF.EarthModels;
/// <summary>
/// 预烘焙的等经纬度地表贴图:反照率 + 高度 + 冰盖 + 云层 + 夜间灯光。
/// 只在模型加载时算一次,之后每帧只做采样 —— 比逐像素跑噪声快一个数量级,
/// 而且能画出「真实一点」的地表:海洋深度、沙漠/雨林/针叶林带、山脉阴影、极地冰盖。
/// </summary>
public sealed class PlanetTexture
{
public const int DefaultWidth = 1024;
public int Width { get; }
public int Height { get; }
/// <summary>打包的反照率(0xRRGGBB),每像素一次双线性即可拿三通道。</summary>
public uint[] Albedo { get; }
/// <summary>地形高度(0=海平面,255=高山)</summary>
public byte[] Elevation { get; }
/// <summary>云量</summary>
public byte[] Cloud { get; }
/// <summary>夜间灯光</summary>
public byte[] Lights { get; }
/// <summary>预烘焙的地形坡度:东向 / 北向高度梯度(加载时算一次,每帧直接采样)。</summary>
public float[] SlopeEast { get; }
public float[] SlopeNorth { get; }
public long ByteSize => (long)(Albedo.Length * 4 + Elevation.Length + Cloud.Length + Lights.Length
+ SlopeEast.Length * 4 + SlopeNorth.Length * 4);
private PlanetTexture(int width, int height)
{
Width = width;
Height = height;
var count = width * height;
Albedo = new uint[count];
Elevation = new byte[count];
Cloud = new byte[count];
Lights = new byte[count];
SlopeEast = new float[count];
SlopeNorth = new float[count];
}
public static PlanetTexture Build(LandData? landData, int width, Color ocean, Color land, Color ice,
Action<double>? progress = null)
{
width = Math.Clamp(width, 256, 2048);
var height = width / 2;
var texture = new PlanetTexture(width, height);
progress?.Invoke(0.08);
var mask = landData == null ? null : LandMask.Build(landData, width, height);
progress?.Invoke(0.28);
// 到海岸的距离:海里用来做深度,陆地上用来做大陆性(内陆更干)
var landDistance = new float[width * height];
var oceanDistance = new float[width * height];
ComputeDistances(mask, width, height, landDistance, oceanDistance);
progress?.Invoke(0.42);
Parallel.For(0, height, y =>
{
var lat = 90.0 - (y + 0.5) * 180.0 / height;
var latAbs = MathF.Abs((float)lat);
var rowBase = y * width;
for (var x = 0; x < width; x++)
{
var lon = (x + 0.5) * 360.0 / width - 180.0;
var index = rowBase + x;
var isLand = mask == null || mask.Bits[index] > 127;
var elevation = Fbm(lon * 2.1, lat * 2.1, 4, 0x51A3);
var moisture = Fbm(lon * 1.35 + 40, lat * 1.35 - 20, 3, 0x9E2B);
var detail = Fbm(lon * 0.85, lat * 0.85, 3, 0x2C77);
if (isLand)
{
// 内陆更干,靠海更湿
var inland = Math.Clamp(landDistance[index] / (width * 0.06f), 0f, 1f);
var wet = Math.Clamp(moisture * 0.78f + (1f - inland) * 0.16f
- MathF.Max(0f, latAbs - 45f) / 90f, 0f, 1f);
var (r, g, b) = LandPalette(latAbs, wet, inland, elevation, detail, land, ice);
texture.Albedo[index] = Pack(r, g, b);
texture.Elevation[index] = (byte)Math.Clamp(elevation * 235f + detail * 20f, 0, 255);
// 夜间灯光:沿海平原、中低纬,稀疏分布
// 夜间灯光:低频的城市群辉光(高频点会在小尺寸球面上变成噪点)
var cityGlow = Smooth(0.55f, 0.92f, Fbm(lon * 1.7, lat * 1.7, 3, 0x7A31));
if (latAbs < 60 && inland < 0.55f && elevation < 0.75f)
texture.Lights[index] = ToByte(cityGlow * 0.55f);
}
else
{
// 海洋:按离岸距离做深浅
var depth = Math.Clamp(oceanDistance[index] / (width * 0.09f), 0f, 1f);
depth = (float)Math.Pow(depth, 0.65);
var shallowR = Math.Min(1f, ocean.R / 255f + 0.16f);
var shallowG = Math.Min(1f, ocean.G / 255f + 0.22f);
var shallowB = Math.Min(1f, ocean.B / 255f + 0.16f);
var deepR = ocean.R / 255f * 0.32f;
var deepG = ocean.G / 255f * 0.40f;
var deepB = ocean.B / 255f * 0.52f;
var wave = (detail - 0.5f) * 0.035f;
texture.Albedo[index] = Pack(
ToByte(shallowR + (deepR - shallowR) * depth + wave),
ToByte(shallowG + (deepG - shallowG) * depth + wave),
ToByte(shallowB + (deepB - shallowB) * depth + wave));
texture.Elevation[index] = 0;
}
// 极地冰盖:纬度 + 噪声边界,海洋也能结冰
var iceEdge = 62f + (detail - 0.5f) * 9f;
var iceAmt = Smooth(iceEdge - 7f, iceEdge + 6f, latAbs);
if (iceAmt > 0.001f)
{
var iceR = ice.R / 255f;
var iceG = ice.G / 255f;
var iceB = ice.B / 255f;
var packed = texture.Albedo[index];
texture.Albedo[index] = Pack(
ToByte(Lerp(((packed >> 16) & 0xFF) / 255f, iceR, iceAmt)),
ToByte(Lerp(((packed >> 8) & 0xFF) / 255f, iceG, iceAmt)),
ToByte(Lerp((packed & 0xFF) / 255f, iceB, iceAmt)));
}
// 云:多个尺度的 fbm,赤道与中纬多云
var cloudBase = Fbm(lon * 0.55, lat * 0.7, 3, 0x1144);
var band = 0.5f + 0.5f * MathF.Cos(latAbs / 90f * MathF.PI * 3.1f);
var cloud = Smooth(0.48f, 0.84f, cloudBase * 0.86f + band * 0.14f);
texture.Cloud[index] = ToByte(cloud * 0.72f);
}
});
// 云层做一次模糊,避免小尺寸球面上采样出噪点
Blur(texture.Cloud, width, height, 2);
// 预烘焙地形坡度:渲染时不必每像素再取 4 次高度
BakeSlopes(texture, width, height);
progress?.Invoke(0.62);
return texture;
}
private static (byte R, byte G, byte B) LandPalette(float latAbs, float wet, float inland, float elevation,
float detail, Color landBase, Color ice)
{
// 基色随纬度:赤道雨林 -> 温带 -> 针叶林 -> 苔原
float r, g, b;
var tropical = (1f - Smooth(8f, 24f, latAbs));
var temperate = Smooth(20f, 34f, latAbs) * (1f - Smooth(46f, 60f, latAbs));
var boreal = Smooth(46f, 60f, latAbs) * (1f - Smooth(62f, 70f, latAbs));
var tundra = Smooth(60f, 72f, latAbs);
r = 0.13f; g = 0.36f; b = 0.17f; // 温带草原绿
r = Lerp(r, 0.10f, tropical); g = Lerp(g, 0.42f, tropical); b = Lerp(b, 0.19f, tropical);
r = Lerp(r, 0.17f, boreal); g = Lerp(g, 0.28f, boreal); b = Lerp(b, 0.17f, boreal);
r = Lerp(r, 0.34f, tundra); g = Lerp(g, 0.36f, tundra); b = Lerp(b, 0.31f, tundra);
// 湿润度:干 -> 沙漠/草原
var dry = Math.Clamp(1f - wet * 0.95f, 0f, 1f);
var desertBand = Math.Clamp(1f - MathF.Abs(latAbs - 24f) / 13f, 0f, 1f);
var desert = Math.Clamp(dry * 0.72f + desertBand * 0.62f, 0f, 1f);
r = Lerp(r, 0.72f, desert * 0.85f);
g = Lerp(g, 0.60f, desert * 0.85f);
b = Lerp(b, 0.38f, desert * 0.85f);
// 高原/山地:岩石和雪
var rock = Smooth(0.62f, 0.86f, elevation);
r = Lerp(r, 0.44f, rock * 0.7f);
g = Lerp(g, 0.40f, rock * 0.7f);
b = Lerp(b, 0.34f, rock * 0.7f);
var snow = Smooth(0.86f, 0.97f, elevation + (latAbs - 40f) / 220f);
r = Lerp(r, ice.R / 255f, snow);
g = Lerp(g, ice.G / 255f, snow);
b = Lerp(b, ice.B / 255f, snow);
// 细节扰动,避免大面积纯色
var grain = (detail - 0.5f) * 0.07f;
var baseMix = 0.25f;
return (
ToByte(Math.Clamp(r + grain + (landBase.R / 255f - 0.3f) * baseMix * 0.2f, 0f, 1f)),
ToByte(Math.Clamp(g + grain + (landBase.G / 255f - 0.45f) * baseMix * 0.2f, 0f, 1f)),
ToByte(Math.Clamp(b + grain + (landBase.B / 255f - 0.3f) * baseMix * 0.2f, 0f, 1f)));
}
/// <summary>可分离盒式模糊(原地),用于软化云层。</summary>
private static void Blur(byte[] data, int width, int height, int radius)
{
var temp = new byte[data.Length];
for (var y = 0; y < height; y++)
{
var row = y * width;
for (var x = 0; x < width; x++)
{
var sum = 0;
var count = 0;
for (var k = -radius; k <= radius; k++)
{
var sx = (x + k + width) % width;
sum += data[row + sx];
count++;
}
temp[row + x] = (byte)(sum / count);
}
}
for (var x = 0; x < width; x++)
{
for (var y = 0; y < height; y++)
{
var sum = 0;
var count = 0;
for (var k = -radius; k <= radius; k++)
{
var sy = Math.Clamp(y + k, 0, height - 1);
sum += temp[sy * width + x];
count++;
}
data[y * width + x] = (byte)(sum / count);
}
}
}
/// <summary>由高度图算东西/南北梯度,供球面光照直接使用。</summary>
private static void BakeSlopes(PlanetTexture t, int width, int height)
{
const float relief = 0.055f * 90f;
for (var y = 0; y < height; y++)
{
var row = y * width;
var up = Math.Max(0, y - 1) * width;
var down = Math.Min(height - 1, y + 1) * width;
for (var x = 0; x < width; x++)
{
var left = (x - 1 + width) % width;
var right = (x + 1) % width;
t.SlopeEast[row + x] = (t.Elevation[row + right] - t.Elevation[row + left]) / 255f * relief;
t.SlopeNorth[row + x] = (t.Elevation[up + x] - t.Elevation[down + x]) / 255f * relief;
}
}
}
// ---------------------------------------------------------------- 距离场
private static void ComputeDistances(LandMask? mask, int width, int height, float[] landDistance, float[] oceanDistance)
{
var count = width * height;
const float big = 1e6f;
for (var i = 0; i < count; i++)
{
var isLand = mask != null && mask.Bits[i] > 127;
landDistance[i] = isLand ? big : -big;
oceanDistance[i] = isLand ? -big : big;
}
// 两遍 chamfer:陆地到海洋的距离 / 海洋到陆地的距离
for (var y = 0; y < height; y++)
{
for (var x = 0; x < width; x++)
{
var i = y * width + x;
if (mask != null && mask.Bits[i] > 127)
{
var best = big;
if (x > 0 && mask.Bits[i - 1] <= 127) best = 0.5f;
if (x < width - 1 && mask.Bits[i + 1] <= 127) best = Math.Min(best, 0.5f);
if (y > 0 && mask.Bits[i - width] <= 127) best = Math.Min(best, 0.5f);
if (y < height - 1 && mask.Bits[i + width] <= 127) best = Math.Min(best, 0.5f);
if (best < big) landDistance[i] = best;
}
if (mask != null && mask.Bits[i] <= 127)
{
var best = big;
if (x > 0 && mask.Bits[i - 1] > 127) best = 0.5f;
if (x < width - 1 && mask.Bits[i + 1] > 127) best = Math.Min(best, 0.5f);
if (y > 0 && mask.Bits[i - width] > 127) best = Math.Min(best, 0.5f);
if (y < height - 1 && mask.Bits[i + width] > 127) best = Math.Min(best, 0.5f);
if (best < big) oceanDistance[i] = best;
}
}
}
// 正向传递
for (var y = 0; y < height; y++)
{
for (var x = 0; x < width; x++)
{
var i = y * width + x;
Propagate(landDistance, i, width, height, x, y, -1, 0, 1.4142f);
Propagate(oceanDistance, i, width, height, x, y, -1, 0, 1.4142f);
if (x > 0)
{
landDistance[i] = Math.Min(landDistance[i], landDistance[i - 1] + 1f);
oceanDistance[i] = Math.Min(oceanDistance[i], oceanDistance[i - 1] + 1f);
}
if (y > 0)
{
landDistance[i] = Math.Min(landDistance[i], landDistance[i - width] + 1f);
oceanDistance[i] = Math.Min(oceanDistance[i], oceanDistance[i - width] + 1f);
if (x > 0)
{
landDistance[i] = Math.Min(landDistance[i], landDistance[i - width - 1] + 1.4142f);
oceanDistance[i] = Math.Min(oceanDistance[i], oceanDistance[i - width - 1] + 1.4142f);
}
if (x < width - 1)
{
landDistance[i] = Math.Min(landDistance[i], landDistance[i - width + 1] + 1.4142f);
oceanDistance[i] = Math.Min(oceanDistance[i], oceanDistance[i - width + 1] + 1.4142f);
}
}
}
}
// 反向传递
for (var y = height - 1; y >= 0; y--)
{
for (var x = width - 1; x >= 0; x--)
{
var i = y * width + x;
if (x < width - 1)
{
landDistance[i] = Math.Min(landDistance[i], landDistance[i + 1] + 1f);
oceanDistance[i] = Math.Min(oceanDistance[i], oceanDistance[i + 1] + 1f);
}
if (y < height - 1)
{
landDistance[i] = Math.Min(landDistance[i], landDistance[i + width] + 1f);
oceanDistance[i] = Math.Min(oceanDistance[i], oceanDistance[i + width] + 1f);
if (x < width - 1)
{
landDistance[i] = Math.Min(landDistance[i], landDistance[i + width + 1] + 1.4142f);
oceanDistance[i] = Math.Min(oceanDistance[i], oceanDistance[i + width + 1] + 1.4142f);
}
if (x > 0)
{
landDistance[i] = Math.Min(landDistance[i], landDistance[i + width - 1] + 1.4142f);
oceanDistance[i] = Math.Min(oceanDistance[i], oceanDistance[i + width - 1] + 1.4142f);
}
}
}
}
for (var i = 0; i < count; i++)
{
landDistance[i] = MathF.Max(0f, landDistance[i]);
oceanDistance[i] = MathF.Max(0f, oceanDistance[i]);
}
}
private static void Propagate(float[] map, int index, int width, int height, int x, int y, int dx, int dy, float w)
{
var nx = x + dx;
var ny = y + dy;
if (nx < 0 || nx >= width || ny < 0 || ny >= height) return;
var other = ny * width + nx;
map[index] = Math.Min(map[index], map[other] + w);
}
// ---------------------------------------------------------------- 噪声
/// <summary>值噪声 + 分形叠加(确定性,跨平台一致)。</summary>
public static float Fbm(double x, double y, int octaves, int seed)
{
var amplitude = 1.0;
var frequency = 1.0;
var sum = 0.0;
var norm = 0.0;
for (var i = 0; i < octaves; i++)
{
sum += amplitude * ValueNoise(x * frequency, y * frequency, seed + i * 101);
norm += amplitude;
amplitude *= 0.5;
frequency *= 2.07;
}
return (float)(sum / norm);
}
private static double ValueNoise(double x, double y, int seed)
{
var xi = (int)Math.Floor(x);
var yi = (int)Math.Floor(y);
var xf = x - xi;
var yf = y - yi;
var u = xf * xf * (3 - 2 * xf);
var v = yf * yf * (3 - 2 * yf);
var a = Hash(xi, yi, seed);
var b = Hash(xi + 1, yi, seed);
var c = Hash(xi, yi + 1, seed);
var d = Hash(xi + 1, yi + 1, seed);
return (a + (b - a) * u) * (1 - v) + (c + (d - c) * u) * v;
}
private static double Hash(int x, int y, int seed)
{
var h = (uint)(x * 374761393 + y * 668265263 + seed * 1442695041);
h = (h ^ (h >> 13)) * 1274126177u;
h ^= h >> 16;
return (h & 0xFFFFFF) / (double)0xFFFFFF;
}
// ---------------------------------------------------------------- 采样
public void Sample(double lon, double lat, out float r, out float g, out float b,
out float elevation, out float cloud, out float lights,
out float slopeEast, out float slopeNorth)
{
var u = (lon + 180.0) / 360.0 * Width - 0.5;
var v = (90.0 - lat) / 180.0 * Height - 0.5;
var x0 = (int)Math.Floor(u);
var y0 = (int)Math.Floor(v);
var fx = (float)(u - x0);
var fy = (float)(v - y0);
var x1 = x0 + 1;
var y1 = y0 + 1;
if (x0 < 0) x0 += Width; if (x1 < 0) x1 += Width;
if (x0 >= Width) x0 -= Width; if (x1 >= Width) x1 -= Width;
y0 = Math.Clamp(y0, 0, Height - 1);
y1 = Math.Clamp(y1, 0, Height - 1);
var i00 = y0 * Width + x0;
var i10 = y0 * Width + x1;
var i01 = y1 * Width + x0;
var i11 = y1 * Width + x1;
float w00 = (1 - fx) * (1 - fy), w10 = fx * (1 - fy), w01 = (1 - fx) * fy, w11 = fx * fy;
var p00 = Albedo[i00];
var p10 = Albedo[i10];
var p01 = Albedo[i01];
var p11 = Albedo[i11];
var rr = ((p00 >> 16) & 0xFF) * w00 + ((p10 >> 16) & 0xFF) * w10 + ((p01 >> 16) & 0xFF) * w01 + ((p11 >> 16) & 0xFF) * w11;
var gg = ((p00 >> 8) & 0xFF) * w00 + ((p10 >> 8) & 0xFF) * w10 + ((p01 >> 8) & 0xFF) * w01 + ((p11 >> 8) & 0xFF) * w11;
var bb = (p00 & 0xFF) * w00 + (p10 & 0xFF) * w10 + (p01 & 0xFF) * w01 + (p11 & 0xFF) * w11;
r = rr / 255f;
g = gg / 255f;
b = bb / 255f;
elevation = (Elevation[i00] * w00 + Elevation[i10] * w10 + Elevation[i01] * w01 + Elevation[i11] * w11) / 255f;
cloud = (Cloud[i00] * w00 + Cloud[i10] * w10 + Cloud[i01] * w01 + Cloud[i11] * w11) / 255f;
lights = Lights[i00] / 255f;
slopeEast = SlopeEast[i00] * w00 + SlopeEast[i10] * w10 + SlopeEast[i01] * w01 + SlopeEast[i11] * w11;
slopeNorth = SlopeNorth[i00] * w00 + SlopeNorth[i10] * w10 + SlopeNorth[i01] * w01 + SlopeNorth[i11] * w11;
}
/// <summary>只采样高度(法线扰动用)。</summary>
public float SampleHeight(double lon, double lat)
{
var u = (lon + 180.0) / 360.0 * Width - 0.5;
var v = (90.0 - lat) / 180.0 * Height - 0.5;
var x = Math.Clamp((int)Math.Round(u), 0, Width - 1);
var y = Math.Clamp((int)Math.Round(v), 0, Height - 1);
return Elevation[y * Width + x] / 255f;
}
public float SampleCloud(double lon, double lat)
{
var u = (lon + 180.0) / 360.0 * Width - 0.5;
var v = (90.0 - lat) / 180.0 * Height - 0.5;
var x = Math.Clamp((int)Math.Round(u), 0, Width - 1);
var y = Math.Clamp((int)Math.Round(v), 0, Height - 1);
return Cloud[y * Width + x] / 255f;
}
public static byte ToByte(float v) => (byte)Math.Clamp((int)(v * 255f + 0.5f), 0, 255);
private static uint Pack(byte r, byte g, byte b) => ((uint)r << 16) | ((uint)g << 8) | b;
private static float Lerp(float a, float b, float t) => a + (b - a) * Math.Clamp(t, 0f, 1f);
private static float Smooth(float edge0, float edge1, float x)
{
if (edge1 <= edge0) return x >= edge1 ? 1f : 0f;
var t = Math.Clamp((x - edge0) / (edge1 - edge0), 0f, 1f);
return t * t * (3f - 2f * t);
}
}
+172
View File
@@ -0,0 +1,172 @@
using System;
using System.Numerics;
using System.Threading.Tasks;
using Avalonia.Media.Imaging;
namespace NeoRF.EarthModels;
/// <summary>
/// 球体像素级渲染:正交投影 + 预烘焙地表纹理 + 地形光照 + 云层 + 夜灯 + 大气边缘光。
/// 纯 CPU 光栅、按行并行,不依赖 GPU,三平台效果一致。
/// </summary>
public static unsafe class SphereRaster
{
/// <summary>把球体画进 WriteableBitmap(整张位图会被覆盖)。</summary>
public static void Draw(WriteableBitmap bitmap, int size, Matrix4x4 cam, Matrix4x4 planet,
Vector3 light, PlanetTexture texture, double cloudShift, bool showClouds)
{
using var framebuffer = bitmap.Lock();
var stride = framebuffer.RowBytes / 4;
Render((uint*)framebuffer.Address, stride, size, cam, planet, light, texture, cloudShift, showClouds);
}
public static void Render(uint* dst, int stride, int size, Matrix4x4 cam, Matrix4x4 planet,
Vector3 light, PlanetTexture texture, double cloudShift, bool showClouds)
{
var radius = size * 0.5f - 1.0f;
var center = size * 0.5f;
var inv = 1f / radius;
// 相机空间法线 -> 行星本地法线
var combined = Matrix4x4.Multiply(planet, cam);
var mt = Matrix4x4.Transpose(combined);
float m11 = mt.M11, m12 = mt.M12, m13 = mt.M13;
float m21 = mt.M21, m22 = mt.M22, m23 = mt.M23;
float m31 = mt.M31, m32 = mt.M32, m33 = mt.M33;
var lx = light.X; var ly = light.Y; var lz = light.Z;
Parallel.For(0, size, y =>
{
var ny = (center - y - 0.5f) * inv;
var row = dst + (long)y * stride;
for (var x = 0; x < size; x++)
{
var nx = (x + 0.5f - center) * inv;
var r2 = nx * nx + ny * ny;
if (r2 >= 1f)
{
row[x] = 0;
continue;
}
var nz = MathF.Sqrt(1f - r2);
// 本地法线(用于取经纬度)
var ux = nx * m11 + ny * m21 + nz * m31;
var uy = nx * m12 + ny * m22 + nz * m32;
var uz = nx * m13 + ny * m23 + nz * m33;
var lat = MathF.Asin(Math.Clamp(uy, -1f, 1f)) * 57.2957795f;
var lon = MathF.Atan2(ux, uz) * 57.2957795f;
var cloudLon = lon + cloudShift;
if (cloudLon > 180) cloudLon -= 360;
if (cloudLon < -180) cloudLon += 360;
texture.Sample(lon, lat, out var ar, out var ag, out var ab,
out var elevation, out var cloud, out var lights,
out var dEast, out var dNorth);
// ---- 地形法线:局部基向量可由球面法线直接推出,不必再算 6 次三角函数
// 点 P=(cosLat·sinLon, sinLat, cosLat·cosLon) = (ux,uy,uz)
// 东向 = (cosLon,0,-sinLon),北向 = (-sinLat·sinLon, cosLat, -sinLat·cosLon)
var cosLat = MathF.Sqrt(MathF.Max(ux * ux + uz * uz, 1e-6f));
var invCos = 1f / cosLat;
var eastX = uz * invCos;
var eastZ = -ux * invCos;
var northX = -uy * ux * invCos;
var northY = cosLat;
var northZ = -uy * uz * invCos;
var nLocalX = ux + eastX * dEast + northX * dNorth;
var nLocalY = uy + northY * dNorth;
var nLocalZ = uz + eastZ * dEast + northZ * dNorth;
var nLen = MathF.Sqrt(nLocalX * nLocalX + nLocalY * nLocalY + nLocalZ * nLocalZ);
if (nLen > 0.0001f) { nLocalX /= nLen; nLocalY /= nLen; nLocalZ /= nLen; }
var nCamX = nLocalX * combined.M11 + nLocalY * combined.M21 + nLocalZ * combined.M31;
var nCamY = nLocalX * combined.M12 + nLocalY * combined.M22 + nLocalZ * combined.M32;
var nCamZ = nLocalX * combined.M13 + nLocalY * combined.M23 + nLocalZ * combined.M33;
var lam = nx * lx + ny * ly + nz * lz; // 几何光照(晨昏线)
var bump = nCamX * lx + nCamY * ly + nCamZ * lz; // 地形光照
var day = Smooth(-0.18f, 0.22f, lam);
var terrainLight = 0.82f + 0.42f * MathF.Max(0f, bump - lam);
var shade = (0.055f + 0.945f * day) * terrainLight;
var br = ar * shade;
var bg = ag * shade;
var bb = ab * shade;
// 海面高光(高度为 0 视为水面)
if (elevation < 0.02f)
{
var t2 = MathF.Max(0f, lam);
var t4 = t2 * t2 * t2 * t2;
var t8 = t4 * t4;
var t16 = t8 * t8;
var spec = t16 * t8 * t4 * t2 * t2 * 0.62f;
br += spec * 0.95f;
bg += spec * 0.98f;
bb += spec;
}
// 云层(随经度缓慢漂移)
if (showClouds && cloud > 0.02f)
{
var cloudLight = 0.10f + 0.90f * day;
var c = Math.Clamp(cloud * 0.92f, 0f, 1f);
var cloudR = 0.98f * cloudLight;
var cloudG = 0.985f * cloudLight;
var cloudB = 1.0f * cloudLight;
br += (cloudR - br) * c;
bg += (cloudG - bg) * c;
bb += (cloudB - bb) * c;
}
// 夜间灯光
if (lights > 0.01f)
{
var night = 1f - day;
var glow = lights * night * 0.35f;
br += glow * 0.95f;
bg += glow * 0.72f;
bb += glow * 0.38f;
}
// 大气边缘散射
var rim = 1f - nz;
rim *= rim;
var litRim = rim * MathF.Max(0f, lam) * 0.98f;
br += 0.30f * litRim;
bg += 0.55f * litRim;
bb += 1.00f * litRim;
// 夜面极淡反照
var nightSide = 1f - day;
br += 0.008f * nightSide;
bg += 0.013f * nightSide;
bb += 0.028f * nightSide;
var coverage = 1f;
var edge = (1f - MathF.Sqrt(r2)) * radius;
if (edge < 1f) coverage = MathF.Max(0f, edge);
var a = (uint)(coverage * 255f);
var r8 = (uint)(Math.Clamp(br, 0f, 1f) * 255f * coverage);
var g8 = (uint)(Math.Clamp(bg, 0f, 1f) * 255f * coverage);
var b8 = (uint)(Math.Clamp(bb, 0f, 1f) * 255f * coverage);
row[x] = (a << 24) | (r8 << 16) | (g8 << 8) | b8;
}
});
}
private static float Smooth(float edge0, float edge1, float x)
{
if (edge1 <= edge0) return x >= edge1 ? 1f : 0f;
var t = Math.Clamp((x - edge0) / (edge1 - edge0), 0f, 1f);
return t * t * (3f - 2f * t);
}
}
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<RootNamespace>EarthModelStudio.ModelSdk</RootNamespace>
<AssemblyName>EarthModelStudio.ModelSdk</AssemblyName>
<IsPackable>false</IsPackable>
<Description>Earth Model 模型契约:启动器与模型之间唯一的编译期依赖。</Description>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
</ItemGroup>
</Project>
@@ -0,0 +1,68 @@
using System;
using Avalonia.Controls;
namespace EarthModelStudio.ModelSdk;
/// <summary>
/// 模型入口契约。模型程序集里必须有一个公开、无参构造的 <see cref="IModelFactory"/> 实现,
/// 启动器按模型清单里的 <c>assembly</c> + <c>type</c> 定位并创建它。
/// </summary>
public interface IModelFactory
{
/// <summary>契约版本。启动器目前支持 1。</summary>
int ApiVersion { get; }
/// <summary>创建一个模型运行时实例(每个窗口一个实例)。</summary>
IModelRuntime Create();
}
/// <summary>
/// 模型运行时:负责把模型自己的界面交给启动器。
/// 启动器只负责开窗口,**不参与任何渲染**。
/// </summary>
public interface IModelRuntime : IDisposable
{
/// <summary>
/// 在**后台线程**准备数据(读文件、算纹理等),期间禁止创建或操作任何 UI 控件。
/// 启动器的进度窗会显示 <see cref="IModelContext.ReportProgress"/> 汇报的进度。
/// 默认空实现:模型也可以把准备工作留到 CreateView 里(那样会占用 UI 线程)。
/// </summary>
void Prepare(IModelContext context) { }
/// <summary>
/// 在 UI 线程创建模型窗口的内容。模型可以自由组合控件、自己画图、自己管动画。
/// 返回的控件会被直接放进窗口,铺满客户区。
/// </summary>
Control CreateView(IModelContext context);
}
/// <summary>启动器提供给模型的环境信息与能力。</summary>
public interface IModelContext
{
/// <summary>模型 id(即模型目录名)。</summary>
string ModelId { get; }
/// <summary>模型目录:<c>model/&lt;id&gt;</c>。</summary>
string ModelDirectory { get; }
/// <summary>模型数据目录:<c>model/&lt;id&gt;/&lt;id&gt;.model</c>,模型自己的场景数据、贴图、语言包都放这里。</summary>
string DataDirectory { get; }
/// <summary>界面语言(zh-CN / en)。模型应按它选择自己的文案。</summary>
string Language { get; }
/// <summary>用户在设置里分配的运行内存预算(MB),模型可据此控制缓存规模。</summary>
int MemoryBudgetMb { get; }
/// <summary>请求关闭承载此模型的窗口。</summary>
void RequestClose();
/// <summary>
/// 汇报加载进度(0–1)与当前阶段文案。启动器的加载进度条会实时显示,
/// 也可以在任何时候调用(例如切换数据集时)。
/// </summary>
void ReportProgress(double value, string? message = null);
/// <summary>输出日志(启动器会写到控制台)。</summary>
void Log(string message);
}
@@ -0,0 +1,115 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"EarthModelStudio.ModelSdk/1.0.3": {
"dependencies": {
"Avalonia": "11.3.9"
},
"runtime": {
"EarthModelStudio.ModelSdk.dll": {}
}
},
"Avalonia/11.3.9": {
"dependencies": {
"Avalonia.Remote.Protocol": "11.3.9",
"MicroCom.Runtime": "0.11.0"
},
"runtime": {
"lib/net8.0/Avalonia.Base.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.Controls.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.DesignerSupport.dll": {
"assemblyVersion": "0.7.0.0",
"fileVersion": "0.7.0.0"
},
"lib/net8.0/Avalonia.Dialogs.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.Markup.Xaml.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.Markup.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.Metal.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.MicroCom.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.OpenGL.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.Vulkan.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
}
}
},
"Avalonia.Remote.Protocol/11.3.9": {
"runtime": {
"lib/net8.0/Avalonia.Remote.Protocol.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
}
}
},
"MicroCom.Runtime/0.11.0": {
"runtime": {
"lib/net5.0/MicroCom.Runtime.dll": {
"assemblyVersion": "0.11.0.0",
"fileVersion": "0.11.0.0"
}
}
}
}
},
"libraries": {
"EarthModelStudio.ModelSdk/1.0.3": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Avalonia/11.3.9": {
"type": "package",
"serviceable": true,
"sha512": "sha512-YfaTrUxcmVTsGOw2YqdZyunHqZArK16m1pYfNIBvyvAgX89Pzd3A1PgoMkf64u7scL23IN6HkfqhZeFcbYWLoA==",
"path": "avalonia/11.3.9",
"hashPath": "avalonia.11.3.9.nupkg.sha512"
},
"Avalonia.Remote.Protocol/11.3.9": {
"type": "package",
"serviceable": true,
"sha512": "sha512-2XVLTSNa+Nvwu4D8NqqdudhllTaCRA9ZKlLZZvYLZeuLlzg7OcAV+df/biHQc6AqOv7iMFR9K5Zt3wG0EF4KfQ==",
"path": "avalonia.remote.protocol/11.3.9",
"hashPath": "avalonia.remote.protocol.11.3.9.nupkg.sha512"
},
"MicroCom.Runtime/0.11.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-MEnrZ3UIiH40hjzMDsxrTyi8dtqB5ziv3iBeeU4bXsL/7NLSal9F1lZKpK+tfBRnUoDSdtcW3KufE4yhATOMCA==",
"path": "microcom.runtime/0.11.0",
"hashPath": "microcom.runtime.0.11.0.nupkg.sha512"
}
}
}
@@ -0,0 +1,115 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"EarthModelStudio.ModelSdk/1.0.3": {
"dependencies": {
"Avalonia": "11.3.9"
},
"runtime": {
"EarthModelStudio.ModelSdk.dll": {}
}
},
"Avalonia/11.3.9": {
"dependencies": {
"Avalonia.Remote.Protocol": "11.3.9",
"MicroCom.Runtime": "0.11.0"
},
"runtime": {
"lib/net8.0/Avalonia.Base.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.Controls.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.DesignerSupport.dll": {
"assemblyVersion": "0.7.0.0",
"fileVersion": "0.7.0.0"
},
"lib/net8.0/Avalonia.Dialogs.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.Markup.Xaml.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.Markup.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.Metal.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.MicroCom.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.OpenGL.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.Vulkan.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
},
"lib/net8.0/Avalonia.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
}
}
},
"Avalonia.Remote.Protocol/11.3.9": {
"runtime": {
"lib/net8.0/Avalonia.Remote.Protocol.dll": {
"assemblyVersion": "11.3.9.0",
"fileVersion": "11.3.9.0"
}
}
},
"MicroCom.Runtime/0.11.0": {
"runtime": {
"lib/net5.0/MicroCom.Runtime.dll": {
"assemblyVersion": "0.11.0.0",
"fileVersion": "0.11.0.0"
}
}
}
}
},
"libraries": {
"EarthModelStudio.ModelSdk/1.0.3": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Avalonia/11.3.9": {
"type": "package",
"serviceable": true,
"sha512": "sha512-YfaTrUxcmVTsGOw2YqdZyunHqZArK16m1pYfNIBvyvAgX89Pzd3A1PgoMkf64u7scL23IN6HkfqhZeFcbYWLoA==",
"path": "avalonia/11.3.9",
"hashPath": "avalonia.11.3.9.nupkg.sha512"
},
"Avalonia.Remote.Protocol/11.3.9": {
"type": "package",
"serviceable": true,
"sha512": "sha512-2XVLTSNa+Nvwu4D8NqqdudhllTaCRA9ZKlLZZvYLZeuLlzg7OcAV+df/biHQc6AqOv7iMFR9K5Zt3wG0EF4KfQ==",
"path": "avalonia.remote.protocol/11.3.9",
"hashPath": "avalonia.remote.protocol.11.3.9.nupkg.sha512"
},
"MicroCom.Runtime/0.11.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-MEnrZ3UIiH40hjzMDsxrTyi8dtqB5ziv3iBeeU4bXsL/7NLSal9F1lZKpK+tfBRnUoDSdtcW3KufE4yhATOMCA==",
"path": "microcom.runtime/0.11.0",
"hashPath": "microcom.runtime.0.11.0.nupkg.sha512"
}
}
}
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
@@ -0,0 +1 @@
19347f0fd9099e96da933911861c08405b49d004b7b88b97423c17bee0eb100f
@@ -0,0 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("NeoRF")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("Earth Model 模型契约:启动器与模型之间唯一的编译期依赖。")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.3.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.3")]
[assembly: System.Reflection.AssemblyProductAttribute("Earth Model Studio")]
[assembly: System.Reflection.AssemblyTitleAttribute("EarthModelStudio.ModelSdk")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.3.0")]
[assembly: System.Resources.NeutralResourcesLanguageAttribute("zh-Hans")]
// Generated by the MSBuild WriteCodeFragment class.
@@ -0,0 +1 @@
b335d297927ccf5a0daf4e3ae36efd34dab2da4d5a059ac53a2e5ec720bc9741
@@ -0,0 +1,25 @@
is_global = true
build_property.AvaloniaNameGeneratorIsEnabled = true
build_property.AvaloniaNameGeneratorBehavior = InitializeComponent
build_property.AvaloniaNameGeneratorDefaultFieldModifier = internal
build_property.AvaloniaNameGeneratorFilterByPath = *
build_property.AvaloniaNameGeneratorFilterByNamespace = *
build_property.AvaloniaNameGeneratorViewFileNamingStrategy = NamespaceAndClassName
build_property.AvaloniaNameGeneratorAttachDevTools = true
build_property.TargetFramework = net8.0
build_property.TargetFrameworkIdentifier = .NETCoreApp
build_property.TargetFrameworkVersion = v8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property.EntryPointFilePath =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = EarthModelStudio.ModelSdk
build_property.ProjectDir = /Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 8.0
build_property.EnableCodeStyleSeverity =
@@ -0,0 +1 @@
700a4b41f184bc7a11bf82dedb3429528bb388b5fb0ec5c68baea6f472087bef
@@ -0,0 +1,13 @@
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/bin/Debug/net8.0/EarthModelStudio.ModelSdk.deps.json
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/bin/Debug/net8.0/EarthModelStudio.ModelSdk.dll
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/bin/Debug/net8.0/EarthModelStudio.ModelSdk.pdb
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/obj/Debug/net8.0/EarthModelStudio.ModelSdk.csproj.AssemblyReference.cache
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/obj/Debug/net8.0/EarthModelStudio.ModelSdk.GeneratedMSBuildEditorConfig.editorconfig
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/obj/Debug/net8.0/EarthModelStudio.ModelSdk.AssemblyInfoInputs.cache
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/obj/Debug/net8.0/EarthModelStudio.ModelSdk.AssemblyInfo.cs
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/obj/Debug/net8.0/EarthModelStudio.ModelSdk.csproj.CoreCompileInputs.cache
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/obj/Debug/net8.0/EarthModelStudio.ModelSdk.dll
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/obj/Debug/net8.0/refint/EarthModelStudio.ModelSdk.dll
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/obj/Debug/net8.0/EarthModelStudio.ModelSdk.pdb
/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/obj/Debug/net8.0/ref/EarthModelStudio.ModelSdk.dll
@@ -0,0 +1,96 @@
{
"format": 1,
"restore": {
"/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/EarthModelStudio.ModelSdk.csproj": {}
},
"projects": {
"/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/EarthModelStudio.ModelSdk.csproj": {
"version": "1.0.3",
"restore": {
"projectUniqueName": "/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/EarthModelStudio.ModelSdk.csproj",
"projectName": "EarthModelStudio.ModelSdk",
"projectPath": "/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/EarthModelStudio.ModelSdk.csproj",
"packagesPath": "/Users/morris/.nuget/packages/",
"outputPath": "/Users/morris/Downloads/GC#/model/_sdk/EarthModelStudio.ModelSdk/obj/",
"projectStyle": "PackageReference",
"configFilePaths": [
"/Users/morris/.nuget/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"framework": "net8.0",
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "10.0.400"
},
"frameworks": {
"net8.0": {
"framework": "net8.0",
"targetAlias": "net8.0",
"dependencies": {
"Avalonia": {
"target": "Package",
"version": "[11.3.9, )"
},
"Microsoft.NET.ILLink.Tasks": {
"suppressParent": "All",
"target": "Package",
"version": "[8.0.31, )",
"autoReferenced": true
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Runtime.win-arm64",
"version": "[8.0.31, 8.0.31]"
},
{
"name": "Microsoft.NETCore.App.Runtime.win-arm64",
"version": "[8.0.31, 8.0.31]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/10.0.401/PortableRuntimeIdentifierGraph.json"
}
},
"runtimes": {
"win-arm64": {
"#import": []
}
}
}
}
}
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/morris/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/morris/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">7.0.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="/Users/morris/.nuget/packages/" />
</ItemGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)microsoft.net.illink.tasks/8.0.31/build/Microsoft.NET.ILLink.Tasks.props" Condition="Exists('$(NuGetPackageRoot)microsoft.net.illink.tasks/8.0.31/build/Microsoft.NET.ILLink.Tasks.props')" />
<Import Project="$(NuGetPackageRoot)avalonia/11.3.9/buildTransitive/Avalonia.props" Condition="Exists('$(NuGetPackageRoot)avalonia/11.3.9/buildTransitive/Avalonia.props')" />
</ImportGroup>
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<PkgMicrosoft_NET_ILLink_Tasks Condition=" '$(PkgMicrosoft_NET_ILLink_Tasks)' == '' ">/Users/morris/.nuget/packages/microsoft.net.illink.tasks/8.0.31</PkgMicrosoft_NET_ILLink_Tasks>
<PkgAvalonia_BuildServices Condition=" '$(PkgAvalonia_BuildServices)' == '' ">/Users/morris/.nuget/packages/avalonia.buildservices/11.3.2</PkgAvalonia_BuildServices>
<PkgAvalonia Condition=" '$(PkgAvalonia)' == '' ">/Users/morris/.nuget/packages/avalonia/11.3.9</PkgAvalonia>
</PropertyGroup>
</Project>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)avalonia.buildservices/11.3.2/buildTransitive/Avalonia.BuildServices.targets" Condition="Exists('$(NuGetPackageRoot)avalonia.buildservices/11.3.2/buildTransitive/Avalonia.BuildServices.targets')" />
<Import Project="$(NuGetPackageRoot)avalonia/11.3.9/buildTransitive/Avalonia.targets" Condition="Exists('$(NuGetPackageRoot)avalonia/11.3.9/buildTransitive/Avalonia.targets')" />
</ImportGroup>
</Project>
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
@@ -0,0 +1 @@
19347f0fd9099e96da933911861c08405b49d004b7b88b97423c17bee0eb100f
Loaded 100 of 1125 files, more files were not shown because too many files have changed in this diff. Show more