@rr0/ufoathome 0.186.0 → 0.187.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist-embed-scene/{AdsbLolArchiveProvider-CzTJVwX_.js → AdsbLolArchiveProvider-DdUpO-EA.js} +1 -1
  2. package/dist-embed-scene/{BeamEditor-B1rrWZ8t.js → BeamEditor-RO5pPyvd.js} +1 -1
  3. package/dist-embed-scene/BeamSystem-Ab_wCPf_.js +1 -0
  4. package/dist-embed-scene/ContrailSystem-BYqjhyyF.js +1 -0
  5. package/dist-embed-scene/ControlPasses-BZIhjZfW.js +29 -0
  6. package/dist-embed-scene/{Flightradar24Provider-ae0_oe2g.js → Flightradar24Provider-DnJbUJ3f.js} +1 -1
  7. package/dist-embed-scene/GLTFLoader-BmUyASZK.js +1 -0
  8. package/dist-embed-scene/HeadlightSystem-DOQSyusn.js +34 -0
  9. package/dist-embed-scene/{LanternEditor-DbaHa2ey.js → LanternEditor-B6YtPdnz.js} +1 -1
  10. package/dist-embed-scene/{LaserBeam-DW1f0LPn.js → LaserBeam-BS0xtrAx.js} +1 -1
  11. package/dist-embed-scene/{LaunchEditor-M8G5W83U.js → LaunchEditor-C6-Ovt8V.js} +1 -1
  12. package/dist-embed-scene/{LaunchPlume-BtEO63Vx.js → LaunchPlume-GdjoMQQa.js} +1 -1
  13. package/dist-embed-scene/{LaunchSimulation-xgRnC8OK.js → LaunchSimulation-C_x89oL_.js} +1 -1
  14. package/dist-embed-scene/{ModuleSession-BGUJHOk9.js → ModuleSession-CwJVkcpn.js} +2 -2
  15. package/dist-embed-scene/ModuleThree-BHjFJ_bC.js +1 -0
  16. package/dist-embed-scene/{ParameterForm-DMplRkcQ.js → ParameterForm-BEITBqB0.js} +1 -1
  17. package/dist-embed-scene/{RailwaySystem-C3Y0a9aT.js → RailwaySystem-8h9OGJkr.js} +1 -1
  18. package/dist-embed-scene/{ReentryEditor-FFxrv4q7.js → ReentryEditor-BAC0cNg_.js} +1 -1
  19. package/dist-embed-scene/{ReentrySimulation-xFQ_R53U.js → ReentrySimulation-DCNhQGDE.js} +1 -1
  20. package/dist-embed-scene/ReferenceSystem-BTDpVH4u.js +1 -0
  21. package/dist-embed-scene/{RoadMarkings-C3oJCHLk.js → RoadMarkings-DAs6evab.js} +1 -1
  22. package/dist-embed-scene/{SceneNames_en-CIzANCLW.js → SceneNames_en-BLm2h3zy.js} +1 -1
  23. package/dist-embed-scene/{SceneNames_es-DntR6o9V.js → SceneNames_es-DrJ24RvP.js} +1 -1
  24. package/dist-embed-scene/{SceneNames_fr-7wmERMPd.js → SceneNames_fr-CddH0oWD.js} +1 -1
  25. package/dist-embed-scene/{SceneNames_it-Bxtenoxp.js → SceneNames_it-DL3AbXlk.js} +1 -1
  26. package/dist-embed-scene/{TimelineTracks-CZBILU3f.js → TimelineTracks-B73gWzRB.js} +1 -1
  27. package/dist-embed-scene/{TraceSystem-BD6YpW6g.js → TraceSystem-vEBDgerB.js} +2 -2
  28. package/dist-embed-scene/{UfoMessages_en-AS8tBKJW.js → UfoMessages_en-BzK4iS9N.js} +1 -1
  29. package/dist-embed-scene/WaterSystem-QZGlpcQ7.js +19 -0
  30. package/dist-embed-scene/rr0-scene.mjs +168 -162
  31. package/dist-embed-scene/{sightingSchema-B8Xs45w9.js → sightingSchema-Dz2hCtcS.js} +1 -1
  32. package/dist-embed-sighting/{AdsbLolArchiveProvider-D9EKDsic.js → AdsbLolArchiveProvider-BYOz5Wdl.js} +1 -1
  33. package/dist-embed-sighting/{BeamEditor-Cod7HUNj.js → BeamEditor-mDSavUYe.js} +2 -2
  34. package/dist-embed-sighting/BeamSystem-5WJWP1Ad.js +1 -0
  35. package/dist-embed-sighting/{CaseReportExport-CnwLgGOS.js → CaseReportExport-B9N0s2JX.js} +1 -1
  36. package/dist-embed-sighting/ContrailSystem-C1pCwq7H.js +1 -0
  37. package/dist-embed-sighting/ControlPasses-B78JMfGN.js +29 -0
  38. package/dist-embed-sighting/{Flightradar24Provider-DQ-bvlMM.js → Flightradar24Provider-RjrQ963H.js} +1 -1
  39. package/dist-embed-sighting/GLTFLoader-BrNCkGT3.js +1 -0
  40. package/dist-embed-sighting/{HeadlightSystem-B4RR270O.js → HeadlightSystem-LMaOhpkj.js} +1 -1
  41. package/dist-embed-sighting/{LanternEditor-9zPknaGj.js → LanternEditor-Czo3tup9.js} +1 -1
  42. package/dist-embed-sighting/{LaserBeam-CFUYJu2F.js → LaserBeam-BuVmy_0s.js} +1 -1
  43. package/dist-embed-sighting/{LaunchEditor-GiZERDOz.js → LaunchEditor-DZ2V0dHc.js} +1 -1
  44. package/dist-embed-sighting/{LaunchPlume-CuDQMA8K.js → LaunchPlume-Quo7JzI8.js} +1 -1
  45. package/dist-embed-sighting/LaunchSimulation-DZ4pDnrh.js +1 -0
  46. package/dist-embed-sighting/{ModuleSession-CY6DsJx0.js → ModuleSession-xCJtw_IT.js} +2 -2
  47. package/dist-embed-sighting/ModuleThree-D1QGUDll.js +1 -0
  48. package/dist-embed-sighting/{ParameterForm-BHITM-mQ.js → ParameterForm-GKeZmZAL.js} +4 -4
  49. package/dist-embed-sighting/RailwaySystem-m2A18WjN.js +41 -0
  50. package/dist-embed-sighting/{ReentryEditor-C_AN8aTr.js → ReentryEditor-CnYz3Q7Q.js} +2 -2
  51. package/dist-embed-sighting/{ReentrySimulation-sBnymskP.js → ReentrySimulation-BnYP6UwW.js} +1 -1
  52. package/dist-embed-sighting/ReferenceSystem-C1iPC-1U.js +1 -0
  53. package/dist-embed-sighting/{TimelineTracks-B7EcGLEf.js → TimelineTracks-BjJwL-DC.js} +1 -1
  54. package/dist-embed-sighting/{TraceSystem-BkUPo1Xf.js → TraceSystem-ZNrHrAPL.js} +2 -2
  55. package/dist-embed-sighting/WaterSystem-BtEY0XLc.js +19 -0
  56. package/dist-embed-sighting/rr0-sighting.mjs +241 -235
  57. package/dist-embed-sighting/{sightingSchema-B8Xs45w9.js → sightingSchema-Dz2hCtcS.js} +1 -1
  58. package/dist-embed-sighting-editor/{CaseReportExport-B1B1xDnQ.js → CaseReportExport-RjSpSvFT.js} +1 -1
  59. package/dist-embed-sighting-editor/{ControlPasses-BsZQ-_CW.js → ControlPasses-D9A8NPRi.js} +1 -1
  60. package/dist-embed-sighting-editor/{GLTFLoader-D7spTlJl.js → GLTFLoader-GAmboVFk.js} +1 -1
  61. package/dist-embed-sighting-editor/{HeadlightSystem-DZN_EX7x.js → HeadlightSystem-CDAFEIP8.js} +1 -1
  62. package/dist-embed-sighting-editor/{InterviewEditorElement-CD-k5bQB.js → InterviewEditorElement-Bq8INvJ8.js} +2 -2
  63. package/dist-embed-sighting-editor/{ModuleConformance-D7QNv2-c.js → ModuleConformance-Qm-EHVoc.js} +2 -2
  64. package/dist-embed-sighting-editor/{ModuleSession-DTZs4At5.js → ModuleSession-BZ3xmE8Y.js} +2 -2
  65. package/dist-embed-sighting-editor/ModuleThree-BFSbIe18.js +1 -0
  66. package/dist-embed-sighting-editor/{ModulesPanelElement-9x7kP_Tx.js → ModulesPanelElement-DuyRnhEj.js} +3 -3
  67. package/dist-embed-sighting-editor/{RailwaySystem-BxHS7Jka.js → RailwaySystem-DG0WQQfc.js} +1 -1
  68. package/dist-embed-sighting-editor/{ReferenceSystem-ZQRGSWgC.js → ReferenceSystem-DMmt1GR2.js} +1 -1
  69. package/dist-embed-sighting-editor/{SightingFileEditor-BXWkp08k.js → SightingFileEditor-6F5VGGUe.js} +1 -1
  70. package/dist-embed-sighting-editor/{TraceSystem-DAa5Lzof.js → TraceSystem-eEbqZeYs.js} +1 -1
  71. package/dist-embed-sighting-editor/WaterSystem-CbmcniYb.js +19 -0
  72. package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +207 -201
  73. package/dist-embed-sighting-editor/{sightingSchema-B8Xs45w9.js → sightingSchema-Dz2hCtcS.js} +1 -1
  74. package/package.json +1 -1
  75. package/dist-embed-scene/BeamSystem-BxfhSMvb.js +0 -1
  76. package/dist-embed-scene/ContrailSystem-Bn--uCNU.js +0 -1
  77. package/dist-embed-scene/ControlPasses-X_kTXa-p.js +0 -29
  78. package/dist-embed-scene/GLTFLoader-CZ-8eVJ4.js +0 -1
  79. package/dist-embed-scene/HeadlightSystem-l2XbBvXf.js +0 -34
  80. package/dist-embed-scene/ModuleThree-BljKXj42.js +0 -1
  81. package/dist-embed-scene/ReferenceSystem-Dyc08-lR.js +0 -1
  82. package/dist-embed-scene/WaterSystem-DbyWlKho.js +0 -1
  83. package/dist-embed-sighting/BeamSystem-BZ2f4hh1.js +0 -1
  84. package/dist-embed-sighting/ContrailSystem-CqpZgLkb.js +0 -1
  85. package/dist-embed-sighting/ControlPasses-BnlLorfW.js +0 -29
  86. package/dist-embed-sighting/GLTFLoader-DPrksej_.js +0 -1
  87. package/dist-embed-sighting/LaunchSimulation-Fpwvzpf1.js +0 -1
  88. package/dist-embed-sighting/ModuleThree-EigESy50.js +0 -1
  89. package/dist-embed-sighting/RailwaySystem-C1nfRJfj.js +0 -41
  90. package/dist-embed-sighting/ReferenceSystem-Cn6gWxGT.js +0 -1
  91. package/dist-embed-sighting/WaterSystem-DrSAhM5g.js +0 -1
  92. package/dist-embed-sighting-editor/ModuleThree-COSQVAvF.js +0 -1
  93. package/dist-embed-sighting-editor/WaterSystem-C7hE-tnY.js +0 -1
@@ -1 +1 @@
1
- import{bw as k,bx as F,by as v,bz as Y,R as H}from"./rr0-sighting.mjs";class K{static MU=398600.4418;static OMEGA=72921159e-12;static EARTH_RADIUS_KM=6371;static STEP_S=1;static DENSITY=[[0,1.225],[20,.0889],[40,.004],[60,31e-5],[80,185e-7],[100,56e-8],[120,222e-10],[150,208e-11],[200,254e-12],[250,607e-13],[300,192e-13],[400,28e-13],[500,522e-15],[600,114e-15],[700,307e-16],[800,114e-16],[900,576e-17],[1e3,356e-17]];static FREE_PATH_TIMES_DENSITY=68e-9;static ICE_DENSITY=917;static airDensity(s){const t=K.DENSITY;if(s<=t[0][0])return t[0][1];let e=0;for(;e<t.length-2&&t[e+1][0]<s;)e++;const[a,i]=t[e],[o,n]=t[e+1];return i*Math.exp(Math.log(n/i)*(s-a)/(o-a))}static dragPerKm(s,t,e,a=.5){const i=K.airDensity(s),o=K.FREE_PATH_TIMES_DENSITY/i/1e3,n=Math.exp(-o/t),p=i*1e9*Math.PI*t*t/Math.max(e,1e-9),d=3*i/(4*a*1e-6*K.ICE_DENSITY)*1e3;return n*p+(1-n)*d}static step(s,t,e,a,i){const[o,n,p,d,R,h]=s,m=Math.hypot(o,n,p),T=K.OMEGA,M=-398600.4418/(m*m*m),y=M*o+2*T*R+T*T*o,U=M*n-2*T*d+T*T*n,I=M*p,E=Math.hypot(d,R,h),c=1/(1+K.dragPerKm(m-K.EARTH_RADIUS_KM,e,a,i)*E*t);s[3]=(d+y*t)*c,s[4]=(R+U*t)*c,s[5]=(h+I*t)*c,s[0]=o+s[3]*t,s[1]=n+s[4]*t,s[2]=p+s[5]*t;const f=Math.hypot(s[0],s[1],s[2]);if(f<K.EARTH_RADIUS_KM){const A=K.EARTH_RADIUS_KM/f;s[0]*=A,s[1]*=A,s[2]*=A,s[3]=s[4]=s[5]=0}}}class _{constructor(s,t,e,a,i=.5){this.massKg=e,this.radiusAt=a,this.particleRadiusUm=i,this.state=Float64Array.of(...s,...t),this.positions=new Float64Array(192),this.positions.set(s,0)}positions;steps=0;state;at(s){const t=K.STEP_S,e=Math.max(0,s/t),a=Math.ceil(e);for(;this.steps<a;){if(K.step(this.state,t,this.radiusAt(this.steps*t),this.massKg,this.particleRadiusUm),this.steps++,3*(this.steps+1)>this.positions.length){const p=new Float64Array(this.positions.length*2);p.set(this.positions),this.positions=p}this.positions.set(this.state.subarray(0,3),3*this.steps)}const i=Math.floor(e),o=e-i,n=this.positions;return o===0||i>=this.steps?[n[3*i],n[3*i+1],n[3*i+2]]:[0,1,2].map(p=>n[3*i+p]+(n[3*i+3+p]-n[3*i+p])*o)}}class r{static EARTH_RADIUS_KM=6371;static SHADOW_RADIUS_KM=r.EARTH_RADIUS_KM+15;static PENUMBRA_KM=10;static SUN_ILLUMINANCE_LUX=127e3;static RAYLEIGH_PER_M=[58e-7,135e-7,331e-7];static SCALE_HEIGHT_M=8e3;static OZONE_GRAZING_DEPTH=[2.4,1.8,.24];static ANISOTROPY=.7;static ALBEDO=.99;static WAVELENGTHS_UM=[.61,.55,.465];static ICE_INDEX=1.31;static DEFAULTS={exhaustKgPerS:273,condensedShare:.065,particleRadiusUm:.5,expansionKmPerS:.15,initialRadiusKm:.5,lifetimeS:420,collarShare:.85,collarExpansionKmPerS:2.5,collarLifetimeS:20};static PROPELLANTS={"rp1-lox":{condensedShare:.065,particleRadiusUm:.5},"methane-lox":{condensedShare:.09,particleRadiusUm:.5},"hydrogen-lox":{condensedShare:.13,particleRadiusUm:.5},hypergolic:{condensedShare:.079,particleRadiusUm:.4},solid:{condensedShare:.27,particleRadiusUm:.8}};static G0=9.80665;static COLLAR_SPREAD_OF_EXHAUST_VELOCITY=.735;static plumeOf(s){const t={},e=s.vehicle?.engine;if(e){const a=e.specificImpulseS===void 0?void 0:e.specificImpulseS*r.G0;e.thrustKN!==void 0&&a&&(t.exhaustKgPerS=e.thrustKN*1e3/a),a&&(t.collarExpansionKmPerS=a/1e3*r.COLLAR_SPREAD_OF_EXHAUST_VELOCITY),e.propellant&&Object.assign(t,r.PROPELLANTS[e.propellant])}return{...r.DEFAULTS,...t,...s.plume}}static PUFF_EVERY_S=.5;static SIGMA_OF_RADIUS=.5;static MAX_PUFFS=320;static DEG=Math.PI/180;static EARTH_ROTATION=72921159e-12;static VENT_DEFAULTS={speedKmPerS:.7,massKgPerS:20,condensedShare:.5,particleRadiusUm:.5,expansionKmPerS:.1,initialRadiusKm:.2,lifetimeS:600};static paths=new WeakMap;static exhaustVelocityKmPerS(s){return(s.vehicle?.engine?.specificImpulseS??348)*r.G0/1e3}static releasesOf(s){const t=[],e=s.jets??[];if(e.length===0||s.burnFromT!==void 0||s.burnUntilT!==void 0){const a=s.track[0]?.t??0,i=s.track[s.track.length-1]?.t??0;t.push(r.engineRelease(s,"burn",{fromT:s.burnFromT??a,untilT:s.burnUntilT??i}))}return e.forEach((a,i)=>t.push(r.releaseOf(s,a,i))),t}static releaseOf(s,t,e){const a=`jet:${t.id??e}`;if((t.kind??"burn")==="burn")return r.engineRelease(s,a,t);const i=r.VENT_DEFAULTS;return{key:a,fromT:t.fromT,untilT:t.untilT,angleDeg:t.angleDeg??0,azimuthDeg:t.azimuthDeg??0,spinPeriodS:t.spinPeriodS,speedKmPerS:t.speedKmPerS??i.speedKmPerS,massKgPerS:t.massKgPerS??i.massKgPerS,condensedShare:t.condensedShare??i.condensedShare,particleRadiusUm:t.particleRadiusUm??i.particleRadiusUm,initialRadiusKm:t.initialRadiusKm??i.initialRadiusKm,populations:[{share:1,expansionKmPerS:t.expansionKmPerS??i.expansionKmPerS,lifetimeS:t.lifetimeS??i.lifetimeS}]}}static engineRelease(s,t,e){const a=r.plumeOf(s);return{key:t,fromT:e.fromT,untilT:e.untilT,angleDeg:e.angleDeg??0,azimuthDeg:e.azimuthDeg??0,spinPeriodS:e.spinPeriodS,speedKmPerS:e.speedKmPerS??r.exhaustVelocityKmPerS(s),massKgPerS:e.massKgPerS??a.exhaustKgPerS,condensedShare:e.condensedShare??a.condensedShare,particleRadiusUm:e.particleRadiusUm??a.particleRadiusUm,initialRadiusKm:e.initialRadiusKm??a.initialRadiusKm,populations:[{share:1-a.collarShare,expansionKmPerS:e.expansionKmPerS??a.expansionKmPerS,lifetimeS:e.lifetimeS??a.lifetimeS},{share:a.collarShare,expansionKmPerS:a.collarExpansionKmPerS,lifetimeS:a.collarLifetimeS}]}}static extinctionEfficiency(s,t){const e=2*Math.PI*s/t,a=r.ICE_INDEX**2,i=8/3*e**4*((a-1)/(a+2))**2,o=2*e*(r.ICE_INDEX-1),n=o<.001?o*o/2:2-4/o*Math.sin(o)+4/(o*o)*(1-Math.cos(o));return Math.min(i,n)}static scatteringColour(s){const t=r.extinctionEfficiency(s,r.WAVELENGTHS_UM[1]);return r.WAVELENGTHS_UM.map(e=>r.extinctionEfficiency(s,e)/t)}static sunDirectionAt(s){const t=new k(0,0,-6378137),e=F(v.Sun,s,t,!0,!0),a=(e.ra-Y(s))*15*r.DEG,i=e.dec*r.DEG;return[Math.cos(i)*Math.cos(a),Math.cos(i)*Math.sin(a),Math.sin(i)]}static puffsAt(s,t){const e=[];for(const a of s){let i=r.paths.get(a);i||r.paths.set(a,i=new Map);for(const o of r.releasesOf(a)){const n=Math.min(o.untilT,t);if(n<=o.fromT)continue;const p=Math.max(r.PUFF_EVERY_S*1e3,(o.untilT-o.fromT)/r.MAX_PUFFS),d=[];for(let M=o.fromT;M<n;M+=p)d.push(M);d.push(n);const R=o.massKgPerS*(p/1e3),m=3*r.extinctionEfficiency(o.particleRadiusUm,r.WAVELENGTHS_UM[1])/(4*917*o.particleRadiusUm*1e-6),T=r.scatteringColour(o.particleRadiusUm);o.populations.forEach((M,y)=>{if(M.share<=0)return;const U=E=>o.initialRadiusKm+M.expansionKmPerS*E,I=[];for(const E of d){const D=(t-E)/1e3;if(D>M.lifetimeS)continue;const c=E!==n||n===o.untilT,f=`${o.key}|${y}|${E}`;let A=c?i.get(f):void 0;if(!A){if(A=r.launchPuff(a,o,E,R*M.share,U),!A)continue;c&&i.set(f,A)}I.push({ageS:D,position:A.at(D)})}for(let E=I.length-1;E>=0;E--){const{ageS:D,position:c}=I[E],f=I[E-1]??I[E+1],A=f?Math.hypot(c[0]-f.position[0],c[1]-f.position[1],c[2]-f.position[2]):0,l=U(D)+A/2,O=r.SIGMA_OF_RADIUS*l*1e3,N=R*o.condensedShare*M.share*m/(2*Math.PI*O*O),x=Math.max(0,1-(D/M.lifetimeS)**2);N*x<=0||e.push({launchId:a.id,release:o.key,at:r.geoPoint(c),radiusKm:l,opticalDepth:N*x,colour:T,ageS:D})}})}}return e}static viewsAt(s,t,e,a){const i=[];for(const o of r.puffsAt(s,t)){const n=H.seenFrom(e,o.at);if(n.altitudeDeg<0)continue;const p=r.sunlightAt(o.at,a);if(p.lit<=0)continue;const d=r.scatteringPhase(e,o.at,a),R=r.SUN_ILLUMINANCE_LUX*r.ALBEDO*d*o.opticalDepth*p.lit;R<=0||i.push({launchId:o.launchId,release:o.release,heightKm:o.at.heightM/1e3,centre:n,radiusDeg:Math.atan2(o.radiusKm,n.distanceKm)/r.DEG,luminanceCdM2:R,sunTransmittance:p.transmittance,colour:o.colour,lit:p.lit,ageS:o.ageS})}return i}static launchPuff(s,t,e,a,i){const o={id:s.id,track:s.track,fragments:[]},n=H.leadAt(o,e);if(!n)return;const p=s.track[0].t,d=s.track[s.track.length-1].t,R=Math.max(p,e-500),h=Math.min(d,e+500),m=r.earthCentred(n),T=r.earthCentred(H.leadAt(o,R)),M=r.earthCentred(H.leadAt(o,h)),y=Math.max(.001,(h-R)/1e3),U=[0,1,2].map(S=>(M[S]-T[S])/y),I=r.EARTH_ROTATION,E=[U[0]-I*m[1],U[1]+I*m[0],U[2]],D=S=>{const b=Math.hypot(S[0],S[1],S[2])||1;return S.map(w=>w/b)},c=D(E),f=D(m),A=f[0]*c[0]+f[1]*c[1]+f[2]*c[2];let l=[f[0]-A*c[0],f[1]-A*c[1],f[2]-A*c[2]];Math.hypot(l[0],l[1],l[2])<1e-6&&(l=[-c[2]*c[0],-c[2]*c[1],1-c[2]*c[2]]),l=D(l);const O=[c[1]*l[2]-c[2]*l[1],c[2]*l[0]-c[0]*l[2],c[0]*l[1]-c[1]*l[0]],N=t.spinPeriodS?360*((e-t.fromT)/1e3)/t.spinPeriodS:0,x=(t.azimuthDeg+N)*r.DEG,G=t.angleDeg*r.DEG,C=[0,1,2].map(S=>-c[S]*Math.cos(G)+Math.sin(G)*(Math.cos(x)*l[S]+Math.sin(x)*O[S])),P=[0,1,2].map(S=>U[S]+t.speedKmPerS*C[S]);return new _(m,P,a,i,t.particleRadiusUm)}static geoPoint(s){const t=Math.hypot(s[0],s[1],s[2]);return{lat:Math.asin(s[2]/t)/r.DEG,lng:Math.atan2(s[1],s[0])/r.DEG,heightM:(t-K.EARTH_RADIUS_KM)*1e3}}static sunlightAt(s,t){const e=r.earthCentred(s),a=e[0]*t[0]+e[1]*t[1]+e[2]*t[2];if(a>=0)return{lit:1,transmittance:[1,1,1]};const i=Math.hypot(e[0]-a*t[0],e[1]-a*t[1],e[2]-a*t[2]),o=r.PENUMBRA_KM,n=Math.min(1,Math.max(0,(i-(r.SHADOW_RADIUS_KM-o/2))/o));if(n<=0)return{lit:0,transmittance:[0,0,0]};const p=Math.max(0,(i-r.EARTH_RADIUS_KM)*1e3),d=Math.exp(-p/r.SCALE_HEIGHT_M),R=Math.sqrt(2*Math.PI*r.EARTH_RADIUS_KM*1e3*r.SCALE_HEIGHT_M),h=Math.exp(-(((p/1e3-25)/15)**2)),m=[0,1,2].map(T=>Math.exp(-r.RAYLEIGH_PER_M[T]*d*R-r.OZONE_GRAZING_DEPTH[T]*h));return{lit:n,transmittance:m}}static scatteringPhase(s,t,e){const a=r.earthCentred(s),i=r.earthCentred(t),o=[a[0]-i[0],a[1]-i[1],a[2]-i[2]],n=Math.hypot(o[0],o[1],o[2])||1,p=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2])/n,d=r.ANISOTROPY;return(1-d*d)/(4*Math.PI*(1+d*d-2*d*p)**1.5)}static earthCentred(s){const t=s.lat*r.DEG,e=s.lng*r.DEG,a=r.EARTH_RADIUS_KM+s.heightM/1e3;return[a*Math.cos(t)*Math.cos(e),a*Math.cos(t)*Math.sin(e),a*Math.sin(t)]}}export{r as L};
1
+ import{by as w,bz as F,bA as v,bB as Y,R as H}from"./rr0-sighting.mjs";class K{static MU=398600.4418;static OMEGA=72921159e-12;static EARTH_RADIUS_KM=6371;static STEP_S=1;static DENSITY=[[0,1.225],[20,.0889],[40,.004],[60,31e-5],[80,185e-7],[100,56e-8],[120,222e-10],[150,208e-11],[200,254e-12],[250,607e-13],[300,192e-13],[400,28e-13],[500,522e-15],[600,114e-15],[700,307e-16],[800,114e-16],[900,576e-17],[1e3,356e-17]];static FREE_PATH_TIMES_DENSITY=68e-9;static ICE_DENSITY=917;static airDensity(s){const t=K.DENSITY;if(s<=t[0][0])return t[0][1];let e=0;for(;e<t.length-2&&t[e+1][0]<s;)e++;const[a,i]=t[e],[o,n]=t[e+1];return i*Math.exp(Math.log(n/i)*(s-a)/(o-a))}static dragPerKm(s,t,e,a=.5){const i=K.airDensity(s),o=K.FREE_PATH_TIMES_DENSITY/i/1e3,n=Math.exp(-o/t),p=i*1e9*Math.PI*t*t/Math.max(e,1e-9),d=3*i/(4*a*1e-6*K.ICE_DENSITY)*1e3;return n*p+(1-n)*d}static step(s,t,e,a,i){const[o,n,p,d,R,h]=s,m=Math.hypot(o,n,p),T=K.OMEGA,M=-398600.4418/(m*m*m),y=M*o+2*T*R+T*T*o,U=M*n-2*T*d+T*T*n,I=M*p,E=Math.hypot(d,R,h),c=1/(1+K.dragPerKm(m-K.EARTH_RADIUS_KM,e,a,i)*E*t);s[3]=(d+y*t)*c,s[4]=(R+U*t)*c,s[5]=(h+I*t)*c,s[0]=o+s[3]*t,s[1]=n+s[4]*t,s[2]=p+s[5]*t;const f=Math.hypot(s[0],s[1],s[2]);if(f<K.EARTH_RADIUS_KM){const A=K.EARTH_RADIUS_KM/f;s[0]*=A,s[1]*=A,s[2]*=A,s[3]=s[4]=s[5]=0}}}class _{constructor(s,t,e,a,i=.5){this.massKg=e,this.radiusAt=a,this.particleRadiusUm=i,this.state=Float64Array.of(...s,...t),this.positions=new Float64Array(192),this.positions.set(s,0)}positions;steps=0;state;at(s){const t=K.STEP_S,e=Math.max(0,s/t),a=Math.ceil(e);for(;this.steps<a;){if(K.step(this.state,t,this.radiusAt(this.steps*t),this.massKg,this.particleRadiusUm),this.steps++,3*(this.steps+1)>this.positions.length){const p=new Float64Array(this.positions.length*2);p.set(this.positions),this.positions=p}this.positions.set(this.state.subarray(0,3),3*this.steps)}const i=Math.floor(e),o=e-i,n=this.positions;return o===0||i>=this.steps?[n[3*i],n[3*i+1],n[3*i+2]]:[0,1,2].map(p=>n[3*i+p]+(n[3*i+3+p]-n[3*i+p])*o)}}class r{static EARTH_RADIUS_KM=6371;static SHADOW_RADIUS_KM=r.EARTH_RADIUS_KM+15;static PENUMBRA_KM=10;static SUN_ILLUMINANCE_LUX=127e3;static RAYLEIGH_PER_M=[58e-7,135e-7,331e-7];static SCALE_HEIGHT_M=8e3;static OZONE_GRAZING_DEPTH=[2.4,1.8,.24];static ANISOTROPY=.7;static ALBEDO=.99;static WAVELENGTHS_UM=[.61,.55,.465];static ICE_INDEX=1.31;static DEFAULTS={exhaustKgPerS:273,condensedShare:.065,particleRadiusUm:.5,expansionKmPerS:.15,initialRadiusKm:.5,lifetimeS:420,collarShare:.85,collarExpansionKmPerS:2.5,collarLifetimeS:20};static PROPELLANTS={"rp1-lox":{condensedShare:.065,particleRadiusUm:.5},"methane-lox":{condensedShare:.09,particleRadiusUm:.5},"hydrogen-lox":{condensedShare:.13,particleRadiusUm:.5},hypergolic:{condensedShare:.079,particleRadiusUm:.4},solid:{condensedShare:.27,particleRadiusUm:.8}};static G0=9.80665;static COLLAR_SPREAD_OF_EXHAUST_VELOCITY=.735;static plumeOf(s){const t={},e=s.vehicle?.engine;if(e){const a=e.specificImpulseS===void 0?void 0:e.specificImpulseS*r.G0;e.thrustKN!==void 0&&a&&(t.exhaustKgPerS=e.thrustKN*1e3/a),a&&(t.collarExpansionKmPerS=a/1e3*r.COLLAR_SPREAD_OF_EXHAUST_VELOCITY),e.propellant&&Object.assign(t,r.PROPELLANTS[e.propellant])}return{...r.DEFAULTS,...t,...s.plume}}static PUFF_EVERY_S=.5;static SIGMA_OF_RADIUS=.5;static MAX_PUFFS=320;static DEG=Math.PI/180;static EARTH_ROTATION=72921159e-12;static VENT_DEFAULTS={speedKmPerS:.7,massKgPerS:20,condensedShare:.5,particleRadiusUm:.5,expansionKmPerS:.1,initialRadiusKm:.2,lifetimeS:600};static paths=new WeakMap;static exhaustVelocityKmPerS(s){return(s.vehicle?.engine?.specificImpulseS??348)*r.G0/1e3}static releasesOf(s){const t=[],e=s.jets??[];if(e.length===0||s.burnFromT!==void 0||s.burnUntilT!==void 0){const a=s.track[0]?.t??0,i=s.track[s.track.length-1]?.t??0;t.push(r.engineRelease(s,"burn",{fromT:s.burnFromT??a,untilT:s.burnUntilT??i}))}return e.forEach((a,i)=>t.push(r.releaseOf(s,a,i))),t}static releaseOf(s,t,e){const a=`jet:${t.id??e}`;if((t.kind??"burn")==="burn")return r.engineRelease(s,a,t);const i=r.VENT_DEFAULTS;return{key:a,fromT:t.fromT,untilT:t.untilT,angleDeg:t.angleDeg??0,azimuthDeg:t.azimuthDeg??0,spinPeriodS:t.spinPeriodS,speedKmPerS:t.speedKmPerS??i.speedKmPerS,massKgPerS:t.massKgPerS??i.massKgPerS,condensedShare:t.condensedShare??i.condensedShare,particleRadiusUm:t.particleRadiusUm??i.particleRadiusUm,initialRadiusKm:t.initialRadiusKm??i.initialRadiusKm,populations:[{share:1,expansionKmPerS:t.expansionKmPerS??i.expansionKmPerS,lifetimeS:t.lifetimeS??i.lifetimeS}]}}static engineRelease(s,t,e){const a=r.plumeOf(s);return{key:t,fromT:e.fromT,untilT:e.untilT,angleDeg:e.angleDeg??0,azimuthDeg:e.azimuthDeg??0,spinPeriodS:e.spinPeriodS,speedKmPerS:e.speedKmPerS??r.exhaustVelocityKmPerS(s),massKgPerS:e.massKgPerS??a.exhaustKgPerS,condensedShare:e.condensedShare??a.condensedShare,particleRadiusUm:e.particleRadiusUm??a.particleRadiusUm,initialRadiusKm:e.initialRadiusKm??a.initialRadiusKm,populations:[{share:1-a.collarShare,expansionKmPerS:e.expansionKmPerS??a.expansionKmPerS,lifetimeS:e.lifetimeS??a.lifetimeS},{share:a.collarShare,expansionKmPerS:a.collarExpansionKmPerS,lifetimeS:a.collarLifetimeS}]}}static extinctionEfficiency(s,t){const e=2*Math.PI*s/t,a=r.ICE_INDEX**2,i=8/3*e**4*((a-1)/(a+2))**2,o=2*e*(r.ICE_INDEX-1),n=o<.001?o*o/2:2-4/o*Math.sin(o)+4/(o*o)*(1-Math.cos(o));return Math.min(i,n)}static scatteringColour(s){const t=r.extinctionEfficiency(s,r.WAVELENGTHS_UM[1]);return r.WAVELENGTHS_UM.map(e=>r.extinctionEfficiency(s,e)/t)}static sunDirectionAt(s){const t=new w(0,0,-6378137),e=F(v.Sun,s,t,!0,!0),a=(e.ra-Y(s))*15*r.DEG,i=e.dec*r.DEG;return[Math.cos(i)*Math.cos(a),Math.cos(i)*Math.sin(a),Math.sin(i)]}static puffsAt(s,t){const e=[];for(const a of s){let i=r.paths.get(a);i||r.paths.set(a,i=new Map);for(const o of r.releasesOf(a)){const n=Math.min(o.untilT,t);if(n<=o.fromT)continue;const p=Math.max(r.PUFF_EVERY_S*1e3,(o.untilT-o.fromT)/r.MAX_PUFFS),d=[];for(let M=o.fromT;M<n;M+=p)d.push(M);d.push(n);const R=o.massKgPerS*(p/1e3),m=3*r.extinctionEfficiency(o.particleRadiusUm,r.WAVELENGTHS_UM[1])/(4*917*o.particleRadiusUm*1e-6),T=r.scatteringColour(o.particleRadiusUm);o.populations.forEach((M,y)=>{if(M.share<=0)return;const U=E=>o.initialRadiusKm+M.expansionKmPerS*E,I=[];for(const E of d){const D=(t-E)/1e3;if(D>M.lifetimeS)continue;const c=E!==n||n===o.untilT,f=`${o.key}|${y}|${E}`;let A=c?i.get(f):void 0;if(!A){if(A=r.launchPuff(a,o,E,R*M.share,U),!A)continue;c&&i.set(f,A)}I.push({ageS:D,position:A.at(D)})}for(let E=I.length-1;E>=0;E--){const{ageS:D,position:c}=I[E],f=I[E-1]??I[E+1],A=f?Math.hypot(c[0]-f.position[0],c[1]-f.position[1],c[2]-f.position[2]):0,l=U(D)+A/2,O=r.SIGMA_OF_RADIUS*l*1e3,N=R*o.condensedShare*M.share*m/(2*Math.PI*O*O),x=Math.max(0,1-(D/M.lifetimeS)**2);N*x<=0||e.push({launchId:a.id,release:o.key,at:r.geoPoint(c),radiusKm:l,opticalDepth:N*x,colour:T,ageS:D})}})}}return e}static viewsAt(s,t,e,a){const i=[];for(const o of r.puffsAt(s,t)){const n=H.seenFrom(e,o.at);if(n.altitudeDeg<0)continue;const p=r.sunlightAt(o.at,a);if(p.lit<=0)continue;const d=r.scatteringPhase(e,o.at,a),R=r.SUN_ILLUMINANCE_LUX*r.ALBEDO*d*o.opticalDepth*p.lit;R<=0||i.push({launchId:o.launchId,release:o.release,heightKm:o.at.heightM/1e3,centre:n,radiusDeg:Math.atan2(o.radiusKm,n.distanceKm)/r.DEG,luminanceCdM2:R,sunTransmittance:p.transmittance,colour:o.colour,lit:p.lit,ageS:o.ageS})}return i}static launchPuff(s,t,e,a,i){const o={id:s.id,track:s.track,fragments:[]},n=H.leadAt(o,e);if(!n)return;const p=s.track[0].t,d=s.track[s.track.length-1].t,R=Math.max(p,e-500),h=Math.min(d,e+500),m=r.earthCentred(n),T=r.earthCentred(H.leadAt(o,R)),M=r.earthCentred(H.leadAt(o,h)),y=Math.max(.001,(h-R)/1e3),U=[0,1,2].map(S=>(M[S]-T[S])/y),I=r.EARTH_ROTATION,E=[U[0]-I*m[1],U[1]+I*m[0],U[2]],D=S=>{const b=Math.hypot(S[0],S[1],S[2])||1;return S.map(k=>k/b)},c=D(E),f=D(m),A=f[0]*c[0]+f[1]*c[1]+f[2]*c[2];let l=[f[0]-A*c[0],f[1]-A*c[1],f[2]-A*c[2]];Math.hypot(l[0],l[1],l[2])<1e-6&&(l=[-c[2]*c[0],-c[2]*c[1],1-c[2]*c[2]]),l=D(l);const O=[c[1]*l[2]-c[2]*l[1],c[2]*l[0]-c[0]*l[2],c[0]*l[1]-c[1]*l[0]],N=t.spinPeriodS?360*((e-t.fromT)/1e3)/t.spinPeriodS:0,x=(t.azimuthDeg+N)*r.DEG,G=t.angleDeg*r.DEG,C=[0,1,2].map(S=>-c[S]*Math.cos(G)+Math.sin(G)*(Math.cos(x)*l[S]+Math.sin(x)*O[S])),P=[0,1,2].map(S=>U[S]+t.speedKmPerS*C[S]);return new _(m,P,a,i,t.particleRadiusUm)}static geoPoint(s){const t=Math.hypot(s[0],s[1],s[2]);return{lat:Math.asin(s[2]/t)/r.DEG,lng:Math.atan2(s[1],s[0])/r.DEG,heightM:(t-K.EARTH_RADIUS_KM)*1e3}}static sunlightAt(s,t){const e=r.earthCentred(s),a=e[0]*t[0]+e[1]*t[1]+e[2]*t[2];if(a>=0)return{lit:1,transmittance:[1,1,1]};const i=Math.hypot(e[0]-a*t[0],e[1]-a*t[1],e[2]-a*t[2]),o=r.PENUMBRA_KM,n=Math.min(1,Math.max(0,(i-(r.SHADOW_RADIUS_KM-o/2))/o));if(n<=0)return{lit:0,transmittance:[0,0,0]};const p=Math.max(0,(i-r.EARTH_RADIUS_KM)*1e3),d=Math.exp(-p/r.SCALE_HEIGHT_M),R=Math.sqrt(2*Math.PI*r.EARTH_RADIUS_KM*1e3*r.SCALE_HEIGHT_M),h=Math.exp(-(((p/1e3-25)/15)**2)),m=[0,1,2].map(T=>Math.exp(-r.RAYLEIGH_PER_M[T]*d*R-r.OZONE_GRAZING_DEPTH[T]*h));return{lit:n,transmittance:m}}static scatteringPhase(s,t,e){const a=r.earthCentred(s),i=r.earthCentred(t),o=[a[0]-i[0],a[1]-i[1],a[2]-i[2]],n=Math.hypot(o[0],o[1],o[2])||1,p=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2])/n,d=r.ANISOTROPY;return(1-d*d)/(4*Math.PI*(1+d*d-2*d*p)**1.5)}static earthCentred(s){const t=s.lat*r.DEG,e=s.lng*r.DEG,a=r.EARTH_RADIUS_KM+s.heightM/1e3;return[a*Math.cos(t)*Math.cos(e),a*Math.cos(t)*Math.sin(e),a*Math.sin(t)]}}export{r as L};
@@ -0,0 +1 @@
1
+ import{L as M}from"./LaunchPlume-Quo7JzI8.js";import{G as T,$ as z,a2 as f,N as C,bw as w,bx as A}from"./rr0-sighting.mjs";class n{static RADIUS=840;static MAX_PUFFS=1e3;static RINGS=[0,.25,.5,.75,1,1.25];static COLUMN=n.RINGS.map(t=>{const i=o=>Math.exp(-((o/M.SIGMA_OF_RADIUS)**2)/2),s=i(n.RINGS[n.RINGS.length-1]);return Math.max(0,(i(t)-s)/(1-s))});static SECTORS=12;static VERTICES_PER_PUFF=n.SECTORS*(3+6*(n.RINGS.length-2));static BRIGHTEST_RELATIVE=6e4;object=new T;mesh;positions=new Float32Array(n.MAX_PUFFS*n.VERTICES_PER_PUFF*3);colors=new Float32Array(n.MAX_PUFFS*n.VERTICES_PER_PUFF*3);shown=0;drawn=[];static VISIBLE_CONTRAST=.1;constructor(){this.object.name="plumes";const t=new z;t.setAttribute("position",new f(this.positions,3)),t.setAttribute("color",new f(this.colors,3)),t.setDrawRange(0,0),this.mesh=new C(t,w.material()),this.mesh.frustumCulled=!1,w.track(this.mesh),this.object.add(this.mesh)}get count(){return this.shown}set(t,i,s,o){let h=0,c=0;this.drawn=[];for(const p of t){if(c>=n.MAX_PUFFS)break;const d=o(p.centre);if(d<=0)continue;const a=s(p.centre),r=[0,1,2].map(g=>Math.min(n.BRIGHTEST_RELATIVE,p.luminanceCdM2*(p.colour?.[g]??1)*i*p.sunTransmittance[g]*a[g]*d));Math.max(...r)<=0||(h=this.pushPuff(h,p,r),this.drawn.push({view:p,direction:this.normalise(A(p.centre.altitudeDeg,p.centre.azimuthDeg,1)),radiusRad:p.radiusDeg*Math.PI/180,luminance:.2126*r[0]+.7152*r[1]+.0722*r[2]}),c++)}this.shown=c;const u=this.mesh.geometry;u.setDrawRange(0,h),u.getAttribute("position").needsUpdate=!0,u.getAttribute("color").needsUpdate=!0}pushPuff(t,i,s){const o=A(i.centre.altitudeDeg,i.centre.azimuthDeg,n.RADIUS),h=this.normalise(o),c=this.normalise(this.cross({x:0,y:1,z:0},h)),u=this.cross(h,c),p=n.RADIUS*Math.tan(i.radiusDeg*Math.PI/180),d=(r,g)=>{const e=g/n.SECTORS*2*Math.PI,I=n.RINGS[r]*p,R=Math.cos(e)*I,l=Math.sin(e)*I;return{x:o.x+c.x*R+u.x*l,y:o.y+c.y*R+u.y*l,z:o.z+c.z*R+u.z*l}},a=r=>n.COLUMN[r];for(let r=0;r<n.SECTORS;r++){const g=(r+1)%n.SECTORS;t=this.push(t,o,s,a(0)),t=this.push(t,d(1,r),s,a(1)),t=this.push(t,d(1,g),s,a(1));for(let e=1;e<n.RINGS.length-1;e++){const I=d(e,r),R=d(e,g),l=d(e+1,r),E=d(e+1,g);t=this.push(t,I,s,a(e)),t=this.push(t,R,s,a(e)),t=this.push(t,l,s,a(e+1)),t=this.push(t,R,s,a(e)),t=this.push(t,E,s,a(e+1)),t=this.push(t,l,s,a(e+1))}}return t}pickAt(t,i,s=0){const o=this.normalise(t);let h=0,c;for(const u of this.drawn){const p=Math.max(-1,Math.min(1,o.x*u.direction.x+o.y*u.direction.y+o.z*u.direction.z)),d=Math.max(0,Math.acos(p)-i)/Math.max(u.radiusRad,1e-9),a=u.luminance*n.profile(d);a<=0||(h+=a,(!c||a>c.light)&&(c={view:u.view,light:a}))}return c&&h>=n.VISIBLE_CONTRAST*s?c.view:void 0}static profile(t){const i=n.RINGS;if(t>=i[i.length-1])return 0;let s=0;for(;t>i[s+1];)s++;const o=(t-i[s])/(i[s+1]-i[s]);return n.COLUMN[s]+(n.COLUMN[s+1]-n.COLUMN[s])*o}push(t,i,s,o){const h=t*3;return this.positions[h]=i.x,this.positions[h+1]=i.y,this.positions[h+2]=i.z,this.colors[h]=s[0]*o,this.colors[h+1]=s[1]*o,this.colors[h+2]=s[2]*o,t+1}cross(t,i){return this.normalise({x:t.y*i.z-t.z*i.y,y:t.z*i.x-t.x*i.z,z:t.x*i.y-t.y*i.x})}normalise(t){const i=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/i,y:t.y/i,z:t.z/i}}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose(),this.object.removeFromParent()}}class N{inSky=!0;plumes=new n;get object(){return this.plumes.object}get drawnCount(){return this.plumes.count}update(t,i,s){const o=t.length===0||!s.date?[]:M.viewsAt(t,i,s.observer,M.sunDirectionAt(s.date));o.length===0&&this.plumes.count===0||this.plumes.set(o,s.relativeScale,h=>s.transmittanceFromSpace(h),h=>s.cloudTransmission(h))}pick(t,i,s){const o=this.plumes.pickAt(i,s.toleranceRad,s.skyLightTowards(i));return o&&{id:o.launchId,detail:o}}dispose(){this.plumes.dispose()}}export{N as LaunchSimulation};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModuleThree-EigESy50.js","./rr0-sighting.mjs"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ModuleThree-D1QGUDll.js","./rr0-sighting.mjs"])))=>i.map(i=>d[i]);
2
2
  import{f as g,d as w,_ as b,M as p}from"./rr0-sighting.mjs";class n{static STORAGE_KEY="ufoathome.modules";static FORMAT=1;static empty(){return{format:1,modules:[]}}static read(t=n.storage()){try{const e=t?.getItem(n.STORAGE_KEY);return e?n.parse(e):n.empty()}catch{return n.empty()}}static write(t,e=n.storage()){try{return e?(t.modules.length===0?e.removeItem(n.STORAGE_KEY):e.setItem(n.STORAGE_KEY,n.text(t)),!0):!1}catch{return!1}}static parse(t){const e=JSON.parse(t);if(e===null||typeof e!="object"||!Array.isArray(e.modules))throw new Error("not a UFO@home module list");if(typeof e.format=="number"&&e.format>n.FORMAT)throw new Error(`format ${e.format} is newer than ${n.FORMAT}`);const r=new Set,s=[];for(const i of e.modules)typeof i?.url!="string"||r.has(i.url)||(r.add(i.url),s.push({url:i.url,enabled:i.enabled!==!1}));return{format:1,modules:s}}static text(t){return JSON.stringify({format:n.FORMAT,modules:t.modules},null,2)+`
3
- `}static storage(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}}class E{constructor(t,e){this.attribution=t,this.models=e}async entries(t){return t?this.models.filter(e=>[e.kind].flat().includes(t)):[...this.models]}async entry(t){return this.models.find(e=>e.id===t)}}class f{attribution;fetchImpl;tileUrlTemplate;constructor(t){this.attribution=t.attribution,this.tileUrlTemplate=t.tileUrlTemplate,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis)}getImageryTexture(t,e){return g(t,e,r=>f.tileUrl(this.tileUrlTemplate,r),this.fetchImpl)}static tileUrl(t,e){return t.replaceAll("{z}",String(e.z)).replaceAll("{x}",String(e.x)).replaceAll("{y}",String(e.y))}}class v extends Error{constructor(t,e){super(`${t}: ${e}`),this.url=t,this.reason=e,this.name="ModuleManifestError"}}class d{static FORMAT=1;static check(t,e){const r=o=>{throw new v(e,o)};(t===null||typeof t!="object"||Array.isArray(t))&&r("not a JSON object");const s=t;typeof s.format!="number"&&r('no "format"'),s.format>d.FORMAT&&r(`format ${s.format} is newer than ${d.FORMAT}, which this version reads`),(typeof s.id!="string"||!/^[a-z0-9][a-z0-9._-]*$/.test(s.id))&&r(`"id" must be lowercase letters, digits, '.', '_' or '-'`),(typeof s.name!="string"||s.name.trim()==="")&&r('no "name"'),s.script!==void 0&&typeof s.script!="string"&&r('"script" must be an address');const i=s.contributes??{};for(const o of["imagery","elevation"]){const c=i[o];c!==void 0&&(Array.isArray(c)||r(`"contributes.${o}" must be a list`),c.forEach((l,h)=>{for(const m of["id","name","credit","creditUrl","tiles"])(typeof l?.[m]!="string"||l[m]==="")&&r(`"contributes.${o}[${h}].${m}" is missing`);["{z}","{x}","{y}"].every(m=>l.tiles.includes(m))||r(`"contributes.${o}[${h}].tiles" must hold {z}, {x} and {y}`)}))}const a=i.models;return a!==void 0&&(Array.isArray(a)||r('"contributes.models" must be a list'),a.forEach((o,c)=>{for(const l of["id","name","file"])(typeof o?.[l]!="string"||o[l]==="")&&r(`"contributes.models[${c}].${l}" is missing`);o.kind===void 0&&r(`"contributes.models[${c}].kind" is missing`),(!o.credit||typeof o.credit!="object")&&r(`"contributes.models[${c}].credit" is missing: a model is shown with its author and licence`)})),s}static contributions(t,e){const r=t.contributes??{},s={};if(r.imagery?.length&&(s.imagery=r.imagery.map(i=>({id:i.id,name:i.name,credit:i.credit,creditUrl:i.creditUrl,create:a=>new f({tileUrlTemplate:d.absoluteTemplate(i.tiles,e),attribution:i.credit,fetchImpl:a})}))),r.elevation?.length&&(s.elevation=r.elevation.map(i=>({id:i.id,name:i.name,credit:i.credit,creditUrl:i.creditUrl,create:a=>new w({tileUrlTemplate:d.absoluteTemplate(i.tiles,e),fetchImpl:a})}))),r.models?.length){const i=r.models.map(({file:o,...c})=>({...c,url:new URL(o,e).href})),a=t.credit??t.name;s.decorModels=[{id:`${t.id}-models`,name:t.name,credit:a,creditUrl:t.creditUrl??e,create:()=>new E(a,i)}]}return s}static module(t,e,r={}){const s=d.contributions(t,e);for(const[i,a]of Object.entries(r))Array.isArray(a)&&(s[i]=[...s[i]??[],...a]);return{id:t.id,name:t.name,credit:t.credit,creditUrl:t.creditUrl,url:e,contributes:s}}static absoluteTemplate(t,e){const r=t.replaceAll("{z}","__Z__").replaceAll("{x}","__X__").replaceAll("{y}","__Y__");return new URL(r,e).href.replaceAll("__Z__","{z}").replaceAll("__X__","{x}").replaceAll("__Y__","{y}")}}class T{fetchImpl;importImpl;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.importImpl=t.importImpl??(e=>import(e))}async load(t,e){const r=await this.fetchImpl(t);if(!r.ok)throw new Error(`${t}: HTTP ${r.status}`);const s=d.check(await r.json(),t),i=s.script!==void 0;let a={};if(i&&e.runScript){const o=new URL(s.script,t).href,c=await this.importImpl(o);if(typeof c.default!="function")throw new Error(`${o}: its default export is not a function`);const{MODULE_THREE:l}=await b(async()=>{const{MODULE_THREE:h}=await import("./ModuleThree-EigESy50.js");return{MODULE_THREE:h}},__vite__mapDeps([0,1]),import.meta.url);a=await c.default({manifestUrl:t,three:l})??{}}return{url:t,manifest:s,module:d.module(s,t,a),hasScript:i,scriptRun:i&&e.runScript}}}class y{constructor(t=new T,e){this.loader=t,this.storage=e}static shared=new y;changes=new EventTarget;states=new Map;config=n.empty();started;list(){const t=[...this.states.values()];return[...t.filter(e=>e.addedByPerson),...t.filter(e=>!e.addedByPerson)]}state(t){return this.states.get(t)}start(){return this.started??=this.applyConfig(n.read(this.storage)),this.started}async add(t){await this.start();const e=new URL(t,typeof location>"u"?void 0:location.href).href;return this.config.modules.some(r=>r.url===e)||(this.config={...this.config,modules:[...this.config.modules,{url:e,enabled:!0}]},this.save()),this.reload(e)}async remove(t){this.config={...this.config,modules:this.config.modules.filter(e=>e.url!==t)},this.save(),await this.reload(t)}async setEnabled(t,e){this.config={...this.config,modules:this.config.modules.map(r=>r.url===t?{...r,enabled:e}:r)},this.save(),await this.reload(t)}exportText(){return n.text(this.config)}async importText(t){const e=n.parse(t);await this.start();const r=this.config.modules.map(s=>s.url);this.config=e,this.save(),await Promise.all([...new Set([...r,...e.modules.map(s=>s.url)])].map(s=>this.reload(s)))}async require(t,e){t?.length&&(await this.start(),await Promise.all(t.map(async r=>{let s;try{s=new URL(r,e??(typeof location>"u"?void 0:location.href)).href}catch{return}const i=this.states.get(s);if(i&&i.status!=="off")return i.status==="loading"?this.pending.get(s):void 0;this.named.add(s),await this.reload(s)})))}named=new Set;pending=new Map;async applyConfig(t){this.config=t,await Promise.all(t.modules.map(e=>this.reload(e.url)))}reload(t){const e=this.reloadNow(t);return this.pending.set(t,e),e}async reloadNow(t){const e=this.config.modules.find(a=>a.url===t),r=this.states.get(t);r?.loaded&&p.uninstall(r.loaded.module.id);const s=e!==void 0,i=e?.enabled??!0;if(!s&&!this.named.has(t))return this.states.delete(t),this.announce(),{url:t,addedByPerson:s,enabled:i,status:"off"};if(s&&!i&&!this.named.has(t))return this.set({url:t,addedByPerson:s,enabled:i,status:"off"});this.set({url:t,addedByPerson:s,enabled:i,status:"loading"});try{const a=await this.loader.load(t,{runScript:s&&i});return p.install(a.module),this.set({url:t,addedByPerson:s,enabled:i,status:"installed",loaded:a})}catch(a){return this.set({url:t,addedByPerson:s,enabled:i,status:"failed",error:a instanceof Error?a.message:String(a)})}}set(t){return this.states.set(t.url,t),this.announce(),t}save(){n.write(this.config,this.storage)}announce(){this.changes.dispatchEvent(new Event("change"))}}export{y as ModuleSession};
3
+ `}static storage(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}}class E{constructor(t,e){this.attribution=t,this.models=e}async entries(t){return t?this.models.filter(e=>[e.kind].flat().includes(t)):[...this.models]}async entry(t){return this.models.find(e=>e.id===t)}}class f{attribution;fetchImpl;tileUrlTemplate;constructor(t){this.attribution=t.attribution,this.tileUrlTemplate=t.tileUrlTemplate,this.fetchImpl=t.fetchImpl??fetch.bind(globalThis)}getImageryTexture(t,e){return g(t,e,r=>f.tileUrl(this.tileUrlTemplate,r),this.fetchImpl)}static tileUrl(t,e){return t.replaceAll("{z}",String(e.z)).replaceAll("{x}",String(e.x)).replaceAll("{y}",String(e.y))}}class v extends Error{constructor(t,e){super(`${t}: ${e}`),this.url=t,this.reason=e,this.name="ModuleManifestError"}}class d{static FORMAT=1;static check(t,e){const r=o=>{throw new v(e,o)};(t===null||typeof t!="object"||Array.isArray(t))&&r("not a JSON object");const s=t;typeof s.format!="number"&&r('no "format"'),s.format>d.FORMAT&&r(`format ${s.format} is newer than ${d.FORMAT}, which this version reads`),(typeof s.id!="string"||!/^[a-z0-9][a-z0-9._-]*$/.test(s.id))&&r(`"id" must be lowercase letters, digits, '.', '_' or '-'`),(typeof s.name!="string"||s.name.trim()==="")&&r('no "name"'),s.script!==void 0&&typeof s.script!="string"&&r('"script" must be an address');const i=s.contributes??{};for(const o of["imagery","elevation"]){const c=i[o];c!==void 0&&(Array.isArray(c)||r(`"contributes.${o}" must be a list`),c.forEach((l,h)=>{for(const m of["id","name","credit","creditUrl","tiles"])(typeof l?.[m]!="string"||l[m]==="")&&r(`"contributes.${o}[${h}].${m}" is missing`);["{z}","{x}","{y}"].every(m=>l.tiles.includes(m))||r(`"contributes.${o}[${h}].tiles" must hold {z}, {x} and {y}`)}))}const a=i.models;return a!==void 0&&(Array.isArray(a)||r('"contributes.models" must be a list'),a.forEach((o,c)=>{for(const l of["id","name","file"])(typeof o?.[l]!="string"||o[l]==="")&&r(`"contributes.models[${c}].${l}" is missing`);o.kind===void 0&&r(`"contributes.models[${c}].kind" is missing`),(!o.credit||typeof o.credit!="object")&&r(`"contributes.models[${c}].credit" is missing: a model is shown with its author and licence`)})),s}static contributions(t,e){const r=t.contributes??{},s={};if(r.imagery?.length&&(s.imagery=r.imagery.map(i=>({id:i.id,name:i.name,credit:i.credit,creditUrl:i.creditUrl,create:a=>new f({tileUrlTemplate:d.absoluteTemplate(i.tiles,e),attribution:i.credit,fetchImpl:a})}))),r.elevation?.length&&(s.elevation=r.elevation.map(i=>({id:i.id,name:i.name,credit:i.credit,creditUrl:i.creditUrl,create:a=>new w({tileUrlTemplate:d.absoluteTemplate(i.tiles,e),fetchImpl:a})}))),r.models?.length){const i=r.models.map(({file:o,...c})=>({...c,url:new URL(o,e).href})),a=t.credit??t.name;s.decorModels=[{id:`${t.id}-models`,name:t.name,credit:a,creditUrl:t.creditUrl??e,create:()=>new E(a,i)}]}return s}static module(t,e,r={}){const s=d.contributions(t,e);for(const[i,a]of Object.entries(r))Array.isArray(a)&&(s[i]=[...s[i]??[],...a]);return{id:t.id,name:t.name,credit:t.credit,creditUrl:t.creditUrl,url:e,contributes:s}}static absoluteTemplate(t,e){const r=t.replaceAll("{z}","__Z__").replaceAll("{x}","__X__").replaceAll("{y}","__Y__");return new URL(r,e).href.replaceAll("__Z__","{z}").replaceAll("__X__","{x}").replaceAll("__Y__","{y}")}}class T{fetchImpl;importImpl;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.importImpl=t.importImpl??(e=>import(e))}async load(t,e){const r=await this.fetchImpl(t);if(!r.ok)throw new Error(`${t}: HTTP ${r.status}`);const s=d.check(await r.json(),t),i=s.script!==void 0;let a={};if(i&&e.runScript){const o=new URL(s.script,t).href,c=await this.importImpl(o);if(typeof c.default!="function")throw new Error(`${o}: its default export is not a function`);const{MODULE_THREE:l}=await b(async()=>{const{MODULE_THREE:h}=await import("./ModuleThree-D1QGUDll.js");return{MODULE_THREE:h}},__vite__mapDeps([0,1]),import.meta.url);a=await c.default({manifestUrl:t,three:l})??{}}return{url:t,manifest:s,module:d.module(s,t,a),hasScript:i,scriptRun:i&&e.runScript}}}class y{constructor(t=new T,e){this.loader=t,this.storage=e}static shared=new y;changes=new EventTarget;states=new Map;config=n.empty();started;list(){const t=[...this.states.values()];return[...t.filter(e=>e.addedByPerson),...t.filter(e=>!e.addedByPerson)]}state(t){return this.states.get(t)}start(){return this.started??=this.applyConfig(n.read(this.storage)),this.started}async add(t){await this.start();const e=new URL(t,typeof location>"u"?void 0:location.href).href;return this.config.modules.some(r=>r.url===e)||(this.config={...this.config,modules:[...this.config.modules,{url:e,enabled:!0}]},this.save()),this.reload(e)}async remove(t){this.config={...this.config,modules:this.config.modules.filter(e=>e.url!==t)},this.save(),await this.reload(t)}async setEnabled(t,e){this.config={...this.config,modules:this.config.modules.map(r=>r.url===t?{...r,enabled:e}:r)},this.save(),await this.reload(t)}exportText(){return n.text(this.config)}async importText(t){const e=n.parse(t);await this.start();const r=this.config.modules.map(s=>s.url);this.config=e,this.save(),await Promise.all([...new Set([...r,...e.modules.map(s=>s.url)])].map(s=>this.reload(s)))}async require(t,e){t?.length&&(await this.start(),await Promise.all(t.map(async r=>{let s;try{s=new URL(r,e??(typeof location>"u"?void 0:location.href)).href}catch{return}const i=this.states.get(s);if(i&&i.status!=="off")return i.status==="loading"?this.pending.get(s):void 0;this.named.add(s),await this.reload(s)})))}named=new Set;pending=new Map;async applyConfig(t){this.config=t,await Promise.all(t.modules.map(e=>this.reload(e.url)))}reload(t){const e=this.reloadNow(t);return this.pending.set(t,e),e}async reloadNow(t){const e=this.config.modules.find(a=>a.url===t),r=this.states.get(t);r?.loaded&&p.uninstall(r.loaded.module.id);const s=e!==void 0,i=e?.enabled??!0;if(!s&&!this.named.has(t))return this.states.delete(t),this.announce(),{url:t,addedByPerson:s,enabled:i,status:"off"};if(s&&!i&&!this.named.has(t))return this.set({url:t,addedByPerson:s,enabled:i,status:"off"});this.set({url:t,addedByPerson:s,enabled:i,status:"loading"});try{const a=await this.loader.load(t,{runScript:s&&i});return p.install(a.module),this.set({url:t,addedByPerson:s,enabled:i,status:"installed",loaded:a})}catch(a){return this.set({url:t,addedByPerson:s,enabled:i,status:"failed",error:a instanceof Error?a.message:String(a)})}}set(t){return this.states.set(t.url,t),this.announce(),t}save(){n.write(this.config,this.storage)}announce(){this.changes.dispatchEvent(new Event("change"))}}export{y as ModuleSession};
@@ -0,0 +1 @@
1
+ import{z as a,K as e,bH as s,aj as t,al as r,aB as i,aa as o,aw as n,ah as l,ai as b,aX as d,aC as m,aD as u,bI as M,a1 as B,am as G,N as S,x as y,bd as c,ba as f,be as h,G as p,br as x,a0 as C,bJ as L,an as D,bK as g,bL as A,bM as E,C as P,ak as T,$ as N,a2 as j,bN as k,aA as v,aq as F}from"./rr0-sighting.mjs";const K={AdditiveBlending:F,BackSide:v,BoxGeometry:k,BufferAttribute:j,BufferGeometry:N,CanvasTexture:T,Color:P,ConeGeometry:E,CylinderGeometry:A,DataTexture:g,DoubleSide:D,Euler:L,Float32BufferAttribute:C,FrontSide:x,Group:p,Line:h,LineBasicMaterial:f,LineSegments:c,Matrix4:y,Mesh:S,MeshBasicMaterial:G,MeshStandardMaterial:B,NormalBlending:M,Object3D:u,PlaneGeometry:m,PointLight:d,Points:b,PointsMaterial:l,Quaternion:n,ShaderMaterial:o,SphereGeometry:i,Sprite:r,SpriteMaterial:t,TorusGeometry:s,Vector2:e,Vector3:a};export{K as MODULE_THREE};
@@ -1,4 +1,4 @@
1
- import{aL as q,S as R,H as D,s as V,i as j,U,aM as f,aN as g}from"./rr0-sighting.mjs";class X{static attach(e,t,i){e.classList.add(t);const s=`${t}-style`;if(e.parentElement?.querySelector(`:scope > style.${s}`))return;const n=e.ownerDocument.createElement("style");n.className=s,n.textContent=i,e.before(n)}}class I{constructor(e,t,i,s){this.button=e,this.onPick=i,this.idOf=s;const n=this.panel=e.ownerDocument.createElement("div");n.id=t,n.className="add-menu",n.setAttribute("popover",""),n.setAttribute("role","menu");const o=`--add-menu-${t}`;e.style.setProperty("anchor-name",o),n.style.setProperty("position-anchor",o),e.setAttribute("popovertarget",t),e.setAttribute("aria-haspopup","menu"),e.after(n)}static CSS=`
1
+ import{aN as q,S as M,H as D,s as V,i as j,U,aO as f,aP as g}from"./rr0-sighting.mjs";class X{static attach(e,t,i){e.classList.add(t);const s=`${t}-style`;if(e.parentElement?.querySelector(`:scope > style.${s}`))return;const n=e.ownerDocument.createElement("style");n.className=s,n.textContent=i,e.before(n)}}class I{constructor(e,t,i,s){this.button=e,this.onPick=i,this.idOf=s;const n=this.panel=e.ownerDocument.createElement("div");n.id=t,n.className="add-menu",n.setAttribute("popover",""),n.setAttribute("role","menu");const o=`--add-menu-${t}`;e.style.setProperty("anchor-name",o),n.style.setProperty("position-anchor",o),e.setAttribute("popovertarget",t),e.setAttribute("aria-haspopup","menu"),e.after(n)}static CSS=`
2
2
  .add-menu { padding: .3em 0; border: 1px solid color-mix(in srgb, CanvasText 30%, transparent); border-radius: 4px; background: Canvas; color: CanvasText;
3
3
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25); max-height: 60vh; overflow-y: auto; font-size: .9em; }
4
4
  @supports (position-area: bottom span-left) {
@@ -62,7 +62,7 @@ rr0-input-basis[hidden] { display: none; }
62
62
  .basis-source h4 { margin: 0 0 10px; font: 600 13px/1.3 var(--sans); color: var(--ink-dim); }
63
63
  .basis-source-free { margin: 0; font: 400 13px/1.45 var(--sans); color: var(--ink-dim); }
64
64
  .basis-window input { box-sizing: border-box; width: 100%; font-weight: 400; }
65
- `;hows=[];rationaleKept=!0;sourceKept=!0;choices={};wording;sourceWording;shown;mark;window;static count=0;anchor=`--rr0-basis-${++w.count}`;set anchorKey(e){this.anchor=`--rr0-basis-${e.replace(/[^a-zA-Z0-9_-]/g,"-")}`,this.mark?.style.setProperty("anchor-name",this.anchor)}build(){if(this.mark)return;const e=document.createElement("span");e.className="basis-mark",e.setAttribute("role","button"),e.tabIndex=0,e.style.setProperty("anchor-name",this.anchor);const t=i=>{i.preventDefault(),i.stopPropagation(),this.open()};e.addEventListener("click",t),e.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&t(i)}),this.append(e),this.mark=e,this.say()}connectedCallback(){this.build()}set messages(e){this.wording=e,this.say()}set sourceMessages(e){this.sourceWording=e}get entry(){return this.shown}set entry(e){this.shown=e&&(e.basis!=="stated"||e.how!==void 0||e.rationale!==void 0||e.source!==void 0)?{...e}:void 0,this.say()}get pill(){return this.build(),this.mark}say(){const e=this.mark,t=this.wording;if(!e||!t)return;const i=this.shown?.basis??"stated";e.dataset.basis=i,this.dataset.basis=i,e.textContent!==t.basis[i]&&(e.textContent=t.basis[i]),this.shown?.source?e.dataset.sourced="yes":delete e.dataset.sourced;const s=this.rationaleRead();e.title=s?`${t.title} : ${s}`:t.title,e.setAttribute("aria-label",`${t.title} : ${t.basis[i]}`)}rationaleRead(){return new R(D.preferencesFor(this)).read(this.shown?.rationale)}rationaleLanguage(){return V(D.preferencesFor(this),U)}static rationaleWritten(e,t,i){if(e===void 0||typeof e=="string")return t?{rationale:t}:{};const s=Object.fromEntries(Object.entries(e).filter(([o])=>o!==i)),n=t?{...s,[i]:t}:s;return Object.keys(n).length>0?{rationale:n}:{}}open(){const e=this.wording;if(!e)return;const t=Object.assign(document.createElement("h3"),{textContent:e.title}),i=document.createElement("select");for(const u of["established","measured","stated","derived","assumed","fitted"])i.append(new Option(e.basis[u],u));i.value=this.shown?.basis??"stated";const s=document.createElement("select");s.append(new Option("—",""));for(const u of this.hows)s.append(new Option(u.label,u.value));s.value=this.shown?.how??"";const n=document.createElement("textarea");n.value=this.rationaleRead()??"";const o=(u,p)=>{const m=document.createElement("label");return m.append(Object.assign(document.createElement("span"),{textContent:u}),p),m};let a=()=>this.shown?.source;const d=()=>{const u=i.value,p=a();this.entry={basis:u,...s.value?{how:s.value}:{},...w.rationaleWritten(this.shown?.rationale,n.value.trim(),this.rationaleLanguage()),...p?{source:p}:{}},this.dispatchEvent(new CustomEvent("basischange",{detail:{entry:this.shown},bubbles:!0,composed:!0}))};s.addEventListener("change",d),n.addEventListener("change",d);const r=document.createElement("div");r.className="basis-source";const c=()=>{a=this.drawSource(r,i.value,o,()=>d())};i.addEventListener("change",()=>{c(),d()});const l=this.windowElement(),h=this.sourceKept&&this.sourceWording!==void 0;h&&c(),l.replaceChildren(t,o(e.basisField,i),...this.hows.length>0?[o(e.howField,s)]:[],...this.rationaleKept?[o(e.rationaleField,n)]:[],...h?[r]:[]),E.popover(l,e.title),typeof l.showPopover=="function"&&l.isConnected?l.showPopover():l.hidden=!1}static kindOf(e){return e?.said?"said":e?.picture?"picture":e?.document!==void 0||e?.at||e?.url?"document":e?.tool?"tool":"none"}drawSource(e,t,i,s){const n=this.sourceWording;if(!n)return e.replaceChildren(),()=>{};if(j.free({basis:t}))return e.replaceChildren(Object.assign(document.createElement("p"),{className:"basis-source-free",textContent:n.free})),()=>{};const o=this.choices.interviews??[],a=this.choices.pictures??[],d=["none",...o.length>0?["said"]:[],"document",...a.length>0?["picture"]:[],"tool"],r=document.createElement("select");for(const m of d)r.append(new Option(n.kinds[m],m));const c=this.shown?.source,l=w.kindOf(c);r.value=d.includes(l)?l:"none";const h=document.createElement("div");let u=()=>{};const p=()=>{u=this.drawSourceFields(h,r.value,c,i,s)};return r.addEventListener("change",()=>{p(),s()}),p(),e.replaceChildren(i(n.field,r),h),()=>u()}drawSourceFields(e,t,i,s,n){const o=this.sourceWording,a=(t===w.kindOf(i)?i:void 0)??{},d=c=>{const l=document.createElement("input");return l.type="text",l.value=c??"",l.addEventListener("change",n),l},r=c=>c.value.trim()||void 0;if(t==="said"){const c=this.choices.interviews??[],l=document.createElement("select");for(const p of c)l.append(new Option(p.id===void 0?o.interviewOnly:p.label,p.id??""));l.value=a.said?.interview??c[0]?.id??"",l.selectedIndex<0&&c.length===1&&(l.selectedIndex=0);const h=document.createElement("select"),u=()=>{const p=c.find(m=>(m.id??"")===l.value)??c[0];h.replaceChildren(...(p?.segments??[]).map(m=>new Option(m.label||o.segmentUnnamed.replace("{n}",String(m.index+1)),String(m.index)))),a.said&&h.querySelector(`option[value="${a.said.segment}"]`)&&(h.value=String(a.said.segment))};return u(),l.addEventListener("change",()=>{u(),n()}),h.addEventListener("change",n),e.replaceChildren(s(o.interviewField,l),s(o.segmentField,h)),()=>{if(h.value==="")return;const p=c.find(m=>(m.id??"")===l.value);return{said:{...p?.id!==void 0?{interview:p.id}:{},segment:Number(h.value),...a.said?.range?{range:a.said.range}:{}}}}}if(t==="picture"){const c=this.choices.pictures??[],l=document.createElement("select");l.append(new Option("—",""));for(const h of c)l.append(new Option(h.label,h.id));return l.value=a.picture??"",l.addEventListener("change",n),e.replaceChildren(s(o.pictureField,l)),()=>l.value?{picture:l.value}:void 0}if(t==="tool"){const c=d(a.tool);return e.replaceChildren(s(o.toolField,c)),()=>r(c)?{tool:r(c)}:void 0}if(t==="document"){const c=d(typeof a.document=="string"?a.document:void 0),l=d(a.at),h=d(a.url);return e.replaceChildren(s(o.documentField,c),s(o.atField,l),s(o.urlField,h)),()=>{const u={...r(c)?{document:r(c)}:{},...r(l)?{at:r(l)}:{},...r(h)?{url:r(h)}:{}};return typeof a.document=="object"&&a.document!==null&&r(c)===void 0?Object.keys(u).length>0||a.document?{...u,document:a.document}:void 0:Object.keys(u).length>0?u:void 0}}return e.replaceChildren(),()=>{}}windowElement(){if(this.window)return this.window;const e=document.createElement("div");e.className="basis-window",e.setAttribute("popover",""),e.setAttribute("role","dialog"),e.style.setProperty("position-anchor",this.anchor),e.addEventListener("toggle",i=>{i.newState==="closed"&&(e.remove(),this.window=void 0)});const t=this.getRootNode();return t instanceof ShadowRoot?t.append(e):(t instanceof Document?t.body:this).append(e),this.window=e,e}get openWindow(){return this.window}}function H(){customElements.get(w.TAG)||customElements.define(w.TAG,w)}const G="rr0-input-position",W={positionRelative:"relative",positionAbsolute:"absolute",positionModeHint:"Click to say it the other way: from something else, or as a latitude and a longitude",positionNoPlace:"The recording has no place yet: give the observer a latitude and a longitude first",positionFrom:"from",positionObserver:"the observer",positionEast:"East",positionNorth:"North",positionLatitude:"Latitude",positionLongitude:"Longitude",positionLabel:"Position",positionBasisHint:"Where this position comes from",positionBasisStated:"stated",positionBasisEstablished:"established",positionBasisMeasured:"measured",positionBasisDerived:"derived",positionBasisAssumed:"assumed",positionBasisFitted:"fitted",positionBasisField:"Basis"},z=`${w.CSS}
65
+ `;hows=[];rationaleKept=!0;sourceKept=!0;choices={};wording;sourceWording;shown;mark;window;static count=0;anchor=`--rr0-basis-${++w.count}`;set anchorKey(e){this.anchor=`--rr0-basis-${e.replace(/[^a-zA-Z0-9_-]/g,"-")}`,this.mark?.style.setProperty("anchor-name",this.anchor)}build(){if(this.mark)return;const e=document.createElement("span");e.className="basis-mark",e.setAttribute("role","button"),e.tabIndex=0,e.style.setProperty("anchor-name",this.anchor);const t=i=>{i.preventDefault(),i.stopPropagation(),this.open()};e.addEventListener("click",t),e.addEventListener("keydown",i=>{(i.key==="Enter"||i.key===" ")&&t(i)}),this.append(e),this.mark=e,this.say()}connectedCallback(){this.build()}set messages(e){this.wording=e,this.say()}set sourceMessages(e){this.sourceWording=e}get entry(){return this.shown}set entry(e){this.shown=e&&(e.basis!=="stated"||e.how!==void 0||e.rationale!==void 0||e.source!==void 0)?{...e}:void 0,this.say()}get pill(){return this.build(),this.mark}say(){const e=this.mark,t=this.wording;if(!e||!t)return;const i=this.shown?.basis??"stated";e.dataset.basis=i,this.dataset.basis=i,e.textContent!==t.basis[i]&&(e.textContent=t.basis[i]),this.shown?.source?e.dataset.sourced="yes":delete e.dataset.sourced;const s=this.rationaleRead();e.title=s?`${t.title} : ${s}`:t.title,e.setAttribute("aria-label",`${t.title} : ${t.basis[i]}`)}rationaleRead(){return new M(D.preferencesFor(this)).read(this.shown?.rationale)}rationaleLanguage(){return V(D.preferencesFor(this),U)}static rationaleWritten(e,t,i){if(e===void 0||typeof e=="string")return t?{rationale:t}:{};const s=Object.fromEntries(Object.entries(e).filter(([o])=>o!==i)),n=t?{...s,[i]:t}:s;return Object.keys(n).length>0?{rationale:n}:{}}open(){const e=this.wording;if(!e)return;const t=Object.assign(document.createElement("h3"),{textContent:e.title}),i=document.createElement("select");for(const u of["established","measured","stated","derived","assumed","fitted"])i.append(new Option(e.basis[u],u));i.value=this.shown?.basis??"stated";const s=document.createElement("select");s.append(new Option("—",""));for(const u of this.hows)s.append(new Option(u.label,u.value));s.value=this.shown?.how??"";const n=document.createElement("textarea");n.value=this.rationaleRead()??"";const o=(u,p)=>{const m=document.createElement("label");return m.append(Object.assign(document.createElement("span"),{textContent:u}),p),m};let a=()=>this.shown?.source;const d=()=>{const u=i.value,p=a();this.entry={basis:u,...s.value?{how:s.value}:{},...w.rationaleWritten(this.shown?.rationale,n.value.trim(),this.rationaleLanguage()),...p?{source:p}:{}},this.dispatchEvent(new CustomEvent("basischange",{detail:{entry:this.shown},bubbles:!0,composed:!0}))};s.addEventListener("change",d),n.addEventListener("change",d);const r=document.createElement("div");r.className="basis-source";const c=()=>{a=this.drawSource(r,i.value,o,()=>d())};i.addEventListener("change",()=>{c(),d()});const l=this.windowElement(),h=this.sourceKept&&this.sourceWording!==void 0;h&&c(),l.replaceChildren(t,o(e.basisField,i),...this.hows.length>0?[o(e.howField,s)]:[],...this.rationaleKept?[o(e.rationaleField,n)]:[],...h?[r]:[]),E.popover(l,e.title),typeof l.showPopover=="function"&&l.isConnected?l.showPopover():l.hidden=!1}static kindOf(e){return e?.said?"said":e?.picture?"picture":e?.document!==void 0||e?.at||e?.url?"document":e?.tool?"tool":"none"}drawSource(e,t,i,s){const n=this.sourceWording;if(!n)return e.replaceChildren(),()=>{};if(j.free({basis:t}))return e.replaceChildren(Object.assign(document.createElement("p"),{className:"basis-source-free",textContent:n.free})),()=>{};const o=this.choices.interviews??[],a=this.choices.pictures??[],d=["none",...o.length>0?["said"]:[],"document",...a.length>0?["picture"]:[],"tool"],r=document.createElement("select");for(const m of d)r.append(new Option(n.kinds[m],m));const c=this.shown?.source,l=w.kindOf(c);r.value=d.includes(l)?l:"none";const h=document.createElement("div");let u=()=>{};const p=()=>{u=this.drawSourceFields(h,r.value,c,i,s)};return r.addEventListener("change",()=>{p(),s()}),p(),e.replaceChildren(i(n.field,r),h),()=>u()}drawSourceFields(e,t,i,s,n){const o=this.sourceWording,a=(t===w.kindOf(i)?i:void 0)??{},d=c=>{const l=document.createElement("input");return l.type="text",l.value=c??"",l.addEventListener("change",n),l},r=c=>c.value.trim()||void 0;if(t==="said"){const c=this.choices.interviews??[],l=document.createElement("select");for(const p of c)l.append(new Option(p.id===void 0?o.interviewOnly:p.label,p.id??""));l.value=a.said?.interview??c[0]?.id??"",l.selectedIndex<0&&c.length===1&&(l.selectedIndex=0);const h=document.createElement("select"),u=()=>{const p=c.find(m=>(m.id??"")===l.value)??c[0];h.replaceChildren(...(p?.segments??[]).map(m=>new Option(m.label||o.segmentUnnamed.replace("{n}",String(m.index+1)),String(m.index)))),a.said&&h.querySelector(`option[value="${a.said.segment}"]`)&&(h.value=String(a.said.segment))};return u(),l.addEventListener("change",()=>{u(),n()}),h.addEventListener("change",n),e.replaceChildren(s(o.interviewField,l),s(o.segmentField,h)),()=>{if(h.value==="")return;const p=c.find(m=>(m.id??"")===l.value);return{said:{...p?.id!==void 0?{interview:p.id}:{},segment:Number(h.value),...a.said?.range?{range:a.said.range}:{}}}}}if(t==="picture"){const c=this.choices.pictures??[],l=document.createElement("select");l.append(new Option("—",""));for(const h of c)l.append(new Option(h.label,h.id));return l.value=a.picture??"",l.addEventListener("change",n),e.replaceChildren(s(o.pictureField,l)),()=>l.value?{picture:l.value}:void 0}if(t==="tool"){const c=d(a.tool);return e.replaceChildren(s(o.toolField,c)),()=>r(c)?{tool:r(c)}:void 0}if(t==="document"){const c=d(typeof a.document=="string"?a.document:void 0),l=d(a.at),h=d(a.url);return e.replaceChildren(s(o.documentField,c),s(o.atField,l),s(o.urlField,h)),()=>{const u={...r(c)?{document:r(c)}:{},...r(l)?{at:r(l)}:{},...r(h)?{url:r(h)}:{}};return typeof a.document=="object"&&a.document!==null&&r(c)===void 0?Object.keys(u).length>0||a.document?{...u,document:a.document}:void 0:Object.keys(u).length>0?u:void 0}}return e.replaceChildren(),()=>{}}windowElement(){if(this.window)return this.window;const e=document.createElement("div");e.className="basis-window",e.setAttribute("popover",""),e.setAttribute("role","dialog"),e.style.setProperty("position-anchor",this.anchor),e.addEventListener("toggle",i=>{i.newState==="closed"&&(e.remove(),this.window=void 0)});const t=this.getRootNode();return t instanceof ShadowRoot?t.append(e):(t instanceof Document?t.body:this).append(e),this.window=e,e}get openWindow(){return this.window}}function H(){customElements.get(w.TAG)||customElements.define(w.TAG,w)}const G="rr0-input-position",W={positionRelative:"relative",positionAbsolute:"absolute",positionModeHint:"Click to say it the other way: from something else, or as a latitude and a longitude",positionNoPlace:"The recording has no place yet: give the observer a latitude and a longitude first",positionFrom:"from",positionObserver:"the observer",positionEast:"East",positionNorth:"North",positionLatitude:"Latitude",positionLongitude:"Longitude",positionLabel:"Position",positionBasisHint:"Where this position comes from",positionBasisStated:"stated",positionBasisEstablished:"established",positionBasisMeasured:"measured",positionBasisDerived:"derived",positionBasisAssumed:"assumed",positionBasisFitted:"fitted",positionBasisField:"Basis"},z=`${w.CSS}
66
66
  rr0-input-position { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .3em .5em; }
67
67
  /* As the date's own switch (see DateInputElement): it reads as part of the label, before the fields. */
68
68
  rr0-input-position .position-mode { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-decoration: underline; text-underline-offset: .15em; }
@@ -84,8 +84,8 @@ rr0-input-position [hidden] { display: none !important; }
84
84
  `)!==o.join(`
85
85
  `)||[...n.options].map(h=>h.text).join(`
86
86
  `)!==s.map(h=>h.label).join(`
87
- `))&&n.replaceChildren(...s.map(h=>new Option(h.label,h.id??""))),this.referenceId!==void 0&&!s.some(h=>h.id===this.referenceId)&&(this.referenceId=void 0),n.value=this.referenceId??o[0]??"",this.fromRow.hidden=!this.relativeShown,this.localRow.hidden=!this.relativeShown,this.geoRow.hidden=this.relativeShown;const a=this.getRootNode().activeElement,d=(h,u)=>{h!==a&&(h.value=u===void 0?"":String(u))},r=this.localValue(),c=this.reference();if(d(this.eastField,r?f.metres(r.eastM-c.eastM):void 0),d(this.northField,r?f.metres(r.northM-c.northM):void 0),this.isGeo&&!this.relativeShown)return;const l=this.geoValue();d(this.latField,l?f.degrees(l.lat):void 0),d(this.lngField,l?f.degrees(l.lng):void 0)}pickReference(e){this.pullDegrees(),this.referenceId=e===""?void 0:e,this.show();const t=this.said;t&&this.shownValue&&this.tell(this.shownValue,t)}static typed(e){const t=e.value.trim(),i=t===""?NaN:Number(t);return Number.isFinite(i)?i:void 0}typedLocal(){const e=x.typed(this.eastField),t=x.typed(this.northField);if(e===void 0||t===void 0)return;const i=this.reference(),s={eastM:i.eastM+e,northM:i.northM+t};let n=s;if(this.isGeo){const o=this.shownFrame.origin;if(!o)return;n=f.toGeo(s,o)}this.shownValue=n,this.tell(n,f.relative(e,t,this.referenceId))}typedGeo(){const e=x.typed(this.latField),t=x.typed(this.lngField);if(e===void 0||t===void 0)return;let i={lat:e,lng:t};if(!this.isGeo){const s=this.shownFrame.origin;if(!s)return;i=f.toLocal({lat:e,lng:t},s)}this.shownValue=i,this.tell(i,{lat:e,lng:t})}tell(e,t){this.show();const i=this.isGeo?f.isAbsolute(t):f.isRelative(t)&&t.relativeTo===void 0;this.dispatchEvent(new CustomEvent("positionchange",{detail:{value:e,said:i?void 0:t},bubbles:!0,composed:!0}))}}function Y(){customElements.get(G)||customElements.define(G,x)}class M{constructor(e,t,i=()=>{},s){this.read=e,this.edit=t,this.context=i,this.place=s}static inPlace(e){return new M(()=>e,t=>t(e))}}class L{constructor(e,t,i="",s,n){this.container=e,this.idPrefix=i,this.values=s,this.enhance=n,this.said=new R([t,"en"])}set;target;changed=()=>{};said;setLanguage(e){this.said=new R([e,"en"]),this.set&&this.target&&this.show(this.set,this.target,this.changed)}show(e,t,i){this.set=e,this.target=t instanceof M?t:M.inPlace(t),this.changed=i,this.container.replaceChildren();const s=new Map;for(const n of e.parameters){const o=this.read(n.group)??"";let a=s.get(o);if(!a){if(a=document.createElement("fieldset"),a.className="parameter-group",o!==""){const d=document.createElement("legend");d.textContent=o,a.append(d)}else a.classList.add("parameter-group-untitled"),a.style.border="0",a.style.padding="0",a.style.marginInline="0";s.set(o,a),this.container.append(a)}a.append(this.fieldOf(n))}v.fit(this.container),this.sync()}clear(){this.set=void 0,this.target=void 0,this.container.replaceChildren()}field(e){return this.container.querySelector(`[data-key="${e}"]`)??void 0}sync(e=!1){const t=this.target?.read();if(!this.set||!t)return;const i=this.target.context(),s=e?null:this.container.getRootNode().activeElement;for(const n of this.set.parameters){const o=n.type==="position"?this.positionOf(n):this.field(n.key);if(!o)continue;const a=o.closest("label, .parameter-row")??o;a.hidden=n.visibleWhen!==void 0&&!n.visibleWhen(t,i);const d=g.read(t,n.key);if(n.type==="number"){const r=o;r!==s&&(r.value=typeof d=="number"?L.shown(d,n):"");const c=L.boundsOf(n,t,i);r.min=String(c.min),r.max=String(c.max);const l=n.effective?.(t,i);r.placeholder=l!==void 0?L.shown(l,n):this.read(n.placeholder)??"",r.classList.toggle("parameter-derived",d===void 0)}else if(n.type==="choice"){const r=o,c=n.optionsOf?.(t,i)??n.choices;if([...r.options].filter(l=>l.value!=="").map(l=>l.value).join(`
87
+ `))&&n.replaceChildren(...s.map(h=>new Option(h.label,h.id??""))),this.referenceId!==void 0&&!s.some(h=>h.id===this.referenceId)&&(this.referenceId=void 0),n.value=this.referenceId??o[0]??"",this.fromRow.hidden=!this.relativeShown,this.localRow.hidden=!this.relativeShown,this.geoRow.hidden=this.relativeShown;const a=this.getRootNode().activeElement,d=(h,u)=>{h!==a&&(h.value=u===void 0?"":String(u))},r=this.localValue(),c=this.reference();if(d(this.eastField,r?f.metres(r.eastM-c.eastM):void 0),d(this.northField,r?f.metres(r.northM-c.northM):void 0),this.isGeo&&!this.relativeShown)return;const l=this.geoValue();d(this.latField,l?f.degrees(l.lat):void 0),d(this.lngField,l?f.degrees(l.lng):void 0)}pickReference(e){this.pullDegrees(),this.referenceId=e===""?void 0:e,this.show();const t=this.said;t&&this.shownValue&&this.tell(this.shownValue,t)}static typed(e){const t=e.value.trim(),i=t===""?NaN:Number(t);return Number.isFinite(i)?i:void 0}typedLocal(){const e=x.typed(this.eastField),t=x.typed(this.northField);if(e===void 0||t===void 0)return;const i=this.reference(),s={eastM:i.eastM+e,northM:i.northM+t};let n=s;if(this.isGeo){const o=this.shownFrame.origin;if(!o)return;n=f.toGeo(s,o)}this.shownValue=n,this.tell(n,f.relative(e,t,this.referenceId))}typedGeo(){const e=x.typed(this.latField),t=x.typed(this.lngField);if(e===void 0||t===void 0)return;let i={lat:e,lng:t};if(!this.isGeo){const s=this.shownFrame.origin;if(!s)return;i=f.toLocal({lat:e,lng:t},s)}this.shownValue=i,this.tell(i,{lat:e,lng:t})}tell(e,t){this.show();const i=this.isGeo?f.isAbsolute(t):f.isRelative(t)&&t.relativeTo===void 0;this.dispatchEvent(new CustomEvent("positionchange",{detail:{value:e,said:i?void 0:t},bubbles:!0,composed:!0}))}}function Y(){customElements.get(G)||customElements.define(G,x)}class R{constructor(e,t,i=()=>{},s){this.read=e,this.edit=t,this.context=i,this.place=s}static inPlace(e){return new R(()=>e,t=>t(e))}}class L{constructor(e,t,i="",s,n){this.container=e,this.idPrefix=i,this.values=s,this.enhance=n,this.said=new M([t,"en"])}set;target;changed=()=>{};said;setLanguage(e){this.said=new M([e,"en"]),this.set&&this.target&&this.show(this.set,this.target,this.changed)}show(e,t,i){this.set=e,this.target=t instanceof R?t:R.inPlace(t),this.changed=i,this.container.replaceChildren();const s=new Map;for(const n of e.parameters){const o=this.read(n.group)??"";let a=s.get(o);if(!a){if(a=document.createElement("fieldset"),a.className="parameter-group",o!==""){const d=document.createElement("legend");d.textContent=o,a.append(d)}else a.classList.add("parameter-group-untitled"),a.style.border="0",a.style.padding="0",a.style.marginInline="0";s.set(o,a),this.container.append(a)}a.append(this.fieldOf(n))}v.fit(this.container),this.sync()}clear(){this.set=void 0,this.target=void 0,this.container.replaceChildren()}field(e){return this.container.querySelector(`[data-key="${e}"]`)??void 0}sync(e=!1){const t=this.target?.read();if(!this.set||!t)return;const i=this.target.context(),s=e?null:this.container.getRootNode().activeElement;for(const n of this.set.parameters){const o=n.type==="position"?this.positionOf(n):this.field(n.key);if(!o)continue;const a=o.closest("label, .parameter-row")??o;a.hidden=n.visibleWhen!==void 0&&!n.visibleWhen(t,i);const d=g.read(t,n.key);if(n.type==="number"){const r=o;r!==s&&(r.value=typeof d=="number"?L.shown(d,n):"");const c=L.boundsOf(n,t,i);r.min=String(c.min),r.max=String(c.max);const l=n.effective?.(t,i);r.placeholder=l!==void 0?L.shown(l,n):this.read(n.placeholder)??"",r.classList.toggle("parameter-derived",d===void 0)}else if(n.type==="choice"){const r=o,c=n.optionsOf?.(t,i)??n.choices;if([...r.options].filter(l=>l.value!=="").map(l=>l.value).join(`
88
88
  `)!==c.map(l=>l.value).join(`
89
89
  `)&&r.replaceChildren(...n.required?[]:[new Option("—","")],...c.map(l=>new Option(this.read(l.label)??l.value,l.value))),r!==s&&(r.value=typeof d=="string"&&c.some(l=>l.value===d)?d:n.required?r.options[0]?.value??"":""),!n.required){const l=n.effective?.(t,i),h=c.find(u=>u.value===l);r.options[0].textContent=h?this.read(h.label)??h.value:this.read(n.empty)??"—"}}else if(n.type==="boolean"){const r=o;r.checked=d===!0}else if(n.type==="colour"){const r=o;r!==s&&(r.value=L.swatchOf(d,n.fallback??"#808080"))}else if(n.type==="set")this.syncSet(n,o,t,i);else if(n.type==="position")this.syncPosition(n,o,t);else if(n.type==="said"){const r=o;r!==s&&(r.value=this.values?.said().read(g.read(t,n.key))??""),this.markMissing(n,r)}else{const r=o;r!==s&&(r.value=typeof d=="string"?d:"",r.classList.remove("invalid"),r.removeAttribute("aria-invalid"))}}for(const n of this.container.querySelectorAll("fieldset.parameter-group"))n.hidden=[...n.querySelectorAll("label, .parameter-row")].filter(o=>o.parentElement===n).every(o=>o.hidden)}fieldOf(e){const t=document.createElement("label"),i=this.read(e.hint);i&&(t.title=i);const s=document.createElement("span");s.textContent=this.read(e.label)??e.key,t.append(s," ");let n;if(e.type==="choice"){const o=document.createElement("select");this.identify(o,e),e.required||o.append(new Option("—","")),o.append(...e.choices.map(a=>new Option(this.read(a.label)??a.value,a.value))),o.addEventListener("input",()=>this.write(e,o.value===""?void 0:o.value)),t.append(o),this.enhance?.(e,o)}else{if(e.type==="position")return this.setRow(e,this.positionFieldOf(e));if(e.type==="set"){const o=document.createElement("div");return this.identify(o,e),o.className="parameter-set",o.addEventListener("input",()=>{const a=[...o.querySelectorAll("input:checked")].map(d=>d.value);this.write(e,a.length>0?a:void 0)}),this.setRow(e,o)}else if(e.type==="boolean"){const o=document.createElement("input");o.type="checkbox",this.identify(o,e),o.addEventListener("input",()=>this.write(e,o.checked?!0:e.required?!1:void 0)),t.prepend(o),t.append(" ")}else{const o=document.createElement("input");this.identify(o,e),o.autocomplete="off",e.type==="number"?(o.type="number",o.min=String(e.min),o.max=String(e.max),o.step=String(e.step),n=e.unit,o.addEventListener("input",()=>{const a=o.value.trim();if(a==="")return e.required?void 0:this.write(e,void 0);const d=Number(a);Number.isFinite(d)&&this.write(e,d)})):e.type==="colour"?(o.type="color",o.addEventListener("input",()=>this.write(e,o.value))):e.type==="said"?(o.type="text",o.placeholder=this.read(e.placeholder)??"",o.style.setProperty("field-sizing","content"),o.style.minWidth="10em",o.style.maxWidth="100%",o.addEventListener("input",()=>{const a=this.target?.read(),d=this.values;!a||!d||(this.write(e,d.said().write(g.read(a,e.key),o.value,d.writingLanguage())),this.markMissing(e,o))})):(o.type="text",o.placeholder=this.read(e.placeholder)??"",o.addEventListener("input",()=>{const a=e.required||e.validate?o.value.trim():o.value,d=this.target?.read(),r=d!==void 0&&(e.required===!0&&a===""||a!==""&&e.validate?.(a,d,this.target.context())===!1);o.classList.toggle("invalid",r),r?o.setAttribute("aria-invalid","true"):o.removeAttribute("aria-invalid"),!r&&this.write(e,a===""?void 0:a)}),o.addEventListener("change",()=>{if(!o.classList.contains("invalid"))return;o.classList.remove("invalid"),o.removeAttribute("aria-invalid");const a=this.target?.read(),d=a===void 0?void 0:g.read(a,e.key);o.value=typeof d=="string"?d:""})),t.append(o)}}return n&&t.append(` ${n}`),t}markMissing(e,t){e.type!=="said"||!e.required||(t.classList.toggle("invalid",t.value===""),t.setAttribute("aria-invalid",String(t.value==="")))}positionFieldOf(e){Y();const t=document.createElement("rr0-input-position"),i=`${this.idPrefix}${e.key}`;t.setAttribute("name",i),e.native==="geo"&&t.setAttribute("native","geo"),e.step!==void 0&&t.setAttribute("step",String(e.step)),e.rangeM!==void 0&&t.setAttribute("range",String(e.rangeM));const s=e.native==="geo"?["lat-id","lng-id"]:["east-id","north-id"];this.idPrefix!==""&&(t.setAttribute(s[0],`${this.idPrefix}${e.key}`),t.setAttribute(s[1],`${this.idPrefix}${e.secondKey}`)),t.dataset.position=e.key,t.build();const[n,o]=e.native==="geo"?[t.latInput,t.lngInput]:[t.eastInput,t.northInput];n.dataset.key=e.key,o.dataset.key=e.secondKey;const a=this.target?.place;return a&&(t.messages=a.messages()),t.basisShown=a?.basis!==void 0,t.addEventListener("positionchange",d=>{const{value:r,said:c}=d.detail;this.writePosition(e,r,c)}),t.addEventListener("basischange",d=>this.target?.place?.basis?.write(e,d.detail.basis)),t}positionOf(e){return this.container.querySelector(`rr0-input-position[data-position="${e.key}"]`)??void 0}syncPosition(e,t,i){const s=this.target?.place;s&&(t.messages=s.messages(),t.frame=s.frame());const n=g.read(i,e.key),o=g.read(i,e.secondKey),a=typeof n=="number"&&typeof o=="number";t.value=a?e.native==="geo"?{lat:n,lng:o}:{eastM:n,northM:o}:void 0;const d=g.read(i,e.saidKey),r=JSON.stringify(d??null);t.dataset.said!==r&&(t.dataset.said=r,t.said=d),t.basis=s?.basis?.read(e)}writePosition(e,t,i){const s=this.target;if(!s)return;const[n,o]="lat"in t?[t.lat,t.lng]:[t.eastM,t.northM],a=e.native==="geo"?d=>Math.round(d*1e7)/1e7:d=>Math.round(d*1e3)/1e3;this.positionOf(e)?.setAttribute("data-said",JSON.stringify(i??null)),s.edit(d=>{g.write(d,e.key,a(n)),g.write(d,e.secondKey,a(o)),g.write(d,e.saidKey,i)},e),this.changed(),this.sync()}setRow(e,t){const i=document.createElement("div");i.className="parameter-row";const s=this.read(e.hint);s&&(i.title=s);const n=document.createElement("span");return n.textContent=this.read(e.label)??e.key,i.append(n," ",t),i}syncSet(e,t,i,s){if(e.type!=="set")return;const n=g.read(i,e.key),o=new Set(Array.isArray(n)?n:[]),a=e.options(i,s);if(a.length===0){t.textContent=this.read(e.empty)??"";return}[...t.querySelectorAll("input")].map(r=>r.value).join(`
90
90
  `)===a.map(r=>r.value).join(`
91
- `)||t.replaceChildren(...a.map(r=>{const c=document.createElement("label"),l=document.createElement("input");return l.type="checkbox",l.value=r.value,c.append(l," ",r.label),c}));for(const r of t.querySelectorAll("input"))r.checked=o.has(r.value)}identify(e,t){e.dataset.key=t.key,this.idPrefix!==""&&(e.id=`${this.idPrefix}${t.key}`)}write(e,t){const i=this.target;if(!i)return;let s=t;if(e.type==="number"&&typeof t=="number"){const n=i.read();if(n){const o=L.boundsOf(e,n,i.context());s=Math.max(o.min,Math.min(o.max,t))/(e.scale??1)}}i.edit(n=>g.write(n,e.key,s),e),this.changed(),this.sync()}read(e){return this.said.read(e)}static boundsOf(e,t,i){const s=e.bounds?.(t,i);return{min:s?.min??e.min,max:s?.max??e.max}}static swatchOf(e,t){if(typeof e!="string")return t;const i=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e);return i?`#${i[1]}${i[1]}${i[2]}${i[2]}${i[3]}${i[3]}`.toLowerCase():/^#[0-9a-f]{6}$/i.test(e)?e.toLowerCase():t}static shown(e,t){const i=Math.max(2,Math.min(6,(String(t.step).split(".")[1]??"").length));return String(Number((e*(t.scale??1)).toFixed(i)))}static choicesOf(e){return e.choices.map(t=>t.value)}}export{A as E,L as P,X as S,M as a};
91
+ `)||t.replaceChildren(...a.map(r=>{const c=document.createElement("label"),l=document.createElement("input");return l.type="checkbox",l.value=r.value,c.append(l," ",r.label),c}));for(const r of t.querySelectorAll("input"))r.checked=o.has(r.value)}identify(e,t){e.dataset.key=t.key,this.idPrefix!==""&&(e.id=`${this.idPrefix}${t.key}`)}write(e,t){const i=this.target;if(!i)return;let s=t;if(e.type==="number"&&typeof t=="number"){const n=i.read();if(n){const o=L.boundsOf(e,n,i.context());s=Math.max(o.min,Math.min(o.max,t))/(e.scale??1)}}i.edit(n=>g.write(n,e.key,s),e),this.changed(),this.sync()}read(e){return this.said.read(e)}static boundsOf(e,t,i){const s=e.bounds?.(t,i);return{min:s?.min??e.min,max:s?.max??e.max}}static swatchOf(e,t){if(typeof e!="string")return t;const i=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e);return i?`#${i[1]}${i[1]}${i[2]}${i[2]}${i[3]}${i[3]}`.toLowerCase():/^#[0-9a-f]{6}$/i.test(e)?e.toLowerCase():t}static shown(e,t){const i=Math.max(2,Math.min(6,(String(t.step).split(".")[1]??"").length));return String(Number((e*(t.scale??1)).toFixed(i)))}static choicesOf(e){return e.choices.map(t=>t.value)}}export{A as E,L as P,X as S,R as a};
@@ -0,0 +1,41 @@
1
+ import{G as F,a1 as P,C as H,m as K,$ as w,a2 as N,N as U,a3 as k}from"./rr0-sighting.mjs";class b{static HOLLOW_M=1;static COVERED_M=3;static WINDOW_M=30;static SAMPLE_M=4;static MAX_GRADE={rail:.025,highSpeed:.035,subway:.04,light_rail:.06,tram:.08,funicular:1/0};static heights(t,s,e){const n=t.map(a=>a.level===0),o=t.map((a,i)=>n[i]?b.targets(a,s,e):[]),c=t.map((a,i)=>n[i]?b.samples(a,o[i]):[]),r=new Map;t.forEach((a,i)=>{if(n[i])for(const h of b.ends(a)){const u=b.key(h),p=r.get(u);p?p.push(i):r.set(u,[i])}});const M=a=>{const i=r.get(b.key(a));if(i)return b.median(i.flatMap(h=>c[h]),a)};return t.map((a,i)=>{if(n[i]){const h=[...new Set([i,...b.ends(a).flatMap(d=>r.get(b.key(d))??[])])].flatMap(d=>c[d]),u=a.centre.map((d,O)=>b.median(h,d)??o[i][O]),[p,A]=b.ends(a);return u[0]=M(p)??u[0],u[u.length-1]=M(A)??u[u.length-1],b.graded(u,a.along,a.highSpeed?b.MAX_GRADE.highSpeed:b.MAX_GRADE[a.kind])}return b.carried(a,s,e,M)})}static targets(t,s,e){return t.centre.map(n=>{const o=s(n.x,n.z);if(e===void 0||n.altitudeM===void 0)return o;const c=n.altitudeM+e;return c-o>b.HOLLOW_M||o-c>b.COVERED_M?c:o})}static samples(t,s){const e=[];let n=0;return t.centre.forEach((o,c)=>{t.along[c]+1e-6<n&&c<t.centre.length-1||(e.push({x:o.x,z:o.z,y:s[c]}),n=t.along[c]+b.SAMPLE_M)}),e}static median(t,s){const e=[];for(const o of t)Math.hypot(o.x-s.x,o.z-s.z)<=b.WINDOW_M&&e.push(o.y);if(e.length===0)return;e.sort((o,c)=>o-c);const n=e.length>>1;return e.length%2===1?e[n]:(e[n-1]+e[n])/2}static graded(t,s,e){if(!Number.isFinite(e)||t.length<3)return t;const n=[...t],o=n.length-1,c=s[o];if(Math.abs(n[o]-n[0])>e*c)return s.map(r=>n[0]+(n[o]-n[0])*r/c);for(let r=1;r<o;r++){const M=e*(s[r]-s[r-1]);n[r]=Math.min(n[r-1]+M,Math.max(n[r-1]-M,n[r]))}for(let r=o-1;r>0;r--){const M=e*(s[r+1]-s[r]);n[r]=Math.min(n[r+1]+M,Math.max(n[r+1]-M,n[r]))}return n}static carried(t,s,e,n){const[o,c]=b.ends(t),r=t.along[t.along.length-1],M=n(o),a=n(c);if(e!==void 0&&t.centre.every(u=>u.altitudeM!==void 0)){const u=t.centre.map(d=>d.altitudeM+e),p=M!==void 0?M-u[0]:0,A=a!==void 0?a-u[u.length-1]:0;return u.map((d,O)=>d+p+(A-p)*t.along[O]/r)}const i=M??s(o.x,o.z),h=a??s(c.x,c.z);return t.along.map(u=>i+(h-i)*u/r)}static ends(t){return[t.centre[0],t.centre[t.centre.length-1]]}static key(t){return`${Math.round(t.x*2)},${Math.round(t.z*2)}`}}class B{positions=[];indices=[];along=[];get vertexCount(){return this.positions.length/3}strip(t,s,e){const n=this.vertexCount;for(let o=0;o<t.length;o++)this.positions.push(t[o].x,t[o].y,t[o].z,s[o].x,s[o].y,s[o].z),e&&this.along.push(e[o],e[o]);for(let o=0;o<t.length-1;o++){const c=n+o*2;this.indices.push(c,c+2,c+1,c+1,c+2,c+3)}}beam(t,s,e,n=!0){const o=s.x-t.x,c=s.y-t.y,r=s.z-t.z,M=Math.hypot(o,c,r);if(M<1e-6)return;const a={x:o/M,y:c/M,z:r/M},i=Math.abs(a.y)>.9?{x:1,y:0,z:0}:{x:0,y:1,z:0},h=a.y*i.z-a.z*i.y,u=a.z*i.x-a.x*i.z,p=a.x*i.y-a.y*i.x,A=Math.hypot(h,u,p),d={x:h/A*e/2,y:u/A*e/2,z:p/A*e/2},O={x:a.y*d.z-a.z*d.y,y:a.z*d.x-a.x*d.z,z:a.x*d.y-a.y*d.x},g=(f,x,E)=>({x:f.x+d.x*x+O.x*E,y:f.y+d.y*x+O.y*E,z:f.z+d.z*x+O.z*E}),_=[[1,1],[-1,1],[-1,-1],[1,-1]];for(let f=0;f<4;f++){const[x,E]=_[f],[z,v]=_[(f+1)%4];this.quad(g(t,x,E),g(t,z,v),g(s,z,v),g(s,x,E))}n&&(this.quad(...[..._].reverse().map(([f,x])=>g(t,f,x))),this.quad(..._.map(([f,x])=>g(s,f,x))))}quad(t,s,e,n){const o=this.vertexCount;this.positions.push(t.x,t.y,t.z,s.x,s.y,s.z,e.x,e.y,e.z,n.x,n.y,n.z),this.indices.push(o,o+1,o+2,o,o+2,o+3)}}class l{static STEP_M=6;static BALLAST_HEIGHT_M=.5;static BALLAST_SLOPE=1.5;static BALLAST_SHOULDER_M=.45;static DECK_DEPTH_M=.8;static BANK_SLOPE=1.5;static SLEEPER_LENGTH_M=2.4;static SLEEPER_WIDTH_M=.29;static SLEEPER_SPACING_M=.6;static RAIL_HEAD_M=.072;static RAIL_HEIGHT_M=.18;static TRAM_RAIL_HEIGHT_M=.03;static LIFT_M=.06;static CATENARY={rail:{contactM:5.5,systemM:1.4,spanM:54,staggerM:.2},highSpeed:{contactM:5.08,systemM:1.4,spanM:63,staggerM:.2},service:{contactM:5.5,systemM:1.2,spanM:45,staggerM:.2},tram:{contactM:6,systemM:0,spanM:30,staggerM:.2}};static MESSENGER_SAG_M=.55;static MAST_SIDE_M=.26;static MAST_OFFSET_M=3.1;static MAST_ABOVE_M=.6;static CONTACT_DIAMETER_M=.012;static MESSENGER_DIAMETER_M=.011;static ARM_SIDE_M=.06;static TRACK_SPACING_M={rail:3.7,highSpeed:4.5,tram:3.1,subway:3.4,light_rail:3.4,funicular:3.2};static BALLAST_ALBEDO=[.17,.16,.15];static BANK_ALBEDO=[.085,.09,.05];static DECK_ALBEDO=[.26,.255,.24];static CONCRETE_ALBEDO=[.36,.35,.33];static WOOD_ALBEDO=[.07,.055,.045];static RUST_ALBEDO=[.085,.068,.058];static STEEL_ALBEDO=[.3,.31,.32];static COPPER_ALBEDO=[.09,.085,.07];static LINE_REACH_M=20;group=new F;stepM=l.STEP_M;drawn=0;laid=[];ballastMaterial=l.pebbled(l.lambert(l.BALLAST_ALBEDO,!0));earthMaterial=l.lambert(l.BANK_ALBEDO,!0);deckMaterial=l.lambert(l.DECK_ALBEDO,!1);concreteSleepers=l.sleeperMaterial(l.CONCRETE_ALBEDO);woodSleepers=l.sleeperMaterial(l.WOOD_ALBEDO);rustMaterial=l.lambert(l.RUST_ALBEDO,!0);headMaterial=new P({color:new H(.62,.62,.62),metalness:1,roughness:.28,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2});steelMaterial=l.lambert(l.STEEL_ALBEDO,!1);wireMaterial=l.lambert(l.COPPER_ALBEDO,!1);constructor(){this.group.name="railways"}get count(){return this.drawn}setGroundSpacing(t){this.stepM=Number.isFinite(t)&&t>0?Math.min(l.STEP_M,Math.max(1.5,t/2)):l.STEP_M}set(t,s,e,n,o=1/0){this.clear();const r=t.map(p=>({line:p,path:p.points.map(A=>({...K(A.lat,A.lng,s,e),altitudeM:A.altitudeM}))})).filter(({line:p,path:A})=>p.level>=0&&l.within(A,o)),M=l.altitudeOffset(r,n),a=r.flatMap(({line:p,path:A})=>{const d=this.layoutOf(p,A);return d?[{line:p,layout:d}]:[]}),i=b.heights(a.map(({layout:p})=>p),n,M),h={ballast:new B,earth:new B,deck:new B,concrete:new B,wood:new B,rust:new B,head:new B,steel:new B,wire:new B};a.forEach(({line:p,layout:A},d)=>{this.lay(p,{...A,y:i[d]},n,h),this.laid.push({line:p,centre:A.centre}),this.drawn++});const u=[[h.ballast,this.ballastMaterial,"ballast",!1],[h.earth,this.earthMaterial,"embankments",!1],[h.deck,this.deckMaterial,"decks",!0],[h.concrete,this.concreteSleepers,"sleepers",!1],[h.wood,this.woodSleepers,"sleepers wood",!1],[h.rust,this.rustMaterial,"rails",!1],[h.head,this.headMaterial,"rail heads",!1],[h.steel,this.steelMaterial,"catenary masts",!0],[h.wire,this.wireMaterial,"catenary wires",!1]];for(const[p,A,d,O]of u){const g=l.meshOf(p,A);g&&(g.name=`railways ${d}`,g.castShadow=O,g.receiveShadow=!0,this.group.add(g))}}clear(){for(const t of[...this.group.children])this.group.remove(t),t.geometry?.dispose();this.drawn=0,this.laid=[]}lineAt(t,s){let e;for(const{line:n,centre:o}of this.laid)for(let c=0;c<o.length-1;c++){const r=o[c],M=o[c+1],a=M.x-r.x,i=M.z-r.z,h=a*a+i*i,u=h===0?0:Math.max(0,Math.min(1,((t-r.x)*a+(s-r.z)*i)/h)),p=Math.hypot(t-(r.x+a*u),s-(r.z+i*u));p<=l.LINE_REACH_M&&(!e||p<e.distance)&&(e={line:n,distance:p})}return e?.line}mayMeet(t,s,e,n){const o=Math.hypot(s.x,s.z);if(o<1e-6)return this.lineAt(t.x,t.z)!==void 0;const c=s.x/o,r=s.z/o,M=l.LINE_REACH_M;for(const{centre:a}of this.laid)for(let i=0;i<a.length-1;i++){const h=a[i],u=a[i+1];for(const p of[0,.5,1]){const A=h.x+(u.x-h.x)*p,d=h.z+(u.z-h.z)*p,O=(A-t.x)*c+(d-t.z)*r;if(O<0)continue;const g=Math.abs((A-t.x)*r-(d-t.z)*c),_=Math.hypot(u.x-h.x,u.z-h.z)/2;if(g>M+_)continue;if(t.y+s.y*(O/o)<=e(A,d)+n)return!0}}return!1}contactHeightM(t){if(!(t.electrification!=="overhead"||t.kind==="subway"||t.kind==="funicular"))return l.catenaryOf(t).contactM}static catenaryOf(t){return t.kind==="tram"?l.CATENARY.tram:t.highSpeed?l.CATENARY.highSpeed:t.service?l.CATENARY.service:l.CATENARY.rail}dispose(){this.clear();for(const t of[this.ballastMaterial,this.earthMaterial,this.deckMaterial,this.concreteSleepers,this.woodSleepers,this.rustMaterial,this.headMaterial,this.steelMaterial,this.wireMaterial])t.dispose()}static within(t,s){if(!Number.isFinite(s))return!0;const e=s*1.1+100;return t.some((n,o)=>Math.hypot(n.x,n.z)<=e||o>0&&Math.hypot((n.x+t[o-1].x)/2,(n.z+t[o-1].z)/2)<=e)}static altitudeOffset(t,s){const e=[];for(const{line:n,path:o}of t)if(n.level===0)for(const c of o)c.altitudeM!==void 0&&e.push(s(c.x,c.z)-c.altitudeM);if(!(e.length<5))return e.sort((n,o)=>n-o),e[Math.floor(e.length/2)]}layoutOf(t,s){const e=[];for(let c=0;c<s.length-1;c++){const r=s[c],M=s[c+1],a=Math.max(1,Math.ceil(Math.hypot(M.x-r.x,M.z-r.z)/this.stepM));for(let i=0;i<a;i++){const h=i/a,u=r.altitudeM!==void 0&&M.altitudeM!==void 0?r.altitudeM+(M.altitudeM-r.altitudeM)*h:void 0;e.push({x:r.x+(M.x-r.x)*h,z:r.z+(M.z-r.z)*h,altitudeM:u})}}if(e.push(s[s.length-1]),e.length<2)return;const n=[0];for(let c=1;c<e.length;c++)n.push(n[c-1]+Math.hypot(e[c].x-e[c-1].x,e[c].z-e[c-1].z));if(n[n.length-1]<.5)return;const o=e.map((c,r)=>{const M=e[Math.max(0,r-1)],a=e[Math.min(e.length-1,r+1)],i=a.x-M.x,h=a.z-M.z,u=Math.hypot(i,h);return u<1e-6?{x:1,z:0}:{x:i/u,z:h/u}});return{kind:t.kind,...t.highSpeed?{highSpeed:!0}:{},level:t.level,centre:e,along:n,dir:o}}lay(t,s,e,n){const o=t.highSpeed?l.TRACK_SPACING_M.highSpeed:l.TRACK_SPACING_M[t.kind],c=Math.min(8,Math.max(1,t.tracks)),r=Array.from({length:c},(g,_)=>(_-(c-1)/2)*o),M=t.kind==="tram",a=M?0:l.BALLAST_HEIGHT_M,i=l.LIFT_M,h=(g,_,f)=>({x:s.centre[g].x-s.dir[g].z*_,y:s.y[g]+f,z:s.centre[g].z+s.dir[g].x*_}),u=s.centre.map((g,_)=>_);if(!M){const g=l.SLEEPER_LENGTH_M/2+l.BALLAST_SHOULDER_M+(r[r.length-1]??0),_=u.map(x=>h(x,g,a+i)),f=u.map(x=>h(x,-g,a+i));if(n.ballast.strip(_,f),t.level===0){const x=g+a*l.BALLAST_SLOPE;for(const E of[1,-1]){const z=[],v=[];let m=!1;for(const L of u){const C=h(L,E*x,i),S=e(C.x,C.z)+i,T=C.y-S;T<0&&(C.y=Math.min(S,s.y[L]+a-.05+i)),z.push(C);const I=h(L,E*(x+Math.max(0,T)*l.BANK_SLOPE),i);I.y=Math.min(e(I.x,I.z)+i,C.y),C.y-I.y>.02&&(m=!0),v.push(I)}const D=E>0?_:f;E>0?n.ballast.strip(z,D):n.ballast.strip(D,z),m&&(E>0?n.earth.strip(v,z):n.earth.strip(z,v))}}else{const x=-l.DECK_DEPTH_M,E=g+.15,z=u.map(L=>h(L,E,a+i+.1)),v=u.map(L=>h(L,-E,a+i+.1)),m=u.map(L=>h(L,E,x)),D=u.map(L=>h(L,-E,x));n.deck.strip(m,z),n.deck.strip(v,D),n.deck.strip(D,m),n.deck.strip(z,u.map(L=>h(L,g,a+i+.1))),n.deck.strip(u.map(L=>h(L,-g,a+i+.1)),v)}}const p=t.service?n.wood:n.concrete,A=t.gaugeMm/2e3+l.RAIL_HEAD_M/2,d=M?l.TRAM_RAIL_HEIGHT_M:l.RAIL_HEIGHT_M,O=a+i;for(const g of r){if(!M){const _=l.SLEEPER_LENGTH_M/2;p.strip(u.map(f=>h(f,g+_,O+.004)),u.map(f=>h(f,g-_,O+.004)),s.along)}for(const _ of[1,-1]){const f=g+_*A,x=l.RAIL_HEAD_M/2,E=u.map(v=>h(v,f+x,O+d)),z=u.map(v=>h(v,f-x,O+d));n.head.strip(E,z),n.rust.strip(u.map(v=>h(v,f+x,O)),E),n.rust.strip(z,u.map(v=>h(v,f-x,O)))}}t.electrification==="overhead"&&t.kind!=="subway"&&t.kind!=="funicular"&&this.catenary(t,s,r,O+d,h,e,n)}catenary(t,s,e,n,o,c,r){const M=l.catenaryOf(t),a=s.along[s.along.length-1],i=Math.max(1,Math.round(a/M.spanM)),h=a/i,u=Array.from({length:i},(E,z)=>(z+.5)*h),p=n+M.contactM,A=p+M.systemM,d=(M.systemM>0?A:p)+l.MAST_ABOVE_M,O=e[e.length-1],g=e.length>2,_=e.length===1?[1]:[1,-1],f=(E,z,v)=>{let m=0,D=s.along.length-2;for(;m<D;){const T=m+D+1>>1;s.along[T]<=E?m=T:D=T-1}const L=Math.min(1,Math.max(0,(E-s.along[m])/Math.max(1e-6,s.along[m+1]-s.along[m]))),C=o(m,z,v),S=o(m+1,z,v);return{x:C.x+(S.x-C.x)*L,y:C.y+(S.y-C.y)*L,z:C.z+(S.z-C.z)*L}};for(const E of u){const z=f(E,0,p);if(!(t.level===0&&c(z.x,z.z)>z.y)){for(const v of _){const m=v*(O+l.MAST_OFFSET_M),D=f(E,m,0);t.level===0&&(D.y=Math.min(D.y,c(D.x,D.z)));const L=f(E,m,d);if(r.steel.beam(D,L,l.MAST_SIDE_M),g)continue;const S=(_.length===1?e[0]:v*O)-v*.6,T=M.systemM>0?A:p+.3;r.steel.beam(f(E,m,T),f(E,S,T),l.ARM_SIDE_M),r.steel.beam(f(E,m,p-.4),f(E,S,T),l.ARM_SIDE_M)}if(g){const v=O+l.MAST_OFFSET_M;r.steel.beam(f(E,v,d-.2),f(E,-v,d-.2),l.MAST_SIDE_M*.8)}}}const x=[0,...u,a];for(const[E,z]of e.entries()){const v=m=>m===0||m===x.length-1?0:((m+E)%2===0?1:-1)*M.staggerM;for(let m=0;m<x.length-1;m++){const D=x[m],L=x[m+1];if(L-D<.1||(r.wire.beam(f(D,z+v(m),p),f(L,z+v(m+1),p),l.CONTACT_DIAMETER_M,!1),M.systemM<=0))continue;const C=4,S=T=>{const I=m===0?.5+T/2:m===x.length-2?T/2:T;return A-l.MESSENGER_SAG_M*4*I*(1-I)};for(let T=0;T<C;T++){const I=T/C,G=(T+1)/C;r.wire.beam(f(D+(L-D)*I,z,S(I)),f(D+(L-D)*G,z,S(G)),l.MESSENGER_DIAMETER_M,!1)}}}}static meshOf(t,s){if(t.indices.length===0)return;const e=new w;return e.setAttribute("position",new N(new Float32Array(t.positions),3)),t.along.length>0&&e.setAttribute("aAlong",new N(new Float32Array(t.along),1)),e.setIndex(new N(new Uint32Array(t.indices),1)),e.computeVertexNormals(),new U(e,s)}static lambert(t,s){return new k({color:new H(...t),...s?{polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2}:{}})}static pebbled(t){return t.onBeforeCompile=s=>{s.vertexShader=s.vertexShader.replace("#include <common>",`#include <common>
2
+ varying vec3 vBallast;`).replace("#include <begin_vertex>",`#include <begin_vertex>
3
+ vBallast = position;`),s.fragmentShader=s.fragmentShader.replace("#include <common>",`#include <common>
4
+ varying vec3 vBallast;
5
+ float ballastHash(vec2 p) {
6
+ p = fract(p * vec2(127.1, 311.7));
7
+ p += dot(p, p + 34.5);
8
+ return fract(p.x * p.y);
9
+ }
10
+ float ballastNoise(vec2 p) {
11
+ vec2 i = floor(p);
12
+ vec2 f = fract(p);
13
+ f = f * f * (3.0 - 2.0 * f);
14
+ return mix(mix(ballastHash(i), ballastHash(i + vec2(1.0, 0.0)), f.x), mix(ballastHash(i + vec2(0.0, 1.0)), ballastHash(i + vec2(1.0, 1.0)), f.x), f.y);
15
+ }`).replace("#include <map_fragment>",`#include <map_fragment>
16
+ {
17
+ float eye = length(vViewPosition);
18
+ vec2 at = vBallast.xz + vec2(0.0, vBallast.y);
19
+ float stones = (ballastHash(floor(at * 22.0)) - 0.5) * 0.9 * (1.0 - smoothstep(4.0, 18.0, eye))
20
+ + (ballastNoise(at * 6.0) - 0.5) * 0.5 * (1.0 - smoothstep(15.0, 60.0, eye))
21
+ + (ballastNoise(at * 0.7) - 0.5) * 0.35 * (1.0 - smoothstep(80.0, 300.0, eye));
22
+ diffuseColor.rgb *= 1.0 + stones;
23
+ }`)},t.customProgramCacheKey=()=>"rr0-railway-ballast",t}static sleeperMaterial(t){const s=new k({color:new H(1,1,1),polygonOffset:!0,polygonOffsetFactor:-3,polygonOffsetUnits:-3}),e=new H(...t),n=new H(...l.BALLAST_ALBEDO);return s.onBeforeCompile=o=>{o.uniforms.uSleeper={value:e},o.uniforms.uCrib={value:n},o.uniforms.uSpacing={value:l.SLEEPER_SPACING_M},o.uniforms.uDuty={value:l.SLEEPER_WIDTH_M/l.SLEEPER_SPACING_M},o.vertexShader=o.vertexShader.replace("#include <common>",`#include <common>
24
+ attribute float aAlong;
25
+ varying float vAlong;`).replace("#include <begin_vertex>",`#include <begin_vertex>
26
+ vAlong = aAlong;`),o.fragmentShader=o.fragmentShader.replace("#include <common>",`#include <common>
27
+ varying float vAlong;
28
+ uniform vec3 uSleeper;
29
+ uniform vec3 uCrib;
30
+ uniform float uSpacing;
31
+ uniform float uDuty;
32
+ // How much of [0, x] periods is sleeper: the integral of a pulse of width uDuty at the start of each period.
33
+ float sleeperIntegral(float x) {
34
+ return floor(x) * uDuty + min(fract(x), uDuty);
35
+ }`).replace("#include <map_fragment>",`#include <map_fragment>
36
+ {
37
+ float u = vAlong / uSpacing;
38
+ float w = max(fwidth(u), 1e-4);
39
+ float cover = (sleeperIntegral(u + 0.5 * w) - sleeperIntegral(u - 0.5 * w)) / w;
40
+ diffuseColor.rgb *= mix(uCrib, uSleeper, clamp(cover, 0.0, 1.0));
41
+ }`)},s.customProgramCacheKey=()=>"rr0-railway-sleepers",s}}export{l as RailwaySystem};
@@ -1,4 +1,4 @@
1
- import{e as w,_ as u,R as v,aH as P,aL as b,bt as M}from"./rr0-sighting.mjs";import{S as C,P as x,a as T,E as F}from"./ParameterForm-BHITM-mQ.js";import{T as _}from"./TimelineTracks-B7EcGLEf.js";const A=w.catalog({en:()=>u(()=>import("./ReentryParameterTexts_en-BH1tGP5C.js"),[],import.meta.url).then(h=>h.reentryParameterTexts_en),fr:()=>u(()=>import("./ReentryParameterTexts_fr-C8ROK57p.js"),[],import.meta.url).then(h=>h.reentryParameterTexts_fr),es:()=>u(()=>import("./ReentryParameterTexts_es-BDMJ4K1g.js"),[],import.meta.url).then(h=>h.reentryParameterTexts_es),it:()=>u(()=>import("./ReentryParameterTexts_it-CwC8vNTI.js"),[],import.meta.url).then(h=>h.reentryParameterTexts_it)});class a{static NAME="name";static OBJECT="object";static LIGHT="light";static WHEN="when";static placeAt(e,t){const r=v.leadAt(e,t);if(r)return{t,lat:r.lat,lng:r.lng,altitudeKm:r.heightM/1e3};const i=e.track,[n,s]=t<(i[0]?.t??0)?[i[0],i[1]]:[i[i.length-2],i[i.length-1]];if(!n||!s||s.t===n.t){const d=n??s??{lat:0,lng:0,altitudeKm:80};return{t,lat:d.lat,lng:d.lng,altitudeKm:d.altitudeKm}}const l=(t-n.t)/(s.t-n.t);return{t,lat:n.lat+(s.lat-n.lat)*l,lng:n.lng+(s.lng-n.lng)*l,altitudeKm:Math.max(0,n.altitudeKm+(s.altitudeKm-n.altitudeKm)*l)}}static curvePointAt(e,t){return{t,absoluteMagnitude:Math.round(v.absoluteMagnitudeAt(e,t)*10)/10}}static instantsOf(e){return[...e.track.map(t=>t.t),...e.fragments.flatMap(t=>[...t.fromT===void 0?[]:[t.fromT],...t.untilT===void 0?[]:[t.untilT],...(t.lightCurve??[]).map(r=>r.t)])]}static instant(e,t,r,i={}){return{type:"number",key:e,min:-3600,max:36e3,step:.1,unit:"s",scale:.001,label:t,hint:r,...i}}static SET={kind:"reentry",title:"fireballOrReEntry",parameters:[{type:"said",key:"title",label:a.NAME},{type:"text",key:"object.name",group:a.OBJECT,label:"catalogueName",hint:"forAReEntryThePiece"},{type:"text",key:"object.cosparId",group:a.OBJECT,label:"cosparId",placeholder:"t1968013c"},{type:"number",key:"object.norad",min:1,max:999999,step:1,group:a.OBJECT,label:"noradNumber"}]};static PLACE={kind:"reentry-place",title:"pointOfThePath",parameters:[a.instant("t","time","secondsOfTheRecordingNegativeBefore",{required:!0}),{type:"position",key:"lat",secondKey:"lng",saidKey:"saidPosition",native:"geo",step:1,rangeM:2e6,label:"position"},{type:"number",key:"altitudeKm",min:0,max:300,step:.1,unit:"km",required:!0,label:"altitude",hint:"aboveTheEllipsoidAMeteorBegins"}]};static trackEnd(e,t){const r=e?.track;if(r?.length)return t==="first"?r[0].t:r[r.length-1].t}static FRAGMENT={kind:"reentry-fragment",title:"piece",parameters:[{type:"text",key:"id",label:"id",validate:(e,t,r)=>!r?.fragments.some(i=>i!==t&&i.id===e)},{type:"number",key:"absoluteMagnitude",min:-40,max:10,step:.1,required:!0,group:a.LIGHT,label:"absoluteMagnitude",hint:"itsBrightnessSeenFrom100Km"},{type:"colour",key:"color",group:a.LIGHT,fallback:v.DEFAULT_COLOR,label:"colour"},{type:"number",key:"trainS",min:0,max:600,step:.1,unit:"s",group:a.LIGHT,effective:()=>v.DEFAULT_TRAIN_S,label:"train",hint:"howLongAStretchOfIts"},{type:"number",key:"lagS",min:0,max:600,step:.1,unit:"s",group:a.WHEN,effective:()=>0,label:"behindTheLead",hint:"secondsBehindTheLeadingPointAlong"},a.instant("fromT","seenFrom","whenItBreaksOffOrBegins",{group:a.WHEN,effective:(e,t)=>a.trackEnd(t,"first")}),a.instant("untilT","outAt","whenItHasBurnedUpOr",{group:a.WHEN,effective:(e,t)=>a.trackEnd(t,"last")})]};static CURVE_POINT={kind:"reentry-curve-point",title:"pointOfTheLightCurve",parameters:[a.instant("t","time","secondsOfTheRecording",{required:!0}),{type:"number",key:"absoluteMagnitude",min:-40,max:10,step:.1,required:!0,label:"absoluteMagnitude"}]}}const L=w.catalog({en:()=>u(()=>import("./ReentryEditorMessages_en-O-YSmHxv.js"),[],import.meta.url).then(h=>h.reentryEditorMessages_en),fr:()=>u(()=>import("./ReentryEditorMessages_fr-xuC-qZ6M.js"),[],import.meta.url).then(h=>h.reentryEditorMessages_fr),es:()=>u(()=>import("./ReentryEditorMessages_es-CvO9Jwz5.js"),[],import.meta.url).then(h=>h.reentryEditorMessages_es),it:()=>u(()=>import("./ReentryEditorMessages_it-B7vyCX9o.js"),[],import.meta.url).then(h=>h.reentryEditorMessages_it)});class m{constructor(e,t,r){this.container=e,this.host=t,C.attach(e,"reentry-editor-part",m.STYLE),this.language=r,this.ready=this.setLanguage(r)}messages;ready;parameterTexts;languageToken=0;currentId;form;list;timeline;placeForm;placeIndex=0;row="path";fragmentForm;fragmentIndex=0;curveForm;curveIndex=0;language;shown=[];static STYLE='.reentry-editor-part { flex-basis: 100%; min-width: 0; } .reentry-editor-part #reentry-timeline { flex-basis: 100%; min-width: 0; padding: 4px 0; } .reentry-editor-part #reentry-path > .icon-btn, .reentry-editor-part #reentry-curve > .icon-btn { align-self: flex-end; } .reentry-editor-part #reentry-list, .reentry-editor-part #reentry-places, .reentry-editor-part #reentry-fragment-list, .reentry-editor-part #reentry-curve-list { flex-basis: 100%; min-width: 0; } .reentry-editor-part .launch-editor, .reentry-editor-part .launch-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; } .reentry-editor-part .launch-fields { flex-basis: 100%; min-width: 0; } .reentry-editor-part [hidden] { display: none !important; } .reentry-editor-part select { min-width: 0; width: 100%; } .reentry-editor-part .launch-intro { flex-basis: 100%; margin: 0; } .reentry-editor-part .launch-track { flex-basis: 100%; margin: 0; } .reentry-editor-part .launch-parameters { flex-basis: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; } .reentry-editor-part .parameter-group { flex: 1 1 14em; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; align-content: flex-start; } .reentry-editor-part input, .reentry-editor-part select { max-width: 100%; box-sizing: border-box; } .reentry-editor-part input[type="text"] { width: 12em; } .reentry-editor-part input[data-key="title"] { width: 18em; } .reentry-editor-part label { min-width: 0; max-width: 100%; } .reentry-editor-part input.parameter-derived::placeholder { opacity: .65; } .reentry-editor-part .launch-path { flex: 1 1 100%; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; }';async setLanguage(e){const t=++this.languageToken;this.language=e;const[r,i]=await Promise.all([L.load(e),A.load(e)]);t===this.languageToken&&(this.messages=r,this.parameterTexts=i,this.render(),this.sync())}sync(){if(!this.messages)return;const e=this.reentries;this.shown=[...e],e.some(r=>r.id===this.currentId)||(this.currentId=e[0]?.id),this.list?.setItems(e.map(r=>({id:r.id,label:this.labelOf(r)})),this.currentId),this.syncAddState();const t=this.current;this.element("reentry-fields").hidden=t===void 0,t&&(this.syncPlace(!0),this.syncFragments(t,!0),this.form??=new x(this.element("reentry-parameters"),this.language,"reentry.",{said:()=>this.host.said(),writingLanguage:()=>this.host.writingLanguage()}),this.form.show(this.resolved(a.SET),new T(()=>this.current,r=>this.editReentry(i=>{i.object&&(i.object={...i.object}),r(i),i.object&&Object.values(i.object).every(n=>n===void 0||n==="")&&delete i.object})),()=>this.written()))}refresh(){if(!this.messages)return;this.syncAddState();const e=this.reentries;if(e.length===this.shown.length&&e.every((t,r)=>t.id===this.shown[r].id)){this.syncTimeline();return}this.sync()}setTime(e){this.messages&&this.timeline?.setTime(e)}syncAddState(){const e=this.origin()!==void 0;this.list?.setAddState(e,e?void 0:this.messages.addNowhere)}get current(){return this.reentries.find(e=>e.id===this.currentId)}show(e){this.messages&&(this.currentId=e,this.row="path",this.placeIndex=0,this.fragmentIndex=0,this.curveIndex=0,this.sync())}resolved(e){return P.resolve(e,this.parameterTexts)}render(){if(!this.messages)return;const e=this.messages;this.form=void 0,this.container.innerHTML=`<div class="launch-editor">
1
+ import{e as w,_ as u,R as y,aJ as P,aN as b,bv as M}from"./rr0-sighting.mjs";import{S as C,P as x,a as T,E as F}from"./ParameterForm-GKeZmZAL.js";import{T as _}from"./TimelineTracks-BjJwL-DC.js";const A=w.catalog({en:()=>u(()=>import("./ReentryParameterTexts_en-BH1tGP5C.js"),[],import.meta.url).then(h=>h.reentryParameterTexts_en),fr:()=>u(()=>import("./ReentryParameterTexts_fr-C8ROK57p.js"),[],import.meta.url).then(h=>h.reentryParameterTexts_fr),es:()=>u(()=>import("./ReentryParameterTexts_es-BDMJ4K1g.js"),[],import.meta.url).then(h=>h.reentryParameterTexts_es),it:()=>u(()=>import("./ReentryParameterTexts_it-CwC8vNTI.js"),[],import.meta.url).then(h=>h.reentryParameterTexts_it)});class a{static NAME="name";static OBJECT="object";static LIGHT="light";static WHEN="when";static placeAt(e,t){const r=y.leadAt(e,t);if(r)return{t,lat:r.lat,lng:r.lng,altitudeKm:r.heightM/1e3};const i=e.track,[n,s]=t<(i[0]?.t??0)?[i[0],i[1]]:[i[i.length-2],i[i.length-1]];if(!n||!s||s.t===n.t){const d=n??s??{lat:0,lng:0,altitudeKm:80};return{t,lat:d.lat,lng:d.lng,altitudeKm:d.altitudeKm}}const l=(t-n.t)/(s.t-n.t);return{t,lat:n.lat+(s.lat-n.lat)*l,lng:n.lng+(s.lng-n.lng)*l,altitudeKm:Math.max(0,n.altitudeKm+(s.altitudeKm-n.altitudeKm)*l)}}static curvePointAt(e,t){return{t,absoluteMagnitude:Math.round(y.absoluteMagnitudeAt(e,t)*10)/10}}static instantsOf(e){return[...e.track.map(t=>t.t),...e.fragments.flatMap(t=>[...t.fromT===void 0?[]:[t.fromT],...t.untilT===void 0?[]:[t.untilT],...(t.lightCurve??[]).map(r=>r.t)])]}static instant(e,t,r,i={}){return{type:"number",key:e,min:-3600,max:36e3,step:.1,unit:"s",scale:.001,label:t,hint:r,...i}}static SET={kind:"reentry",title:"fireballOrReEntry",parameters:[{type:"said",key:"title",label:a.NAME},{type:"text",key:"object.name",group:a.OBJECT,label:"catalogueName",hint:"forAReEntryThePiece"},{type:"text",key:"object.cosparId",group:a.OBJECT,label:"cosparId",placeholder:"t1968013c"},{type:"number",key:"object.norad",min:1,max:999999,step:1,group:a.OBJECT,label:"noradNumber"}]};static PLACE={kind:"reentry-place",title:"pointOfThePath",parameters:[a.instant("t","time","secondsOfTheRecordingNegativeBefore",{required:!0}),{type:"position",key:"lat",secondKey:"lng",saidKey:"saidPosition",native:"geo",step:1,rangeM:2e6,label:"position"},{type:"number",key:"altitudeKm",min:0,max:300,step:.1,unit:"km",required:!0,label:"altitude",hint:"aboveTheEllipsoidAMeteorBegins"}]};static trackEnd(e,t){const r=e?.track;if(r?.length)return t==="first"?r[0].t:r[r.length-1].t}static FRAGMENT={kind:"reentry-fragment",title:"piece",parameters:[{type:"text",key:"id",label:"id",validate:(e,t,r)=>!r?.fragments.some(i=>i!==t&&i.id===e)},{type:"number",key:"absoluteMagnitude",min:-40,max:10,step:.1,required:!0,group:a.LIGHT,label:"absoluteMagnitude",hint:"itsBrightnessSeenFrom100Km"},{type:"colour",key:"color",group:a.LIGHT,fallback:y.DEFAULT_COLOR,label:"colour"},{type:"number",key:"trainS",min:0,max:600,step:.1,unit:"s",group:a.LIGHT,effective:()=>y.DEFAULT_TRAIN_S,label:"train",hint:"howLongAStretchOfIts"},{type:"number",key:"lagS",min:0,max:600,step:.1,unit:"s",group:a.WHEN,effective:()=>0,label:"behindTheLead",hint:"secondsBehindTheLeadingPointAlong"},a.instant("fromT","seenFrom","whenItBreaksOffOrBegins",{group:a.WHEN,effective:(e,t)=>a.trackEnd(t,"first")}),a.instant("untilT","outAt","whenItHasBurnedUpOr",{group:a.WHEN,effective:(e,t)=>a.trackEnd(t,"last")})]};static CURVE_POINT={kind:"reentry-curve-point",title:"pointOfTheLightCurve",parameters:[a.instant("t","time","secondsOfTheRecording",{required:!0}),{type:"number",key:"absoluteMagnitude",min:-40,max:10,step:.1,required:!0,label:"absoluteMagnitude"}]}}const L=w.catalog({en:()=>u(()=>import("./ReentryEditorMessages_en-O-YSmHxv.js"),[],import.meta.url).then(h=>h.reentryEditorMessages_en),fr:()=>u(()=>import("./ReentryEditorMessages_fr-xuC-qZ6M.js"),[],import.meta.url).then(h=>h.reentryEditorMessages_fr),es:()=>u(()=>import("./ReentryEditorMessages_es-CvO9Jwz5.js"),[],import.meta.url).then(h=>h.reentryEditorMessages_es),it:()=>u(()=>import("./ReentryEditorMessages_it-B7vyCX9o.js"),[],import.meta.url).then(h=>h.reentryEditorMessages_it)});class m{constructor(e,t,r){this.container=e,this.host=t,C.attach(e,"reentry-editor-part",m.STYLE),this.language=r,this.ready=this.setLanguage(r)}messages;ready;parameterTexts;languageToken=0;currentId;form;list;timeline;placeForm;placeIndex=0;row="path";fragmentForm;fragmentIndex=0;curveForm;curveIndex=0;language;shown=[];static STYLE='.reentry-editor-part { flex-basis: 100%; min-width: 0; } .reentry-editor-part #reentry-timeline { flex-basis: 100%; min-width: 0; padding: 4px 0; } .reentry-editor-part #reentry-path > .icon-btn, .reentry-editor-part #reentry-curve > .icon-btn { align-self: flex-end; } .reentry-editor-part #reentry-list, .reentry-editor-part #reentry-places, .reentry-editor-part #reentry-fragment-list, .reentry-editor-part #reentry-curve-list { flex-basis: 100%; min-width: 0; } .reentry-editor-part .launch-editor, .reentry-editor-part .launch-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; } .reentry-editor-part .launch-fields { flex-basis: 100%; min-width: 0; } .reentry-editor-part [hidden] { display: none !important; } .reentry-editor-part select { min-width: 0; width: 100%; } .reentry-editor-part .launch-intro { flex-basis: 100%; margin: 0; } .reentry-editor-part .launch-track { flex-basis: 100%; margin: 0; } .reentry-editor-part .launch-parameters { flex-basis: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; } .reentry-editor-part .parameter-group { flex: 1 1 14em; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; align-content: flex-start; } .reentry-editor-part input, .reentry-editor-part select { max-width: 100%; box-sizing: border-box; } .reentry-editor-part input[type="text"] { width: 12em; } .reentry-editor-part input[data-key="title"] { width: 18em; } .reentry-editor-part label { min-width: 0; max-width: 100%; } .reentry-editor-part input.parameter-derived::placeholder { opacity: .65; } .reentry-editor-part .launch-path { flex: 1 1 100%; min-width: 0; box-sizing: border-box; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: flex-start; }';async setLanguage(e){const t=++this.languageToken;this.language=e;const[r,i]=await Promise.all([L.load(e),A.load(e)]);t===this.languageToken&&(this.messages=r,this.parameterTexts=i,this.render(),this.sync())}sync(){if(!this.messages)return;const e=this.reentries;this.shown=[...e],e.some(r=>r.id===this.currentId)||(this.currentId=e[0]?.id),this.list?.setItems(e.map(r=>({id:r.id,label:this.labelOf(r)})),this.currentId),this.syncAddState();const t=this.current;this.element("reentry-fields").hidden=t===void 0,t&&(this.syncPlace(!0),this.syncFragments(t,!0),this.form??=new x(this.element("reentry-parameters"),this.language,"reentry.",{said:()=>this.host.said(),writingLanguage:()=>this.host.writingLanguage()}),this.form.show(this.resolved(a.SET),new T(()=>this.current,r=>this.editReentry(i=>{i.object&&(i.object={...i.object}),r(i),i.object&&Object.values(i.object).every(n=>n===void 0||n==="")&&delete i.object})),()=>this.written()))}refresh(){if(!this.messages)return;this.syncAddState();const e=this.reentries;if(e.length===this.shown.length&&e.every((t,r)=>t.id===this.shown[r].id)){this.syncTimeline();return}this.sync()}setTime(e){this.messages&&this.timeline?.setTime(e)}syncAddState(){const e=this.origin()!==void 0;this.list?.setAddState(e,e?void 0:this.messages.addNowhere)}get current(){return this.reentries.find(e=>e.id===this.currentId)}show(e){this.messages&&(this.currentId=e,this.row="path",this.placeIndex=0,this.fragmentIndex=0,this.curveIndex=0,this.sync())}resolved(e){return P.resolve(e,this.parameterTexts)}render(){if(!this.messages)return;const e=this.messages;this.form=void 0,this.container.innerHTML=`<div class="launch-editor">
2
2
  <p class="launch-intro">${e.intro}</p>
3
3
  <div id="reentry-list"></div>
4
4
  <div id="reentry-fields" class="launch-fields">
@@ -24,4 +24,4 @@ import{e as w,_ as u,R as v,aH as P,aL as b,bt as M}from"./rr0-sighting.mjs";imp
24
24
  </fieldset>
25
25
  <p class="launch-intro">${e.derivedNote}</p>
26
26
  </div>
27
- </div>`,this.list=new F({header:this.element("reentry-list"),body:this.element("reentry-fields"),ids:{list:"reentry-select",remove:"reentry-delete",add:"reentry-add",kinds:"reentry-add-kind",kind:t=>`reentry-add-${t}`},onSelect:t=>this.show(t),onAdd:t=>this.addReentry(t==="reentry"?"reentry":"fireball"),onRemove:()=>this.deleteCurrent()}),this.list.setLabels({list:e.reentry,remove:e.deleteReentry,add:e.addReentry,empty:e.none}),this.list.setKinds([{value:"fireball",label:e.kindFireball},{value:"reentry",label:e.kindReentry}]),this.timeline=new _(this.element("reentry-timeline"),t=>this.host.seekTo(t),{addKeyframeHere:e.addPointHere,keyframeHere:e.pointHere,zoomHint:e.zoomHint}),this.element("reentry-place-delete").addEventListener("click",()=>this.removePlace()),this.element("reentry-curve-delete").addEventListener("click",()=>this.removeCurvePoint()),this.placeForm=void 0,this.element("reentry-fragment-add").addEventListener("click",()=>this.addFragment()),this.element("reentry-fragment-delete").addEventListener("click",()=>this.removeFragment()),this.fragmentForm=void 0,this.curveForm=void 0}written(){const e=this.current;e&&this.list?.rename(e.id,this.labelOf(e))}syncTimeline(){const e=this.current;if(!this.timeline||!e)return;const t=this.messages,r=e.track[0]?.t??0,i=e.track[e.track.length-1]?.t??0,n={id:"path",label:t.path,color:m.PATH_COLOR,times:e.track.map(c=>c.t),active:this.row==="path",selectedTime:this.row==="path"?e.track[this.placeIndex]?.t:void 0,open:()=>this.selectPlace(this.placeIndex),pressed:(c,o)=>{const p=o===void 0?-1:(this.current?.track??[]).findIndex(g=>g.t===o);this.selectPlace(p>=0?p:this.placeIndex)},move:(c,o)=>this.movePlace(c,o),add:()=>this.addPlaceAt(this.host.currentTime())},s=e.fragments.map((c,o)=>{const p=c.lightCurve??[];return{id:`fragment-${o}`,label:this.fragmentLabel(c,o),color:m.PIECE_COLOR,times:p.map(g=>g.t),spans:[{t:c.fromT??r,until:c.untilT??i,label:""}],active:this.row==="fragment"&&o===this.fragmentIndex,selectedTime:this.row==="fragment"&&o===this.fragmentIndex?p[this.curveIndex]?.t:void 0,open:()=>this.selectFragment(o),pressed:(g,y)=>{const E=y===void 0?-1:(this.current?.fragments[o]?.lightCurve??[]).findIndex(k=>k.t===y);this.selectFragment(o,E>=0?E:void 0)},move:(g,y)=>this.moveCurvePoint(o,g,y),add:()=>this.addCurvePointAt(o,this.host.currentTime())}}),l=a.instantsOf(e),d=Math.min(...l),f=Math.max(...l),I=Math.max(500,(f-d)/10);this.timeline.show([n,...s],this.host.duration(),this.host.currentTime(),{from:d-I,to:f+I})}static PATH_COLOR="#e08a1e";static PIECE_COLOR="#c0581b";static MIN_PLACES=2;syncPlace(e=!1){const t=this.current?.track??[];this.placeIndex=Math.max(0,Math.min(this.placeIndex,t.length-1)),this.element("reentry-place-delete").disabled=t.length<=m.MIN_PLACES,this.placeForm?this.placeForm.sync(e):(this.placeForm=new x(this.element("reentry-place-parameters"),this.language,"reentryPlace."),this.placeForm.show(this.resolved(a.PLACE),new T(()=>this.current?.track[this.placeIndex],r=>this.editPlace(this.placeIndex,r),void 0,this.host.positionPlace?.()),()=>{})),this.syncTimeline()}selectPlace(e){this.row="path",this.placeIndex=e,this.syncDetail(),this.syncPlace(!0)}syncDetail(){this.element("reentry-path").hidden=this.row!=="path",this.element("reentry-fragments").hidden=this.row!=="fragment";const e=this.currentFragment;this.element("reentry-fragment-legend").textContent=e?`${this.messages.fragment} ${this.fragmentLabel(e,this.fragmentIndex)}`:this.messages.fragment}editPlace(e,t){let r;this.editReentry(i=>{r={...i.track[e]},t(r),i.track=i.track.map((n,s)=>s===e?r:n).sort((n,s)=>n.t-s.t)}),r&&(this.placeIndex=this.current?.track.indexOf(r)??0),this.syncPlace()}movePlace(e,t){const r=this.current?.track.findIndex(i=>i.t===e)??-1;r<0||(this.editPlace(r,i=>{i.t=t}),this.syncPlace(!0))}addPlaceAt(e){const t=this.current;if(!t)return;const r=t.track.findIndex(n=>Math.abs(n.t-e)<1);if(r>=0){this.selectPlace(r);return}const i=a.placeAt(t,e);this.editReentry(n=>{n.track=[...n.track,i].sort((s,l)=>s.t-l.t)}),this.selectPlace(this.current?.track.indexOf(i)??0)}removePlace(){if((this.current?.track.length??0)<=m.MIN_PLACES)return;const e=this.placeIndex;this.editReentry(t=>{t.track=t.track.filter((r,i)=>i!==e)}),this.syncPlace(!0)}static MIN_FRAGMENTS=1;fragmentLabel(e,t){return e.id??String(t+1)}syncFragments(e,t=!1){const r=e.fragments;this.fragmentIndex=Math.max(0,Math.min(this.fragmentIndex,r.length-1)),this.element("reentry-fragment-delete").disabled=r.length<=m.MIN_FRAGMENTS,this.syncDetail(),this.fragmentForm?this.fragmentForm.sync(t):(this.fragmentForm=new x(this.element("reentry-fragment-parameters"),this.language,"reentryFragment."),this.fragmentForm.show(this.resolved(a.FRAGMENT),new T(()=>this.currentFragment,i=>this.editFragment(n=>i(n)),()=>this.current),()=>{})),this.syncCurve(t)}selectFragment(e,t){const r=e!==this.fragmentIndex;this.row="fragment",this.fragmentIndex=e,t!==void 0?this.curveIndex=t:r&&(this.curveIndex=0),this.current&&this.syncFragments(this.current,!0)}get currentFragment(){return this.current?.fragments[this.fragmentIndex]}editFragment(e,t=this.fragmentIndex){this.editReentry(r=>{const i={...r.fragments[t]};i.lightCurve&&(i.lightCurve=[...i.lightCurve]),e(i),r.fragments=r.fragments.map((n,s)=>s===t?i:n)}),this.syncDetail(),this.syncTimeline()}addFragment(){const e=this.current;if(!e)return;const t=e.fragments[e.fragments.length-1];let r=e.fragments.length+1;for(;e.fragments.some(n=>n.id===`piece-${r}`);)r++;const i={id:`piece-${r}`,lagS:(t?.lagS??0)+1,absoluteMagnitude:(t?.absoluteMagnitude??-4)+1};this.editReentry(n=>{n.fragments=[...n.fragments,i]}),this.selectFragment((this.current?.fragments.length??1)-1)}removeFragment(){if((this.current?.fragments.length??0)<=m.MIN_FRAGMENTS)return;const e=this.fragmentIndex;this.editReentry(t=>{t.fragments=t.fragments.filter((r,i)=>i!==e)}),this.curveIndex=0,this.selectFragment(Math.min(e,(this.current?.fragments.length??1)-1))}syncCurve(e=!1){const t=this.currentFragment?.lightCurve??[];this.curveIndex=Math.max(0,Math.min(this.curveIndex,t.length-1)),this.element("reentry-curve-empty").hidden=t.length>0,this.element("reentry-curve-parameters").hidden=t.length===0,this.element("reentry-curve-delete").hidden=t.length===0,this.curveForm?this.curveForm.sync(e):(this.curveForm=new x(this.element("reentry-curve-parameters"),this.language,"reentryCurve."),this.curveForm.show(this.resolved(a.CURVE_POINT),new T(()=>this.currentFragment?.lightCurve?.[this.curveIndex],r=>this.editCurvePoint(this.fragmentIndex,this.curveIndex,r)),()=>{})),this.syncTimeline()}editCurvePoint(e,t,r){let i;this.editFragment(n=>{const s=n.lightCurve??[];i={...s[t]},r(i),n.lightCurve=s.map((l,d)=>d===t?i:l).sort((l,d)=>l.t-d.t)},e),i&&(this.curveIndex=this.current?.fragments[e]?.lightCurve?.indexOf(i)??0),this.syncCurve()}moveCurvePoint(e,t,r){const i=this.current?.fragments[e]?.lightCurve?.findIndex(n=>n.t===t)??-1;i<0||(this.fragmentIndex=e,this.editCurvePoint(e,i,n=>{n.t=r}),this.syncFragments(this.current,!0))}addCurvePointAt(e,t){const r=this.current?.fragments[e];if(!r)return;const i=(r.lightCurve??[]).findIndex(s=>Math.abs(s.t-t)<1);if(i>=0){this.selectFragment(e,i);return}const n=a.curvePointAt(r,t);this.editFragment(s=>{s.lightCurve=[...s.lightCurve??[],n].sort((l,d)=>l.t-d.t)},e),this.selectFragment(e,this.current?.fragments[e]?.lightCurve?.indexOf(n)??0)}removeCurvePoint(){if(!this.currentFragment?.lightCurve?.length)return;const e=this.curveIndex;this.editFragment(t=>{const r=(t.lightCurve??[]).filter((i,n)=>n!==e);r.length?t.lightCurve=r:delete t.lightCurve}),this.syncCurve(!0)}editReentry(e){const t=this.current;if(!t)return;const r={...t,track:[...t.track],fragments:[...t.fragments]};e(r),this.writeReentries(this.reentries.map(i=>i===t?r:i)),this.host.changed()}origin(){const e=this.host.sighting(),t=e.event?.place?.[0];if(!(t?.lat===void 0||t.lng===void 0))return{lat:t.lat,lng:t.lng,headingRad:(e.observerTrack?.getInterpolatedPoseAt(0)?.headingDeg??0)*Math.PI/180}}newOf(e){const t=this.origin();if(!t)return;const r=Math.round(this.host.currentTime()),i=Math.max(.05,Math.cos(t.lat*Math.PI/180)),n=(s,l)=>{const d=s*Math.cos(t.headingRad)-l*Math.sin(t.headingRad),f=s*Math.sin(t.headingRad)+l*Math.cos(t.headingRad);return{lat:t.lat+d/111.32,lng:t.lng+f/(111.32*i)}};return e==="fireball"?{track:[{t:r,...n(150,-45),altitudeKm:100},{t:r+3e3,...n(150,45),altitudeKm:60}],fragments:[{id:"main",absoluteMagnitude:-6}]}:{track:[{t:r,...n(300,-225),altitudeKm:82},{t:r+6e4,...n(300,225),altitudeKm:72}],fragments:[{id:"main",absoluteMagnitude:-4},{id:"piece-2",lagS:1.5,absoluteMagnitude:-2.5},{id:"piece-3",lagS:3,absoluteMagnitude:-1.5}]}}addReentry(e){const t=this.newOf(e);if(!t)return;let r=this.reentries.length+1;for(;this.reentries.some(n=>n.id===`${e}-${r}`);)r++;const i={id:`${e}-${r}`,...t};this.writeReentries([...this.reentries,i]),this.host.changed(),this.show(i.id)}deleteCurrent(){const e=this.current;e&&(this.currentId=void 0,this.writeReentries(this.reentries.filter(t=>t!==e)),this.host.changed(),this.sync())}writeReentries(e){const t=this.host.sighting();t.skyEvents=M.written({...t.skyEvents,reentries:e})}labelOf(e){const t=this.host.said().read(e.title)||e.object?.name;return t?`${t} (${e.id})`:e.id}get reentries(){return this.host.sighting().skyEvents?.reentries??[]}element(e){return this.container.querySelector(`#${e}`)}}export{m as ReentryEditor};
27
+ </div>`,this.list=new F({header:this.element("reentry-list"),body:this.element("reentry-fields"),ids:{list:"reentry-select",remove:"reentry-delete",add:"reentry-add",kinds:"reentry-add-kind",kind:t=>`reentry-add-${t}`},onSelect:t=>this.show(t),onAdd:t=>this.addReentry(t==="reentry"?"reentry":"fireball"),onRemove:()=>this.deleteCurrent()}),this.list.setLabels({list:e.reentry,remove:e.deleteReentry,add:e.addReentry,empty:e.none}),this.list.setKinds([{value:"fireball",label:e.kindFireball},{value:"reentry",label:e.kindReentry}]),this.timeline=new _(this.element("reentry-timeline"),t=>this.host.seekTo(t),{addKeyframeHere:e.addPointHere,keyframeHere:e.pointHere,zoomHint:e.zoomHint}),this.element("reentry-place-delete").addEventListener("click",()=>this.removePlace()),this.element("reentry-curve-delete").addEventListener("click",()=>this.removeCurvePoint()),this.placeForm=void 0,this.element("reentry-fragment-add").addEventListener("click",()=>this.addFragment()),this.element("reentry-fragment-delete").addEventListener("click",()=>this.removeFragment()),this.fragmentForm=void 0,this.curveForm=void 0}written(){const e=this.current;e&&this.list?.rename(e.id,this.labelOf(e))}syncTimeline(){const e=this.current;if(!this.timeline||!e)return;const t=this.messages,r=e.track[0]?.t??0,i=e.track[e.track.length-1]?.t??0,n={id:"path",label:t.path,color:m.PATH_COLOR,times:e.track.map(c=>c.t),active:this.row==="path",selectedTime:this.row==="path"?e.track[this.placeIndex]?.t:void 0,open:()=>this.selectPlace(this.placeIndex),pressed:(c,o)=>{const p=o===void 0?-1:(this.current?.track??[]).findIndex(g=>g.t===o);this.selectPlace(p>=0?p:this.placeIndex)},move:(c,o)=>this.movePlace(c,o),add:()=>this.addPlaceAt(this.host.currentTime())},s=e.fragments.map((c,o)=>{const p=c.lightCurve??[];return{id:`fragment-${o}`,label:this.fragmentLabel(c,o),color:m.PIECE_COLOR,times:p.map(g=>g.t),spans:[{t:c.fromT??r,until:c.untilT??i,label:""}],active:this.row==="fragment"&&o===this.fragmentIndex,selectedTime:this.row==="fragment"&&o===this.fragmentIndex?p[this.curveIndex]?.t:void 0,open:()=>this.selectFragment(o),pressed:(g,v)=>{const E=v===void 0?-1:(this.current?.fragments[o]?.lightCurve??[]).findIndex(k=>k.t===v);this.selectFragment(o,E>=0?E:void 0)},move:(g,v)=>this.moveCurvePoint(o,g,v),add:()=>this.addCurvePointAt(o,this.host.currentTime())}}),l=a.instantsOf(e),d=Math.min(...l),f=Math.max(...l),I=Math.max(500,(f-d)/10);this.timeline.show([n,...s],this.host.duration(),this.host.currentTime(),{from:d-I,to:f+I})}static PATH_COLOR="#e08a1e";static PIECE_COLOR="#c0581b";static MIN_PLACES=2;syncPlace(e=!1){const t=this.current?.track??[];this.placeIndex=Math.max(0,Math.min(this.placeIndex,t.length-1)),this.element("reentry-place-delete").disabled=t.length<=m.MIN_PLACES,this.placeForm?this.placeForm.sync(e):(this.placeForm=new x(this.element("reentry-place-parameters"),this.language,"reentryPlace."),this.placeForm.show(this.resolved(a.PLACE),new T(()=>this.current?.track[this.placeIndex],r=>this.editPlace(this.placeIndex,r),void 0,this.host.positionPlace?.()),()=>{})),this.syncTimeline()}selectPlace(e){this.row="path",this.placeIndex=e,this.syncDetail(),this.syncPlace(!0)}syncDetail(){this.element("reentry-path").hidden=this.row!=="path",this.element("reentry-fragments").hidden=this.row!=="fragment";const e=this.currentFragment;this.element("reentry-fragment-legend").textContent=e?`${this.messages.fragment} ${this.fragmentLabel(e,this.fragmentIndex)}`:this.messages.fragment}editPlace(e,t){let r;this.editReentry(i=>{r={...i.track[e]},t(r),i.track=i.track.map((n,s)=>s===e?r:n).sort((n,s)=>n.t-s.t)}),r&&(this.placeIndex=this.current?.track.indexOf(r)??0),this.syncPlace()}movePlace(e,t){const r=this.current?.track.findIndex(i=>i.t===e)??-1;r<0||(this.editPlace(r,i=>{i.t=t}),this.syncPlace(!0))}addPlaceAt(e){const t=this.current;if(!t)return;const r=t.track.findIndex(n=>Math.abs(n.t-e)<1);if(r>=0){this.selectPlace(r);return}const i=a.placeAt(t,e);this.editReentry(n=>{n.track=[...n.track,i].sort((s,l)=>s.t-l.t)}),this.selectPlace(this.current?.track.indexOf(i)??0)}removePlace(){if((this.current?.track.length??0)<=m.MIN_PLACES)return;const e=this.placeIndex;this.editReentry(t=>{t.track=t.track.filter((r,i)=>i!==e)}),this.syncPlace(!0)}static MIN_FRAGMENTS=1;fragmentLabel(e,t){return e.id??String(t+1)}syncFragments(e,t=!1){const r=e.fragments;this.fragmentIndex=Math.max(0,Math.min(this.fragmentIndex,r.length-1)),this.element("reentry-fragment-delete").disabled=r.length<=m.MIN_FRAGMENTS,this.syncDetail(),this.fragmentForm?this.fragmentForm.sync(t):(this.fragmentForm=new x(this.element("reentry-fragment-parameters"),this.language,"reentryFragment."),this.fragmentForm.show(this.resolved(a.FRAGMENT),new T(()=>this.currentFragment,i=>this.editFragment(n=>i(n)),()=>this.current),()=>{})),this.syncCurve(t)}selectFragment(e,t){const r=e!==this.fragmentIndex;this.row="fragment",this.fragmentIndex=e,t!==void 0?this.curveIndex=t:r&&(this.curveIndex=0),this.current&&this.syncFragments(this.current,!0)}get currentFragment(){return this.current?.fragments[this.fragmentIndex]}editFragment(e,t=this.fragmentIndex){this.editReentry(r=>{const i={...r.fragments[t]};i.lightCurve&&(i.lightCurve=[...i.lightCurve]),e(i),r.fragments=r.fragments.map((n,s)=>s===t?i:n)}),this.syncDetail(),this.syncTimeline()}addFragment(){const e=this.current;if(!e)return;const t=e.fragments[e.fragments.length-1];let r=e.fragments.length+1;for(;e.fragments.some(n=>n.id===`piece-${r}`);)r++;const i={id:`piece-${r}`,lagS:(t?.lagS??0)+1,absoluteMagnitude:(t?.absoluteMagnitude??-4)+1};this.editReentry(n=>{n.fragments=[...n.fragments,i]}),this.selectFragment((this.current?.fragments.length??1)-1)}removeFragment(){if((this.current?.fragments.length??0)<=m.MIN_FRAGMENTS)return;const e=this.fragmentIndex;this.editReentry(t=>{t.fragments=t.fragments.filter((r,i)=>i!==e)}),this.curveIndex=0,this.selectFragment(Math.min(e,(this.current?.fragments.length??1)-1))}syncCurve(e=!1){const t=this.currentFragment?.lightCurve??[];this.curveIndex=Math.max(0,Math.min(this.curveIndex,t.length-1)),this.element("reentry-curve-empty").hidden=t.length>0,this.element("reentry-curve-parameters").hidden=t.length===0,this.element("reentry-curve-delete").hidden=t.length===0,this.curveForm?this.curveForm.sync(e):(this.curveForm=new x(this.element("reentry-curve-parameters"),this.language,"reentryCurve."),this.curveForm.show(this.resolved(a.CURVE_POINT),new T(()=>this.currentFragment?.lightCurve?.[this.curveIndex],r=>this.editCurvePoint(this.fragmentIndex,this.curveIndex,r)),()=>{})),this.syncTimeline()}editCurvePoint(e,t,r){let i;this.editFragment(n=>{const s=n.lightCurve??[];i={...s[t]},r(i),n.lightCurve=s.map((l,d)=>d===t?i:l).sort((l,d)=>l.t-d.t)},e),i&&(this.curveIndex=this.current?.fragments[e]?.lightCurve?.indexOf(i)??0),this.syncCurve()}moveCurvePoint(e,t,r){const i=this.current?.fragments[e]?.lightCurve?.findIndex(n=>n.t===t)??-1;i<0||(this.fragmentIndex=e,this.editCurvePoint(e,i,n=>{n.t=r}),this.syncFragments(this.current,!0))}addCurvePointAt(e,t){const r=this.current?.fragments[e];if(!r)return;const i=(r.lightCurve??[]).findIndex(s=>Math.abs(s.t-t)<1);if(i>=0){this.selectFragment(e,i);return}const n=a.curvePointAt(r,t);this.editFragment(s=>{s.lightCurve=[...s.lightCurve??[],n].sort((l,d)=>l.t-d.t)},e),this.selectFragment(e,this.current?.fragments[e]?.lightCurve?.indexOf(n)??0)}removeCurvePoint(){if(!this.currentFragment?.lightCurve?.length)return;const e=this.curveIndex;this.editFragment(t=>{const r=(t.lightCurve??[]).filter((i,n)=>n!==e);r.length?t.lightCurve=r:delete t.lightCurve}),this.syncCurve(!0)}editReentry(e){const t=this.current;if(!t)return;const r={...t,track:[...t.track],fragments:[...t.fragments]};e(r),this.writeReentries(this.reentries.map(i=>i===t?r:i)),this.host.changed()}origin(){const e=this.host.sighting(),t=e.event?.place?.[0];if(!(t?.lat===void 0||t.lng===void 0))return{lat:t.lat,lng:t.lng,headingRad:(e.observerTrack?.getInterpolatedPoseAt(0)?.headingDeg??0)*Math.PI/180}}newOf(e){const t=this.origin();if(!t)return;const r=Math.round(this.host.currentTime()),i=Math.max(.05,Math.cos(t.lat*Math.PI/180)),n=(s,l)=>{const d=s*Math.cos(t.headingRad)-l*Math.sin(t.headingRad),f=s*Math.sin(t.headingRad)+l*Math.cos(t.headingRad);return{lat:t.lat+d/111.32,lng:t.lng+f/(111.32*i)}};return e==="fireball"?{track:[{t:r,...n(150,-45),altitudeKm:100},{t:r+3e3,...n(150,45),altitudeKm:60}],fragments:[{id:"main",absoluteMagnitude:-6}]}:{track:[{t:r,...n(300,-225),altitudeKm:82},{t:r+6e4,...n(300,225),altitudeKm:72}],fragments:[{id:"main",absoluteMagnitude:-4},{id:"piece-2",lagS:1.5,absoluteMagnitude:-2.5},{id:"piece-3",lagS:3,absoluteMagnitude:-1.5}]}}addReentry(e){const t=this.newOf(e);if(!t)return;let r=this.reentries.length+1;for(;this.reentries.some(n=>n.id===`${e}-${r}`);)r++;const i={id:`${e}-${r}`,...t};this.writeReentries([...this.reentries,i]),this.host.changed(),this.show(i.id)}deleteCurrent(){const e=this.current;e&&(this.currentId=void 0,this.writeReentries(this.reentries.filter(t=>t!==e)),this.host.changed(),this.sync())}writeReentries(e){const t=this.host.sighting();t.skyEvents=M.written({...t.skyEvents,reentries:e})}labelOf(e){const t=this.host.said().read(e.title)||e.object?.name;return t?`${t} (${e.id})`:e.id}get reentries(){return this.host.sighting().skyEvents?.reentries??[]}element(e){return this.container.querySelector(`#${e}`)}}export{m as ReentryEditor};
@@ -1 +1 @@
1
- import{G,bA as S,ad as _,E as M,bB as R,N as w,x as F,bu as f,bv as I,a2 as N,C as y,bC as C,bD as H,bE as B,R as L}from"./rr0-sighting.mjs";class h{static RADIUS=840;static MAX_SEGMENTS=1024;static VERTICES_PER_SEGMENT=12;static MIN_HALF_WIDTH_DEG=.1;static BRIGHT_HALF_WIDTH_DEG=.22;static TRAIN_SHARE=.9;static TRAIN_FALLOFF=1.2;object=new G;tiers;trains;positions;colors;shown=0;drawn=[];constructor(){this.object.name="reentries",this.tiers=S.map(i=>{const o=new _(new M,R.material(i.size,!1));return R.track(o),o.frustumCulled=!1,this.object.add(o),o});const s=h.MAX_SEGMENTS*h.VERTICES_PER_SEGMENT;this.positions=new Float32Array(s*3),this.colors=new Float32Array(s*3);const t=new M;t.setAttribute("position",new w(this.positions,3)),t.setAttribute("color",new w(this.colors,3)),t.setDrawRange(0,0),this.trains=new F(t,f.material()),this.trains.frustumCulled=!1,f.track(this.trains),this.object.add(this.trains)}nearest(s,t){let i,o=t;for(const e of this.drawn){const n=e.direction.dot(s);(n>o||i&&n===o&&e.magnitude<i.magnitude)&&(o=n,i=e)}return i}static directionOf(s){const{x:t,y:i,z:o}=I(s.altitudeDeg,s.azimuthDeg,1);return new N(t,i,o)}get count(){return this.shown}set(s,t,i,o){const e=this.tiers.map(()=>[]);let n=0,E=0;const r=new y;this.drawn=[];for(const a of s){const u=i(a.head);if(u<=0)continue;const c=a.magnitude-2.5*Math.log10(u);if(c>t)continue;E++,this.drawn.push({direction:h.directionOf(a.head),view:a,magnitude:c}),r.set(a.color);const d=C(c,t)*a.fade,{x:b,y:A,z:p}=I(a.head.altitudeDeg,a.head.azimuthDeg,h.RADIUS),[l,m,T]=o(a.head,c),z=a.fade,D=Math.max(r.r,r.g,r.b)||1;e[H(d)].push({x:b,y:A,z:p,r:l*r.r*z/D,g:m*r.g*z/D,b:T*r.b*z/D}),n=this.pushTrain(n,a.train,d,r)}this.shown=E,this.tiers.forEach((a,u)=>{const c=e[u],d=new Float32Array(c.length*3),b=new Float32Array(c.length*3);c.forEach((p,l)=>{d.set([p.x,p.y,p.z],l*3),b.set([p.r,p.g,p.b],l*3)}),a.geometry.dispose();const A=new M;A.setAttribute("position",new w(d,3)),A.setAttribute("color",new w(b,3)),a.geometry=A});const g=this.trains.geometry;g.setDrawRange(0,n),g.getAttribute("position").needsUpdate=!0,g.getAttribute("color").needsUpdate=!0}pushTrain(s,t,i,o){const e=t.length-1;for(let n=0;n<e;n++){if(s+h.VERTICES_PER_SEGMENT>h.MAX_SEGMENTS*h.VERTICES_PER_SEGMENT)return s;const E=1-n/e,r=1-(n+1)/e,g=I(t[n].altitudeDeg,t[n].azimuthDeg,h.RADIUS),a=I(t[n+1].altitudeDeg,t[n+1].azimuthDeg,h.RADIUS),u=d=>h.RADIUS*((h.MIN_HALF_WIDTH_DEG+h.BRIGHT_HALF_WIDTH_DEG*i*d)*Math.PI/180),c=d=>h.TRAIN_SHARE*i*d**h.TRAIN_FALLOFF;s=this.pushRibbon(s,g,a,u(E),u(r),c(E),c(r),o)}return s}pushRibbon(s,t,i,o,e,n,E,r){const g={x:i.x-t.x,y:i.y-t.y,z:i.z-t.z};if(Math.hypot(g.x,g.y,g.z)<1e-9)return s;const a=this.normalise(this.cross(this.normalise(t),this.normalise(g)));for(const[u,c]of[[-1,0],[0,1]]){const d=this.across(t,a,o,u),b=this.across(i,a,e,u),A=this.across(t,a,o,c),p=this.across(i,a,e,c),l=(m,T)=>m===0?T:0;s=this.push(s,d,l(u,n),r),s=this.push(s,b,l(u,E),r),s=this.push(s,A,l(c,n),r),s=this.push(s,b,l(u,E),r),s=this.push(s,p,l(c,E),r),s=this.push(s,A,l(c,n),r)}return s}across(s,t,i,o){return{x:s.x+t.x*i*o,y:s.y+t.y*i*o,z:s.z+t.z*i*o}}push(s,t,i,o){const e=s*3;this.positions[e]=t.x,this.positions[e+1]=t.y,this.positions[e+2]=t.z;const n=B.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[e]=n*o.r,this.colors[e+1]=n*o.g,this.colors[e+2]=n*o.b,s+1}cross(s,t){return{x:s.y*t.z-s.z*t.y,y:s.z*t.x-s.x*t.z,z:s.x*t.y-s.y*t.x}}normalise(s){const t=Math.hypot(s.x,s.y,s.z)||1;return{x:s.x/t,y:s.y/t,z:s.z/t}}dispose(){for(const s of this.tiers)s.geometry.dispose(),s.material.dispose();this.trains.geometry.dispose(),this.trains.material.dispose(),this.object.removeFromParent()}}class k{inSky=!0;hiddenFromEye=!0;pieces=new h;get object(){return this.pieces.object}get drawnCount(){return this.pieces.count}update(s,t,i){const o=s.length===0?[]:L.viewsAt(s,t,i.observer);o.length===0&&this.pieces.count===0||(this.pieces.set(o,i.magnitudeLimit,e=>i.cloudTransmission(e),(e,n)=>i.arrivingIlluminance(e,n,1)),i.lightFrom(o.map(e=>({position:e.head,magnitude:e.magnitude}))),i.glareFrom(o.map(e=>({key:`${e.reentryId}:${e.fragmentId}`,position:e.head,magnitude:e.magnitude,fade:e.fade}))))}pick(s,t,i){const o=this.pieces.nearest(t,i.nearestCos);return o&&{id:o.view.reentryId,detail:o}}dispose(){this.pieces.dispose()}}export{k as ReentrySimulation};
1
+ import{G,bC as S,ai as F,$ as M,bD as R,a2 as b,N as _,bw as f,bx as I,z as N,C as y,bE as C,bF as H,bG as L,R as P}from"./rr0-sighting.mjs";class h{static RADIUS=840;static MAX_SEGMENTS=1024;static VERTICES_PER_SEGMENT=12;static MIN_HALF_WIDTH_DEG=.1;static BRIGHT_HALF_WIDTH_DEG=.22;static TRAIN_SHARE=.9;static TRAIN_FALLOFF=1.2;object=new G;tiers;trains;positions;colors;shown=0;drawn=[];constructor(){this.object.name="reentries",this.tiers=S.map(i=>{const o=new F(new M,R.material(i.size,!1));return R.track(o),o.frustumCulled=!1,this.object.add(o),o});const s=h.MAX_SEGMENTS*h.VERTICES_PER_SEGMENT;this.positions=new Float32Array(s*3),this.colors=new Float32Array(s*3);const t=new M;t.setAttribute("position",new b(this.positions,3)),t.setAttribute("color",new b(this.colors,3)),t.setDrawRange(0,0),this.trains=new _(t,f.material()),this.trains.frustumCulled=!1,f.track(this.trains),this.object.add(this.trains)}nearest(s,t){let i,o=t;for(const e of this.drawn){const n=e.direction.dot(s);(n>o||i&&n===o&&e.magnitude<i.magnitude)&&(o=n,i=e)}return i}static directionOf(s){const{x:t,y:i,z:o}=I(s.altitudeDeg,s.azimuthDeg,1);return new N(t,i,o)}get count(){return this.shown}set(s,t,i,o){const e=this.tiers.map(()=>[]);let n=0,E=0;const r=new y;this.drawn=[];for(const a of s){const u=i(a.head);if(u<=0)continue;const c=a.magnitude-2.5*Math.log10(u);if(c>t)continue;E++,this.drawn.push({direction:h.directionOf(a.head),view:a,magnitude:c}),r.set(a.color);const d=C(c,t)*a.fade,{x:w,y:A,z:p}=I(a.head.altitudeDeg,a.head.azimuthDeg,h.RADIUS),[l,m,T]=o(a.head,c),z=a.fade,D=Math.max(r.r,r.g,r.b)||1;e[H(d)].push({x:w,y:A,z:p,r:l*r.r*z/D,g:m*r.g*z/D,b:T*r.b*z/D}),n=this.pushTrain(n,a.train,d,r)}this.shown=E,this.tiers.forEach((a,u)=>{const c=e[u],d=new Float32Array(c.length*3),w=new Float32Array(c.length*3);c.forEach((p,l)=>{d.set([p.x,p.y,p.z],l*3),w.set([p.r,p.g,p.b],l*3)}),a.geometry.dispose();const A=new M;A.setAttribute("position",new b(d,3)),A.setAttribute("color",new b(w,3)),a.geometry=A});const g=this.trains.geometry;g.setDrawRange(0,n),g.getAttribute("position").needsUpdate=!0,g.getAttribute("color").needsUpdate=!0}pushTrain(s,t,i,o){const e=t.length-1;for(let n=0;n<e;n++){if(s+h.VERTICES_PER_SEGMENT>h.MAX_SEGMENTS*h.VERTICES_PER_SEGMENT)return s;const E=1-n/e,r=1-(n+1)/e,g=I(t[n].altitudeDeg,t[n].azimuthDeg,h.RADIUS),a=I(t[n+1].altitudeDeg,t[n+1].azimuthDeg,h.RADIUS),u=d=>h.RADIUS*((h.MIN_HALF_WIDTH_DEG+h.BRIGHT_HALF_WIDTH_DEG*i*d)*Math.PI/180),c=d=>h.TRAIN_SHARE*i*d**h.TRAIN_FALLOFF;s=this.pushRibbon(s,g,a,u(E),u(r),c(E),c(r),o)}return s}pushRibbon(s,t,i,o,e,n,E,r){const g={x:i.x-t.x,y:i.y-t.y,z:i.z-t.z};if(Math.hypot(g.x,g.y,g.z)<1e-9)return s;const a=this.normalise(this.cross(this.normalise(t),this.normalise(g)));for(const[u,c]of[[-1,0],[0,1]]){const d=this.across(t,a,o,u),w=this.across(i,a,e,u),A=this.across(t,a,o,c),p=this.across(i,a,e,c),l=(m,T)=>m===0?T:0;s=this.push(s,d,l(u,n),r),s=this.push(s,w,l(u,E),r),s=this.push(s,A,l(c,n),r),s=this.push(s,w,l(u,E),r),s=this.push(s,p,l(c,E),r),s=this.push(s,A,l(c,n),r)}return s}across(s,t,i,o){return{x:s.x+t.x*i*o,y:s.y+t.y*i*o,z:s.z+t.z*i*o}}push(s,t,i,o){const e=s*3;this.positions[e]=t.x,this.positions[e+1]=t.y,this.positions[e+2]=t.z;const n=L.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[e]=n*o.r,this.colors[e+1]=n*o.g,this.colors[e+2]=n*o.b,s+1}cross(s,t){return{x:s.y*t.z-s.z*t.y,y:s.z*t.x-s.x*t.z,z:s.x*t.y-s.y*t.x}}normalise(s){const t=Math.hypot(s.x,s.y,s.z)||1;return{x:s.x/t,y:s.y/t,z:s.z/t}}dispose(){for(const s of this.tiers)s.geometry.dispose(),s.material.dispose();this.trains.geometry.dispose(),this.trains.material.dispose(),this.object.removeFromParent()}}class x{inSky=!0;hiddenFromEye=!0;pieces=new h;get object(){return this.pieces.object}get drawnCount(){return this.pieces.count}update(s,t,i){const o=s.length===0?[]:P.viewsAt(s,t,i.observer);o.length===0&&this.pieces.count===0||(this.pieces.set(o,i.magnitudeLimit,e=>i.cloudTransmission(e),(e,n)=>i.arrivingIlluminance(e,n,1)),i.lightFrom(o.map(e=>({position:e.head,magnitude:e.magnitude}))),i.glareFrom(o.map(e=>({key:`${e.reentryId}:${e.fragmentId}`,position:e.head,magnitude:e.magnitude,fade:e.fade}))))}pick(s,t,i){const o=this.pieces.nearest(t,i.nearestCos);return o&&{id:o.view.reentryId,detail:o}}dispose(){this.pieces.dispose()}}export{x as ReentrySimulation};
@@ -0,0 +1 @@
1
+ import{m as D,aw as A,ax as b,ay as M,Y as p,az as O,N as I,am as x,aA as T,aB as S,aC as N,aD as F}from"./rr0-sighting.mjs";class h{static SEEK_BEYOND_S=.25;static SAME_FRAME_S=1/60;static CATCH_UP_SHARE=.1;static MIN_RATE=.0625;static MAX_RATE=16;static rollOfPicture(t){return t&&-t}static kindOfSource(t){if(t.type?.startsWith("video/"))return"video";if(t.type?.startsWith("image/"))return"photo";const i=t.url??"";if(i.startsWith("data:video/")||/\.(mp4|m4v|webm|ogv|mov)(?:[?#].*)?$/i.test(i))return"video";if(i.startsWith("data:image/")||/\.(jpe?g|png|gif|webp|avif)(?:[?#].*)?$/i.test(i))return"photo"}static mediaSecondsAt(t,i,s,a){const e=t.video?.fromS??0,o=t.video?.toS??a??Number.POSITIVE_INFINITY,n=i-(t.t??0);if(n<0)return;const r=e+n/(h.positive(s)*1e3)*h.rateOf(t);return r<=o?r:void 0}static rateOf(t){return h.positive(t.video?.rate??1)}static registrationAt(t,i){const s=t.registration,a=t.registrationTrack;if(!a||a.length===0)return s;let e=a.findIndex(E=>E.t>i);e===-1&&(e=a.length);const o=a[Math.max(e-1,0)],n=a[Math.min(e,a.length-1)],r=n.t>o.t?Math.min(Math.max((i-o.t)/(n.t-o.t),0),1):0,c=((n.headingDeg-o.headingDeg)%360+540)%360-180,f=o.rollDeg??0,y=n.rollDeg??0,v=f+(y-f)*r,w=o.fovDeg??s.fovDeg;return{headingDeg:((o.headingDeg+c*r)%360+360)%360,pitchDeg:o.pitchDeg+(n.pitchDeg-o.pitchDeg)*r,rollDeg:v===0?void 0:v,fovDeg:w+((n.fovDeg??s.fovDeg)-w)*r}}static keyIndexAt(t,i){return(t.registrationTrack??[]).findIndex(s=>Math.abs(s.t-i)<20)}static withKey(t,i,s){const a={t:i,...s},e=h.keyIndexAt(t,i),n=[...(t.registrationTrack??[]).filter((r,c)=>c!==e),e>=0?{...a,t:t.registrationTrack[e].t}:a].sort((r,c)=>r.t-c.t);return{...t,registrationTrack:n,registration:h.plainOf(n[0],t.registration)}}static withoutKey(t,i){const s=h.keyIndexAt(t,i);if(s<0)return t;const a=t.registrationTrack.filter((e,o)=>o!==s);return a.length===0?{...t,registrationTrack:void 0}:{...t,registrationTrack:a,registration:h.plainOf(a[0],t.registration)}}static plainOf(t,i){return{headingDeg:t.headingDeg,pitchDeg:t.pitchDeg,rollDeg:t.rollDeg,fovDeg:t.fovDeg??i.fovDeg}}static command(t,i,s,a){const e=Math.min(Math.max(a,h.MIN_RATE),h.MAX_RATE),o=i-t;if(!s)return{seekS:Math.abs(o)>h.SAME_FRAME_S?i:void 0,play:!1,rate:e};if(Math.abs(o)>h.SEEK_BEYOND_S)return{seekS:i,play:!0,rate:e};const n=Math.min(Math.max(o/h.SEEK_BEYOND_S,-1),1)*h.CATCH_UP_SHARE;return{play:!0,rate:Math.min(Math.max(e*(1+n),h.MIN_RATE),h.MAX_RATE)}}static positive(t){return t>0?t:1}}class u extends Error{constructor(t,i){super(`${t}: ${i.kind==="status"?i.status:i.kind}`),this.src=t,this.failure=i}}class g{static async blob(t){let i;try{i=await fetch(t)}catch{throw new u(t,await g.whyUnread(t))}if(!i.ok)throw new u(t,{kind:"status",status:i.status});const s=await i.blob();if(s.type&&!s.type.startsWith("image/"))throw new u(t,{kind:"notPicture"});return s}static failureOf(t){return t instanceof u?t.failure:{kind:"notPicture"}}static async whyVideoUnread(t){if(t.startsWith("data:")||t.startsWith("blob:"))return{kind:"notVideo"};let i;try{i=await fetch(t,{method:"HEAD"})}catch{return g.whyUnread(t)}return i.ok?{kind:"notVideo"}:{kind:"status",status:i.status}}static async whyUnread(t){try{return await fetch(t,{mode:"no-cors"}),{kind:"notShared"}}catch{return{kind:"unreachable"}}}}const k=3,m=800,l=Math.PI/180;class d{constructor(t,i,s=d.fetchImage,a=d.openVideo){this.scene=t,this.onImageLoaded=i,this.loadImage=s,this.loadVideo=a}meshes=new Map;signatures=new Map;images=new Map;loading=new Map;failed=new Map;references=[];views=new Map;shown=!0;observerAt;clock={t:0,playing:!1,timeScale:1};static PRESENT_WITHIN_M=2;static GONE_BEYOND_M=20;static presenceAt(t,i){if(!t.from||!i)return 1;const s=D(i.lat,i.lng,t.from.lat,t.from.lng),e=(Math.hypot(s.x,s.z)-d.PRESENT_WITHIN_M)/(d.GONE_BEYOND_M-d.PRESENT_WITHIN_M),o=Math.min(Math.max(e,0),1);return 1-o*o*(3-2*o)}set(t,i=this.views,s){this.references=t,this.observerAt=s,this.views=i;const a=new Set(t.map(e=>e.id));for(const[e,o]of this.meshes)a.has(e)||(this.dispose(o),this.meshes.delete(e),this.signatures.delete(e));for(const[e,o]of this.images){const n=t.find(c=>c.id===e);if(n&&n.src===o.texture.userData.src&&n.kind==="video"==(o.video!==void 0))continue;d.release(o),this.images.delete(e);const r=this.meshes.get(e);r&&(this.dispose(r),this.meshes.delete(e),this.signatures.delete(e))}for(const e of t){const o=this.images.get(e.id);if(!o){this.load(e);continue}this.build(e,o)}this.follow()}setTime(t){this.clock=t,this.follow()}setShown(t){this.shown=t;for(const i of this.meshes.values())i.visible=t&&this.opacityOf(i.userData.id)>0}setView(t,i){this.views.set(t,i);const s=this.meshes.get(t);s&&this.applyOpacity(s,t)}layer=k;get any(){for(const t of this.meshes.values())if(t.visible)return!0;return!1}place(t){const i=this.held;i&&t.getWorldQuaternion(this.cameraTurn);for(const s of this.meshes.values()){if(!s.visible)continue;s.position.copy(t.position);const a=i?.get(s);a&&s.quaternion.copy(this.cameraTurn).multiply(a),s.updateMatrixWorld()}}hold(t){t.getWorldQuaternion(this.cameraTurn);const i=this.cameraTurn.clone().invert();this.held=new Map([...this.meshes.values()].map(s=>[s,i.clone().multiply(s.quaternion)])),this.registered=new Map([...this.meshes.values()].map(s=>[s,s.quaternion.clone()]))}release(){if(this.held){for(const[t,i]of this.registered??[])t.quaternion.copy(i);this.held=void 0,this.registered=void 0}}registered;held;cameraTurn=new A;get furthestM(){return this.meshes.size>0?m:0}directionOfPixel(t,i,s,a){const e=this.images.get(t.id),o=e?e.width/e.height:1,n=h.registrationAt(t,this.clock.t),r=Math.tan(n.fovDeg/2*l),c=r*o;return a.set((i*2-1)*c,(1-s*2)*r,-1).normalize(),a.applyQuaternion(d.orientation(n))}aspectOf(t){const i=this.images.get(t);return i?i.width/i.height:void 0}failureOf(t){return this.failed.get(t)}follow(){for(const t of this.references){const i=this.meshes.get(t.id),s=this.images.get(t.id)?.video;s&&this.sync(t,s),i&&(t.registrationTrack?.length&&d.point(i,t,h.registrationAt(t,this.clock.t)),t.kind==="video"&&this.applyOpacity(i,t.id))}}sync(t,i){const s=h.mediaSecondsAt(t,this.clock.t,this.clock.timeScale,Number.isFinite(i.duration)?i.duration:void 0);if(s===void 0){i.paused||i.pause();return}const a=h.command(i.currentTime,s,this.clock.playing,h.rateOf(t));i.playbackRate=a.rate,a.seekS!==void 0&&!i.seeking&&(i.currentTime=a.seekS),a.play&&i.paused&&i.play().catch(()=>{}),!a.play&&!i.paused&&i.pause()}load(t){const i=t.src;if(this.loading.has(t.id)||this.failed.has(i))return;const s=t.kind==="video",e=(s?this.loadVideo(i,()=>this.onVideoFrame()):this.loadImage(i)).then(o=>{this.loading.delete(t.id);const n=this.references.find(r=>r.id===t.id);if(!n||n.src!==i||n.kind==="video"!==s){d.release(o);return}o.texture.userData.src=i,this.images.set(t.id,o),this.build(n,o),this.follow(),this.onImageLoaded()},o=>{this.loading.delete(t.id),this.failed.set(i,g.failureOf(o)),this.onImageLoaded()});this.loading.set(t.id,e)}onVideoFrame(){this.follow(),this.onFrame?.()}onFrame;static openVideo(t,i){return new Promise((s,a)=>{const e=document.createElement("video");e.crossOrigin="anonymous",e.muted=!0,e.playsInline=!0,e.preload="auto",e.addEventListener("loadeddata",()=>{const o=new b(e);o.colorSpace=M,o.minFilter=p,o.magFilter=p,o.generateMipmaps=!1,e.addEventListener("seeked",i);const n=()=>{e.paused&&i(),e.src&&e.requestVideoFrameCallback(n)};"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(n),s({texture:o,width:e.videoWidth,height:e.videoHeight,video:e})},{once:!0}),e.addEventListener("error",()=>{g.whyVideoUnread(t).then(o=>a(new u(t,o)))},{once:!0}),e.src=t})}static release(t){t.texture.dispose();const i=t.video;i&&(i.pause(),i.removeAttribute?.("src"),i.load?.())}static async fetchImage(t){const i=await g.blob(t),s=await createImageBitmap(i,{imageOrientation:"flipY"}).catch(()=>{throw new u(t,{kind:"notPicture"})}),a=new O(s);return a.flipY=!1,a.colorSpace=M,a.minFilter=p,a.magFilter=p,a.generateMipmaps=!1,a.needsUpdate=!0,{texture:a,width:s.width,height:s.height}}build(t,i){const s=d.signatureOf(t,i);let a=this.meshes.get(t.id);if(a&&this.signatures.get(t.id)===s){this.applyOpacity(a,t.id);return}a&&(this.dispose(a),this.meshes.delete(t.id)),a=new I(d.geometryOf(t,i),new x({map:i.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),t.kind==="panorama"&&(a.material.side=T),a.frustumCulled=!1,a.layers.set(k),a.userData.id=t.id,d.point(a,t,h.registrationAt(t,this.clock.t)),this.scene.add(a),this.meshes.set(t.id,a),this.signatures.set(t.id,s),this.applyOpacity(a,t.id)}static geometryOf(t,i){if(t.kind==="panorama"){const o=new S(m,64,32,Math.PI/2,Math.PI*2),n=o.attributes.uv;for(let r=0;r<n.count;r++)n.setX(r,1-n.getX(r));return n.needsUpdate=!0,o}const s=2*m*Math.tan(t.registration.fovDeg/2*l),a=s*(i.width/Math.max(i.height,1)),e=new N(a,s);return e.translate(0,0,-m),e}static orientation({headingDeg:t,pitchDeg:i,rollDeg:s}){const a=new F;return a.rotation.set(i*l,-t*l,-(s??0)*l,"YXZ"),a.quaternion}static point(t,i,s){if(t.quaternion.copy(d.orientation(s)),i.kind==="panorama")return;const a=Math.tan(s.fovDeg/2*l)/Math.tan(i.registration.fovDeg/2*l);t.scale.set(a,a,1)}inTime(t){if(t.kind!=="video")return!0;const i=this.images.get(t.id)?.video?.duration;return h.mediaSecondsAt(t,this.clock.t,this.clock.timeScale,i!==void 0&&Number.isFinite(i)?i:void 0)!==void 0}opacityOf(t){const i=this.references.find(e=>e.id===t);if(i&&!this.inTime(i))return 0;const s=this.views.get(t),a=i?d.presenceAt(i,this.observerAt):1;return(s?.opacity??i?.opacity??0)*a}applyOpacity(t,i){const s=this.opacityOf(i);t.material.opacity=s,t.visible=this.shown&&s>0}static signatureOf(t,i){const{headingDeg:s,pitchDeg:a,rollDeg:e,fovDeg:o}=t.registration;return[t.kind,t.src,i.width,i.height,s,a,e??0,o].join("|")}dispose(t){this.scene.remove(t),t.geometry.dispose(),t.material.dispose()}disposeAll(){for(const t of this.meshes.values())this.dispose(t);this.meshes.clear(),this.signatures.clear();for(const t of this.images.values())d.release(t);this.images.clear()}}export{k as REFERENCE_LAYER,d as ReferenceSystem};
@@ -1,4 +1,4 @@
1
- import{aL as u}from"./rr0-sighting.mjs";class p{constructor(t,i,e){this.host=t,this.seek=i,this.messages=e,t.classList.add("timeline-tracks"),this.scroll=document.createElement("div"),this.scroll.className="track-scroll",this.scroll.hidden=!0,this.thumb=document.createElement("div"),this.thumb.className="thumb",this.scroll.append(this.thumb),this.scroll.addEventListener("pointerdown",s=>this.dragWindow(s)),t.addEventListener("wheel",s=>this.wheel(s),{passive:!1})}static CSS=`
1
+ import{aN as u}from"./rr0-sighting.mjs";class p{constructor(t,i,e){this.host=t,this.seek=i,this.messages=e,t.classList.add("timeline-tracks"),this.scroll=document.createElement("div"),this.scroll.className="track-scroll",this.scroll.hidden=!0,this.thumb=document.createElement("div"),this.thumb.className="thumb",this.scroll.append(this.thumb),this.scroll.addEventListener("pointerdown",s=>this.dragWindow(s)),t.addEventListener("wheel",s=>this.wheel(s),{passive:!1})}static CSS=`
2
2
  .timeline-tracks { display: grid; grid-template-columns: max-content minmax(0, 1fr) auto; align-items: center; gap: 6px 10px; padding: 10px 14px 12px; }
3
3
  .timeline-tracks[hidden] { display: none; }
4
4
  .track-name { display: inline-block; justify-self: start; min-height: 0; padding: 2px 0; border: 0; background: none; color: var(--ink-dim, inherit); font: 600 12px/1.3 var(--sans, inherit); cursor: pointer; }
@@ -1,4 +1,4 @@
1
- import{X as ee,J as F,Y as G,Z as M,$ as te,a0 as j,a1 as J,a2 as E,a3 as ie,a4 as O,a5 as K,y as ne,a6 as I,x as se,a7 as B,a8 as oe,a9 as ae,aa as re,G as le,C as ce,ab as de,E as fe,ac as ue,ad as pe,ae as he,af as me,ag as V,m as ge}from"./rr0-sighting.mjs";const k=new j,P=new E;class Y extends ee{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],n=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],i=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(i),this.setAttribute("position",new F(e,3)),this.setAttribute("uv",new F(n,2))}applyMatrix4(e){const n=this.attributes.instanceStart,i=this.attributes.instanceEnd;return n!==void 0&&(n.applyMatrix4(e),i.applyMatrix4(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const i=new G(n,6,1);return this.setAttribute("instanceStart",new M(i,3,0)),this.setAttribute("instanceEnd",new M(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const i=new G(n,6,1);return this.setAttribute("instanceColorStart",new M(i,3,0)),this.setAttribute("instanceColorEnd",new M(i,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new te(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new j);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),k.setFromBufferAttribute(n),this.boundingBox.union(k))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new J),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let t=0;for(let o=0,l=e.count;o<l;o++)P.fromBufferAttribute(e,o),t=Math.max(t,i.distanceToSquared(P)),P.fromBufferAttribute(n,o),t=Math.max(t,i.distanceToSquared(P));this.boundingSphere.radius=Math.sqrt(t),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}I.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new ne},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};O.line={uniforms:K.merge([I.common,I.fog,I.line]),vertexShader:`
1
+ import{a4 as ee,a0 as F,a5 as G,a6 as M,a7 as te,a8 as j,a9 as J,z as E,aa as ie,ab as O,ac as Z,K as ne,ad as I,N as se,J as B,ae as oe,x as ae,af as re,G as le,C as ce,ag as de,$ as fe,ah as ue,ai as pe,aj as he,ak as me,al as V,m as ge}from"./rr0-sighting.mjs";const k=new j,P=new E;class Q extends ee{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],n=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],i=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(i),this.setAttribute("position",new F(e,3)),this.setAttribute("uv",new F(n,2))}applyMatrix4(e){const n=this.attributes.instanceStart,i=this.attributes.instanceEnd;return n!==void 0&&(n.applyMatrix4(e),i.applyMatrix4(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const i=new G(n,6,1);return this.setAttribute("instanceStart",new M(i,3,0)),this.setAttribute("instanceEnd",new M(i,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const i=new G(n,6,1);return this.setAttribute("instanceColorStart",new M(i,3,0)),this.setAttribute("instanceColorEnd",new M(i,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new te(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new j);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),k.setFromBufferAttribute(n),this.boundingBox.union(k))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new J),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let t=0;for(let o=0,l=e.count;o<l;o++)P.fromBufferAttribute(e,o),t=Math.max(t,i.distanceToSquared(P)),P.fromBufferAttribute(n,o),t=Math.max(t,i.distanceToSquared(P));this.boundingSphere.radius=Math.sqrt(t),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}}I.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new ne},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};O.line={uniforms:Z.merge([I.common,I.fog,I.line]),vertexShader:`
2
2
  #include <common>
3
3
  #include <color_pars_vertex>
4
4
  #include <fog_pars_vertex>
@@ -390,4 +390,4 @@ import{X as ee,J as F,Y as G,Z as M,$ as te,a0 as j,a1 as J,a2 as E,a3 as ie,a4
390
390
  #include <premultiplied_alpha_fragment>
391
391
 
392
392
  }
393
- `};class N extends ie{constructor(e){super({type:"LineMaterial",uniforms:K.clone(O.line.uniforms),vertexShader:O.line.vertexShader,fragmentShader:O.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0!==this.worldUnits&&(this.needsUpdate=!0),e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const H=new B,X=new E,q=new E,f=new B,u=new B,x=new B,W=new E,R=new ae,p=new oe,Z=new E,T=new j,C=new J,S=new B;let b,z;function $(h,e,n){return S.set(0,0,-e,1).applyMatrix4(h.projectionMatrix),S.multiplyScalar(1/S.w),S.x=z/n.width,S.y=z/n.height,S.applyMatrix4(h.projectionMatrixInverse),S.multiplyScalar(1/S.w),Math.abs(Math.max(S.x,S.y))}function ve(h,e){const n=h.matrixWorld,i=h.geometry,t=i.attributes.instanceStart,o=i.attributes.instanceEnd,l=Math.min(i.instanceCount,t.count);for(let s=0,a=l;s<a;s++){p.start.fromBufferAttribute(t,s),p.end.fromBufferAttribute(o,s),p.applyMatrix4(n);const d=new E,m=new E;b.distanceSqToSegment(p.start,p.end,m,d),m.distanceTo(d)<z*.5&&e.push({point:m,pointOnLine:d,distance:b.origin.distanceTo(m),object:h,face:null,faceIndex:s,uv:null,uv1:null})}}function ye(h,e,n){const i=e.projectionMatrix,o=h.material.resolution,l=h.matrixWorld,s=h.geometry,a=s.attributes.instanceStart,d=s.attributes.instanceEnd,m=Math.min(s.instanceCount,a.count),c=-e.near;b.at(1,x),x.w=1,x.applyMatrix4(e.matrixWorldInverse),x.applyMatrix4(i),x.multiplyScalar(1/x.w),x.x*=o.x/2,x.y*=o.y/2,x.z=0,W.copy(x),R.multiplyMatrices(e.matrixWorldInverse,l);for(let g=0,r=m;g<r;g++){if(f.fromBufferAttribute(a,g),u.fromBufferAttribute(d,g),f.w=1,u.w=1,f.applyMatrix4(R),u.applyMatrix4(R),f.z>c&&u.z>c)continue;if(f.z>c){const _=f.z-u.z,w=(f.z-c)/_;f.lerp(u,w)}else if(u.z>c){const _=u.z-f.z,w=(u.z-c)/_;u.lerp(f,w)}f.applyMatrix4(i),u.applyMatrix4(i),f.multiplyScalar(1/f.w),u.multiplyScalar(1/u.w),f.x*=o.x/2,f.y*=o.y/2,u.x*=o.x/2,u.y*=o.y/2,p.start.copy(f),p.start.z=0,p.end.copy(u),p.end.z=0;const y=p.closestPointToPointParameter(W,!0);p.at(y,Z);const L=re.lerp(f.z,u.z,y),U=L>=-1&&L<=1,D=W.distanceTo(Z)<z*.5;if(U&&D){p.start.fromBufferAttribute(a,g),p.end.fromBufferAttribute(d,g),p.start.applyMatrix4(l),p.end.applyMatrix4(l);const _=new E,w=new E;b.distanceSqToSegment(p.start,p.end,w,_),n.push({point:w,pointOnLine:_,distance:b.origin.distanceTo(w),object:h,face:null,faceIndex:g,uv:null,uv1:null})}}}class we extends se{constructor(e=new Y,n=new N({color:Math.random()*16777215})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,i=e.attributes.instanceEnd,t=new Float32Array(2*n.count);for(let l=0,s=0,a=n.count;l<a;l++,s+=2)X.fromBufferAttribute(n,l),q.fromBufferAttribute(i,l),t[s]=s===0?0:t[s-1],t[s+1]=t[s]+X.distanceTo(q);const o=new G(t,2,1);return e.setAttribute("instanceDistanceStart",new M(o,1,0)),e.setAttribute("instanceDistanceEnd",new M(o,1,1)),this}raycast(e,n){const i=this.material.worldUnits,t=e.camera;if(t===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'),i===!1&&(this.material.resolution.x===0||this.material.resolution.y===0))return;const o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;b=e.ray;const l=this.matrixWorld,s=this.geometry,a=this.material;z=a.linewidth+o,s.boundingSphere===null&&s.computeBoundingSphere(),C.copy(s.boundingSphere).applyMatrix4(l);let d;if(i)d=z*.5;else{const c=Math.max(t.near,C.distanceToPoint(b.origin));d=$(t,c,a.resolution)}if(C.radius+=d,b.intersectsSphere(C)===!1)return;s.boundingBox===null&&s.computeBoundingBox(),T.copy(s.boundingBox).applyMatrix4(l);let m;if(i)m=z*.5;else{const c=Math.max(t.near,T.distanceToPoint(b.origin));m=$(t,c,a.resolution)}T.expandByScalar(m),b.intersectsBox(T)!==!1&&(i?ve(this,n):ye(this,t,n))}onBeforeRender(e){const n=this.material.uniforms;n&&n.resolution&&(e.getViewport(H),this.material.uniforms.resolution.value.set(H.z,H.w))}}class Q extends Y{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const n=e.length-3,i=new Float32Array(2*n);for(let t=0;t<n;t+=3)i[2*t]=e[t],i[2*t+1]=e[t+1],i[2*t+2]=e[t+2],i[2*t+3]=e[t+3],i[2*t+4]=e[t+4],i[2*t+5]=e[t+5];return super.setPositions(i),this}setColors(e){const n=e.length-3,i=new Float32Array(2*n);for(let t=0;t<n;t+=3)i[2*t]=e[t],i[2*t+1]=e[t+1],i[2*t+2]=e[t+2],i[2*t+3]=e[t+3],i[2*t+4]=e[t+4],i[2*t+5]=e[t+5];return super.setColors(i),this}setFromPoints(e){const n=e.length-1,i=new Float32Array(6*n);for(let t=0;t<n;t++)i[6*t]=e[t].x,i[6*t+1]=e[t].y,i[6*t+2]=e[t].z||0,i[6*t+3]=e[t+1].x,i[6*t+4]=e[t+1].y,i[6*t+5]=e[t+1].z||0;return super.setPositions(i),this}fromLine(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}}class xe extends we{constructor(e=new Q,n=new N({color:Math.random()*16777215})){super(e,n),this.isLine2=!0,this.type="Line2"}}class A{constructor(e){this.layer=e,this.group.name="traces"}static LINE_WIDTH_PX=2.5;static MARKER_SIZE_PX=9;static LABEL_HEIGHT_PX=15;static STEP_M=15;static LIFT_M=.3;group=new le;materials=[];pointsMaterials=[];labels=[];viewportHeightPx=720;fovDeg=60;set(e,n,i,t,o,l){this.empty();for(const s of e){const a=this.positions(s,i,t,o,l),d=new ce(s.color??de),m=n.get(s.id);if(m&&a.length>=3&&this.addLabel(m,this.labelAnchor(a,s.kind)),s.kind==="point"){const c=new fe;c.setAttribute("position",new F(a.slice(0,3),3));const g=new ue({color:d,size:A.MARKER_SIZE_PX,sizeAttenuation:!1,depthTest:!1,fog:!1});this.pointsMaterials.push(g);const r=new pe(c,g);r.name="trace point",r.frustumCulled=!1,r.layers.set(this.layer),this.group.add(r)}else if(a.length>=6){const c=new Q;c.setPositions(s.kind==="polygon"?[...a,a[0],a[1],a[2]]:a);const g=new N({color:d.getHex(),linewidth:A.LINE_WIDTH_PX,worldUnits:!1,transparent:!0,opacity:.92,depthTest:!1,fog:!1});this.materials.push(g);const r=new xe(c,g);r.name=`trace ${s.kind}`,r.frustumCulled=!1,r.layers.set(this.layer),this.group.add(r)}}}setView(e,n){for(const i of this.materials)i.resolution.copy(e);e.y===this.viewportHeightPx&&n===this.fovDeg||(this.viewportHeightPx=e.y,this.fovDeg=n,this.scaleLabels())}get any(){return this.group.children.length>0}dispose(){this.empty()}labelAnchor(e,n){let i=0;if(n==="line"){let t=-1;for(let o=0;o+2<e.length;o+=3){const l=Math.hypot(e[o],e[o+2]);l>t&&(t=l,i=o)}}return[e[i],e[i+1],e[i+2]]}addLabel(e,n){const i=document.createElement("canvas"),t=i.getContext("2d");if(!t)return;const o="bold 30px sans-serif";t.font=o;const l=10;i.width=Math.ceil(t.measureText(e).width)+l*2,i.height=44,t.font=o,t.fillStyle="rgba(0, 0, 0, 0.6)",t.beginPath(),t.roundRect(0,0,i.width,i.height,10),t.fill(),t.fillStyle="#ffffff",t.textBaseline="middle",t.fillText(e,l,i.height/2+2);const s=new he({map:new me(i),depthTest:!1,depthWrite:!1,fog:!1,sizeAttenuation:!1}),a=new V(s);a.name="trace name",a.center.set(0,0),a.position.set(n[0],n[1],n[2]),a.frustumCulled=!1,a.layers.set(this.layer),this.labels.push({sprite:a,aspect:i.width/i.height}),this.group.add(a),this.scaleLabels()}scaleLabels(){const e=A.LABEL_HEIGHT_PX/(this.viewportHeightPx/2)*Math.tan(this.fovDeg*Math.PI/360);for(const{sprite:n,aspect:i}of this.labels)n.scale.set(e*i,e,1)}empty(){for(const e of[...this.group.children])this.group.remove(e),e instanceof V?(e.material.map?.dispose(),e.material.dispose()):e.geometry.dispose();this.labels.length=0;for(const e of this.materials.splice(0))e.dispose();for(const e of this.pointsMaterials.splice(0))e.dispose()}positions(e,n,i,t,o){const l=e.altitude??"ground",s=e.points.map(r=>{const{x:v,z:y}=ge(r.lat,r.lng,n,i);return{x:v,z:y,altM:r.altM??0}}),a=l!=="absolute",d=[],m=(r,v,y)=>l==="absolute"?y-t:o(r,v)+(l==="relative"?y:0)+A.LIFT_M,c=e.kind==="polygon",g=c?s.length:s.length-1;for(let r=0;r<Math.max(g,1);r++){const v=s[r],y=s[(r+1)%s.length],L=a&&e.kind!=="point"?Math.max(1,Math.ceil(Math.hypot(y.x-v.x,y.z-v.z)/A.STEP_M)):1;for(let U=0;U<L;U++){const D=U/L,_=v.x+(y.x-v.x)*D,w=v.z+(y.z-v.z)*D;d.push(_,m(_,w,v.altM+(y.altM-v.altM)*D),w)}}if(!c&&e.kind!=="point"){const r=s[s.length-1];d.push(r.x,m(r.x,r.z,r.altM),r.z)}return d}}export{A as TraceSystem};
393
+ `};class N extends ie{constructor(e){super({type:"LineMaterial",uniforms:Z.clone(O.line.uniforms),vertexShader:O.line.vertexShader,fragmentShader:O.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0!==this.worldUnits&&(this.needsUpdate=!0),e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const H=new B,X=new E,q=new E,f=new B,u=new B,x=new B,W=new E,R=new ae,p=new oe,K=new E,T=new j,C=new J,S=new B;let b,z;function $(h,e,n){return S.set(0,0,-e,1).applyMatrix4(h.projectionMatrix),S.multiplyScalar(1/S.w),S.x=z/n.width,S.y=z/n.height,S.applyMatrix4(h.projectionMatrixInverse),S.multiplyScalar(1/S.w),Math.abs(Math.max(S.x,S.y))}function ve(h,e){const n=h.matrixWorld,i=h.geometry,t=i.attributes.instanceStart,o=i.attributes.instanceEnd,l=Math.min(i.instanceCount,t.count);for(let s=0,a=l;s<a;s++){p.start.fromBufferAttribute(t,s),p.end.fromBufferAttribute(o,s),p.applyMatrix4(n);const d=new E,m=new E;b.distanceSqToSegment(p.start,p.end,m,d),m.distanceTo(d)<z*.5&&e.push({point:m,pointOnLine:d,distance:b.origin.distanceTo(m),object:h,face:null,faceIndex:s,uv:null,uv1:null})}}function ye(h,e,n){const i=e.projectionMatrix,o=h.material.resolution,l=h.matrixWorld,s=h.geometry,a=s.attributes.instanceStart,d=s.attributes.instanceEnd,m=Math.min(s.instanceCount,a.count),c=-e.near;b.at(1,x),x.w=1,x.applyMatrix4(e.matrixWorldInverse),x.applyMatrix4(i),x.multiplyScalar(1/x.w),x.x*=o.x/2,x.y*=o.y/2,x.z=0,W.copy(x),R.multiplyMatrices(e.matrixWorldInverse,l);for(let g=0,r=m;g<r;g++){if(f.fromBufferAttribute(a,g),u.fromBufferAttribute(d,g),f.w=1,u.w=1,f.applyMatrix4(R),u.applyMatrix4(R),f.z>c&&u.z>c)continue;if(f.z>c){const _=f.z-u.z,w=(f.z-c)/_;f.lerp(u,w)}else if(u.z>c){const _=u.z-f.z,w=(u.z-c)/_;u.lerp(f,w)}f.applyMatrix4(i),u.applyMatrix4(i),f.multiplyScalar(1/f.w),u.multiplyScalar(1/u.w),f.x*=o.x/2,f.y*=o.y/2,u.x*=o.x/2,u.y*=o.y/2,p.start.copy(f),p.start.z=0,p.end.copy(u),p.end.z=0;const y=p.closestPointToPointParameter(W,!0);p.at(y,K);const L=re.lerp(f.z,u.z,y),U=L>=-1&&L<=1,D=W.distanceTo(K)<z*.5;if(U&&D){p.start.fromBufferAttribute(a,g),p.end.fromBufferAttribute(d,g),p.start.applyMatrix4(l),p.end.applyMatrix4(l);const _=new E,w=new E;b.distanceSqToSegment(p.start,p.end,w,_),n.push({point:w,pointOnLine:_,distance:b.origin.distanceTo(w),object:h,face:null,faceIndex:g,uv:null,uv1:null})}}}class we extends se{constructor(e=new Q,n=new N({color:Math.random()*16777215})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,i=e.attributes.instanceEnd,t=new Float32Array(2*n.count);for(let l=0,s=0,a=n.count;l<a;l++,s+=2)X.fromBufferAttribute(n,l),q.fromBufferAttribute(i,l),t[s]=s===0?0:t[s-1],t[s+1]=t[s]+X.distanceTo(q);const o=new G(t,2,1);return e.setAttribute("instanceDistanceStart",new M(o,1,0)),e.setAttribute("instanceDistanceEnd",new M(o,1,1)),this}raycast(e,n){const i=this.material.worldUnits,t=e.camera;if(t===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'),i===!1&&(this.material.resolution.x===0||this.material.resolution.y===0))return;const o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;b=e.ray;const l=this.matrixWorld,s=this.geometry,a=this.material;z=a.linewidth+o,s.boundingSphere===null&&s.computeBoundingSphere(),C.copy(s.boundingSphere).applyMatrix4(l);let d;if(i)d=z*.5;else{const c=Math.max(t.near,C.distanceToPoint(b.origin));d=$(t,c,a.resolution)}if(C.radius+=d,b.intersectsSphere(C)===!1)return;s.boundingBox===null&&s.computeBoundingBox(),T.copy(s.boundingBox).applyMatrix4(l);let m;if(i)m=z*.5;else{const c=Math.max(t.near,T.distanceToPoint(b.origin));m=$(t,c,a.resolution)}T.expandByScalar(m),b.intersectsBox(T)!==!1&&(i?ve(this,n):ye(this,t,n))}onBeforeRender(e){const n=this.material.uniforms;n&&n.resolution&&(e.getViewport(H),this.material.uniforms.resolution.value.set(H.z,H.w))}}class Y extends Q{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const n=e.length-3,i=new Float32Array(2*n);for(let t=0;t<n;t+=3)i[2*t]=e[t],i[2*t+1]=e[t+1],i[2*t+2]=e[t+2],i[2*t+3]=e[t+3],i[2*t+4]=e[t+4],i[2*t+5]=e[t+5];return super.setPositions(i),this}setColors(e){const n=e.length-3,i=new Float32Array(2*n);for(let t=0;t<n;t+=3)i[2*t]=e[t],i[2*t+1]=e[t+1],i[2*t+2]=e[t+2],i[2*t+3]=e[t+3],i[2*t+4]=e[t+4],i[2*t+5]=e[t+5];return super.setColors(i),this}setFromPoints(e){const n=e.length-1,i=new Float32Array(6*n);for(let t=0;t<n;t++)i[6*t]=e[t].x,i[6*t+1]=e[t].y,i[6*t+2]=e[t].z||0,i[6*t+3]=e[t+1].x,i[6*t+4]=e[t+1].y,i[6*t+5]=e[t+1].z||0;return super.setPositions(i),this}fromLine(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}}class xe extends we{constructor(e=new Y,n=new N({color:Math.random()*16777215})){super(e,n),this.isLine2=!0,this.type="Line2"}}class A{constructor(e){this.layer=e,this.group.name="traces"}static LINE_WIDTH_PX=2.5;static MARKER_SIZE_PX=9;static LABEL_HEIGHT_PX=15;static STEP_M=15;static LIFT_M=.3;group=new le;materials=[];pointsMaterials=[];labels=[];viewportHeightPx=720;fovDeg=60;set(e,n,i,t,o,l){this.empty();for(const s of e){const a=this.positions(s,i,t,o,l),d=new ce(s.color??de),m=n.get(s.id);if(m&&a.length>=3&&this.addLabel(m,this.labelAnchor(a,s.kind)),s.kind==="point"){const c=new fe;c.setAttribute("position",new F(a.slice(0,3),3));const g=new ue({color:d,size:A.MARKER_SIZE_PX,sizeAttenuation:!1,depthTest:!1,fog:!1});this.pointsMaterials.push(g);const r=new pe(c,g);r.name="trace point",r.frustumCulled=!1,r.layers.set(this.layer),this.group.add(r)}else if(a.length>=6){const c=new Y;c.setPositions(s.kind==="polygon"?[...a,a[0],a[1],a[2]]:a);const g=new N({color:d.getHex(),linewidth:A.LINE_WIDTH_PX,worldUnits:!1,transparent:!0,opacity:.92,depthTest:!1,fog:!1});this.materials.push(g);const r=new xe(c,g);r.name=`trace ${s.kind}`,r.frustumCulled=!1,r.layers.set(this.layer),this.group.add(r)}}}setView(e,n){for(const i of this.materials)i.resolution.copy(e);e.y===this.viewportHeightPx&&n===this.fovDeg||(this.viewportHeightPx=e.y,this.fovDeg=n,this.scaleLabels())}get any(){return this.group.children.length>0}dispose(){this.empty()}labelAnchor(e,n){let i=0;if(n==="line"){let t=-1;for(let o=0;o+2<e.length;o+=3){const l=Math.hypot(e[o],e[o+2]);l>t&&(t=l,i=o)}}return[e[i],e[i+1],e[i+2]]}addLabel(e,n){const i=document.createElement("canvas"),t=i.getContext("2d");if(!t)return;const o="bold 30px sans-serif";t.font=o;const l=10;i.width=Math.ceil(t.measureText(e).width)+l*2,i.height=44,t.font=o,t.fillStyle="rgba(0, 0, 0, 0.6)",t.beginPath(),t.roundRect(0,0,i.width,i.height,10),t.fill(),t.fillStyle="#ffffff",t.textBaseline="middle",t.fillText(e,l,i.height/2+2);const s=new he({map:new me(i),depthTest:!1,depthWrite:!1,fog:!1,sizeAttenuation:!1}),a=new V(s);a.name="trace name",a.center.set(0,0),a.position.set(n[0],n[1],n[2]),a.frustumCulled=!1,a.layers.set(this.layer),this.labels.push({sprite:a,aspect:i.width/i.height}),this.group.add(a),this.scaleLabels()}scaleLabels(){const e=A.LABEL_HEIGHT_PX/(this.viewportHeightPx/2)*Math.tan(this.fovDeg*Math.PI/360);for(const{sprite:n,aspect:i}of this.labels)n.scale.set(e*i,e,1)}empty(){for(const e of[...this.group.children])this.group.remove(e),e instanceof V?(e.material.map?.dispose(),e.material.dispose()):e.geometry.dispose();this.labels.length=0;for(const e of this.materials.splice(0))e.dispose();for(const e of this.pointsMaterials.splice(0))e.dispose()}positions(e,n,i,t,o){const l=e.altitude??"ground",s=e.points.map(r=>{const{x:v,z:y}=ge(r.lat,r.lng,n,i);return{x:v,z:y,altM:r.altM??0}}),a=l!=="absolute",d=[],m=(r,v,y)=>l==="absolute"?y-t:o(r,v)+(l==="relative"?y:0)+A.LIFT_M,c=e.kind==="polygon",g=c?s.length:s.length-1;for(let r=0;r<Math.max(g,1);r++){const v=s[r],y=s[(r+1)%s.length],L=a&&e.kind!=="point"?Math.max(1,Math.ceil(Math.hypot(y.x-v.x,y.z-v.z)/A.STEP_M)):1;for(let U=0;U<L;U++){const D=U/L,_=v.x+(y.x-v.x)*D,w=v.z+(y.z-v.z)*D;d.push(_,m(_,w,v.altM+(y.altM-v.altM)*D),w)}}if(!c&&e.kind!=="point"){const r=s[s.length-1];d.push(r.x,m(r.x,r.z,r.altM),r.z)}return d}}export{A as TraceSystem};
@@ -0,0 +1,19 @@
1
+ import{G as b,w as F,C as E,x as L,y as N,z as M,E as D,J as C,K as R,m as I,N as U,Q as T,X as P,Y as O,Z as B,$ as V,a0 as A}from"./rr0-sighting.mjs";class r{static LIFT_M=.05;static RENDER_ORDER=1.04;static LEVEL_QUANTILE=.2;static BODY_ALBEDO=[.035,.045,.04];static IOR=1.33;static ROUGHNESS=.08;static MAX_SAMPLES=48;static REFLECTION_SCALE=.5;group=new b;material=new F({color:new E(...r.BODY_ALBEDO),roughness:r.ROUGHNESS,metalness:0,ior:r.IOR,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2});levels=new Map;reflectionTarget;reflectionUniforms={uWaterReflection:{value:null},uWaterReflectionMatrix:{value:new L},uWaterReflectionOn:{value:0}};mirrorCamera=new N;eye=new M;ahead=new M;up=new M;plane=new D;clip=new C;q=new C;size=new R;bias=new L().set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);constructor(){this.group.name="water",this.material.onBeforeCompile=t=>{Object.assign(t.uniforms,this.reflectionUniforms),t.vertexShader=t.vertexShader.replace("#include <common>",`#include <common>
2
+ varying vec3 vWaterWorld;`).replace("#include <project_vertex>",`#include <project_vertex>
3
+ vWaterWorld = (modelMatrix * vec4(transformed, 1.0)).xyz;`),t.fragmentShader=t.fragmentShader.replace("#include <common>",`#include <common>
4
+ varying vec3 vWaterWorld;
5
+ uniform sampler2D uWaterReflection;
6
+ uniform mat4 uWaterReflectionMatrix;
7
+ uniform float uWaterReflectionOn;`).replace("#include <opaque_fragment>",`
8
+ if (uWaterReflectionOn > 0.5) {
9
+ vec4 at = uWaterReflectionMatrix * vec4(vWaterWorld, 1.0);
10
+ vec2 uv = at.xy / at.w;
11
+ if (at.w > 0.0 && uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0) {
12
+ vec4 mirrored = texture2D(uWaterReflection, uv);
13
+ float facing = clamp(dot(normal, normalize(vViewPosition)), 0.0, 1.0);
14
+ float fresnel = 0.02 + 0.98 * pow(1.0 - facing, 5.0);
15
+ // Premultiplied: drawn over a picture cleared to nothing, an edge's colour is already its coverage's share.
16
+ outgoingLight = outgoingLight * (1.0 - mirrored.a * fresnel) + mirrored.rgb * fresnel;
17
+ }
18
+ }
19
+ #include <opaque_fragment>`)}}set(t,o,e,f,i,a){this.clear();for(const l of t){const h=l.rings.map(n=>r.clip(n.map(u=>I(u.lat,u.lng,o,e)),i)),c=h[0];if(!c||c.length<3)continue;const d=h.slice(1).filter(n=>n.length>=3),p=r.level(c,d,f,a);if(p===void 0)continue;const s=r.geometry(c,d,p+r.LIFT_M);if(!s)continue;const g=new U(s,this.material);g.name=`water ${l.id}`,g.renderOrder=r.RENDER_ORDER,g.receiveShadow=!0,this.group.add(g),this.levels.set(g,{y:p+r.LIFT_M,areaM2:Math.abs(T.area(c.map(n=>new R(n.x,n.z))))})}}get count(){return this.group.children.length}clear(){for(const t of[...this.group.children])t.geometry.dispose(),this.group.remove(t);this.levels.clear()}dispose(){this.clear(),this.material.dispose(),this.reflectionTarget?.dispose()}reflectBodies(t,o,e,f,i,a){const l=this.reflectionUniforms;l.uWaterReflectionOn.value=0;let h;for(const[v,y]of this.levels)v.visible&&(!h||y.areaM2>h.areaM2)&&(h=y);if(!i||!h)return;this.group.updateWorldMatrix(!0,!1);const c=h.y+this.group.position.y;if(e.updateMatrixWorld(),this.eye.setFromMatrixPosition(e.matrixWorld),this.eye.y<=c)return;t.getDrawingBufferSize(this.size);const d=Math.max(16,Math.round(this.size.x*r.REFLECTION_SCALE)),p=Math.max(16,Math.round(this.size.y*r.REFLECTION_SCALE));(!this.reflectionTarget||this.reflectionTarget.width!==d||this.reflectionTarget.height!==p)&&(this.reflectionTarget?.dispose(),this.reflectionTarget=new P(d,p,{type:B,minFilter:O,magFilter:O}));const s=this.mirrorCamera,g=v=>v.setY(2*c-v.y);s.position.copy(g(this.eye.clone())),e.getWorldDirection(this.ahead);const n=g(this.eye.clone().add(this.ahead));this.up.set(0,1,0).applyQuaternion(e.quaternion),s.up.set(this.up.x,-this.up.y,this.up.z),s.lookAt(n),s.fov=a??e.fov,s.aspect=e.aspect,s.near=e.near,s.far=e.far,s.updateProjectionMatrix(),s.updateMatrixWorld(),this.clipAtLevel(s,c),l.uWaterReflectionMatrix.value.copy(this.bias).multiply(s.projectionMatrix).multiply(s.matrixWorldInverse),o.traverseVisible(v=>{v.isLight&&v.layers.enable(f)});const u=t.getRenderTarget(),m=t.autoClear,x=t.shadowMap.autoUpdate,w=o.background,z=t.getClearAlpha();t.getClearColor(r.clearColor),o.background=null,t.shadowMap.autoUpdate=!1,t.setRenderTarget(this.reflectionTarget),t.setClearColor(0,0),t.autoClear=!0,s.layers.set(f),t.render(o,s),t.setRenderTarget(u),t.setClearColor(r.clearColor,z),t.autoClear=m,t.shadowMap.autoUpdate=x,o.background=w,l.uWaterReflection.value=this.reflectionTarget.texture,l.uWaterReflectionOn.value=1}static clearColor=new E;clipAtLevel(t,o){this.plane.setFromNormalAndCoplanarPoint(new M(0,1,0),new M(0,o,0)).applyMatrix4(t.matrixWorldInverse),this.clip.set(this.plane.normal.x,this.plane.normal.y,this.plane.normal.z,this.plane.constant);const e=t.projectionMatrix.elements;this.q.set((Math.sign(this.clip.x)+e[8])/e[0],(Math.sign(this.clip.y)+e[9])/e[5],-1,(1+e[10])/e[14]),this.clip.multiplyScalar(2/this.clip.dot(this.q)),e[2]=this.clip.x,e[6]=this.clip.y,e[10]=this.clip.z+1,e[14]=this.clip.w}static level(t,o,e,f){const i=t.map(n=>n.x),a=t.map(n=>n.z),[l,h,c,d]=[Math.min(...i),Math.max(...i),Math.min(...a),Math.max(...a)],p=Math.max(f,(h-l)/r.MAX_SAMPLES,(d-c)/r.MAX_SAMPLES,.5),s=[];for(let n=c+p/2;n<d;n+=p)for(let u=l+p/2;u<h;u+=p){const m={x:u,z:n};if(!r.contains(t,m)||o.some(w=>r.contains(w,m)))continue;const x=e(u,n);Number.isFinite(x)&&s.push(x)}if(s.length===0)for(const n of t)s.push(e(n.x,n.z));const g=s.filter(Number.isFinite).sort((n,u)=>n-u);if(g.length!==0)return g[Math.floor((g.length-1)*r.LEVEL_QUANTILE)]}static clip(t,o){let e=t;const f=[{inside:i=>i.x>=-o,cross:(i,a)=>r.atX(i,a,-o)},{inside:i=>i.x<=o,cross:(i,a)=>r.atX(i,a,o)},{inside:i=>i.z>=-o,cross:(i,a)=>r.atZ(i,a,-o)},{inside:i=>i.z<=o,cross:(i,a)=>r.atZ(i,a,o)}];for(const i of f){const a=[];for(let l=0;l<e.length;l++){const h=e[l],c=e[(l+e.length-1)%e.length];i.inside(h)?(i.inside(c)||a.push(i.cross(c,h)),a.push(h)):i.inside(c)&&a.push(i.cross(c,h))}if(e=a,e.length===0)break}return e}static atX(t,o,e){return{x:e,z:t.z+(o.z-t.z)*(e-t.x)/(o.x-t.x)}}static atZ(t,o,e){return{x:t.x+(o.x-t.x)*(e-t.z)/(o.z-t.z),z:e}}static contains(t,o){let e=!1;for(let f=0,i=t.length-1;f<t.length;i=f++){const a=t[f],l=t[i];a.z>o.z!=l.z>o.z&&o.x<(l.x-a.x)*(o.z-a.z)/(l.z-a.z)+a.x&&(e=!e)}return e}static geometry(t,o,e){const f=s=>new R(s.x,s.z),i=t.map(f),a=o.map(s=>s.map(f)),l=T.triangulateShape(i,a);if(l.length===0)return;const h=[...i,...a.flat()],c=[];for(const[s,g,n]of l){const[u,m,x]=[h[s],h[g],h[n]],w=(m.y-u.y)*(x.x-u.x)-(m.x-u.x)*(x.y-u.y)>0;for(const z of w?[u,m,x]:[u,x,m])c.push(z.x,e,z.y)}const d=new V;d.setAttribute("position",new A(c,3));const p=new Float32Array(c.length);for(let s=1;s<p.length;s+=3)p[s]=1;return d.setAttribute("normal",new A(p,3)),d.computeBoundingSphere(),d}}export{r as WaterSystem};