@rr0/ufoathome 0.86.0 → 0.86.2
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.
- package/dist-embed-scene/ContrailGrowth-CuAzwIoc.js +1 -0
- package/dist-embed-scene/ContrailSystem-CQsI1Z1v.js +1 -0
- package/dist-embed-scene/rr0-scene.mjs +32 -32
- package/dist-embed-scene/trafficRuntime-_pIg6nkw.js +2 -0
- package/dist-embed-sighting/ContrailGrowth-CuAzwIoc.js +1 -0
- package/dist-embed-sighting/ContrailSystem-CkzapJ6C.js +1 -0
- package/dist-embed-sighting/rr0-sighting.mjs +34 -34
- package/dist-embed-sighting/trafficRuntime-C1HVGEkh.js +2 -0
- package/dist-embed-sighting-editor/ContrailGrowth-CuAzwIoc.js +1 -0
- package/dist-embed-sighting-editor/ContrailSystem-CXV5ZetF.js +1 -0
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +34 -34
- package/dist-embed-sighting-editor/trafficRuntime-CyMwd0OH.js +2 -0
- package/package.json +1 -1
- package/dist-embed-scene/ContrailGrowth-bHuVPHYY.js +0 -1
- package/dist-embed-scene/ContrailSystem-BsPJ-HyA.js +0 -1
- package/dist-embed-scene/trafficRuntime-BNKtP7MU.js +0 -2
- package/dist-embed-sighting/ContrailGrowth-bHuVPHYY.js +0 -1
- package/dist-embed-sighting/ContrailSystem-Ct9SoLDA.js +0 -1
- package/dist-embed-sighting/trafficRuntime-BqsOb_FO.js +0 -2
- package/dist-embed-sighting-editor/ContrailGrowth-bHuVPHYY.js +0 -1
- package/dist-embed-sighting-editor/ContrailSystem-CdlRgS_7.js +0 -1
- package/dist-embed-sighting-editor/trafficRuntime-BKESmiqx.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{A as ht,T as U,R as L,a as P}from"./rr0-scene.mjs";import{C as Y}from"./ContrailGrowth-CuAzwIoc.js";class g{static OCTAVES=[63,125,250,500,1e3,2e3,4e3,8e3];static STANDARD={temperatureC:15,relativeHumidity:.7,pressureKPa:101.325};static REFERENCE_PRESSURE_KPA=101.325;static REFERENCE_TEMPERATURE_K=293.15;static TRIPLE_POINT_K=273.16;static speedOfSound(t){return 20.0468*Math.sqrt(t+273.15)}static absorptionDbPerKm(t,e=g.STANDARD){const a=e.temperatureC+273.15,n=g.REFERENCE_TEMPERATURE_K,i=e.pressureKPa/g.REFERENCE_PRESSURE_KPA,r=10**(-6.8346*(g.TRIPLE_POINT_K/a)**1.261+4.6151),s=e.relativeHumidity*100*r/i,o=i*(24+40400*s*(.02+s)/(.391+s)),l=i*(a/n)**-.5*(9+280*s*Math.exp(-4.17*((a/n)**(-1/3)-1))),d=t*t;return 8.686*d*(184e-13*(1/i)*Math.sqrt(a/n)+(a/n)**-2.5*(.01275*Math.exp(-2239.1/a)/(o+d/o)+.1068*Math.exp(-3352/a)/(l+d/l)))*1e3}static aWeightingDb(t){const e=t*t,a=12194**2*e*e/((e+20.6**2)*Math.sqrt((e+107.7**2)*(e+737.9**2))*(e+12194**2));return 20*Math.log10(a)+2}static sumDb(t){return 10*Math.log10(t.reduce((e,a)=>e+10**(a/10),0))}}const ut=.25,$=.4,J=6,F=12,pt=3,Z=.2,ft=.2,mt=24,gt=3,Mt=12,Q=1,At=.7,bt=1.5,Et=.8,Dt=1.3,tt=.9,et=5,St=25,yt=.5,Rt=.12,at=[.13,.31],Bt=.16,vt=1.6,Ot=3.6,nt=1.1,It=.3,Ct=1e3,it=.7;class x{context;noiseBuffer;roughBuffers=new Map;voices=new Map;bus;reverb;reverbOut;paused=!0;requested=[];headingDeg=0;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("AircraftAudio: Web Audio unavailable, aircraft stay silent:",t);return}}ht.unlock(this.context),this.apply()}setPaused(t){t!==this.paused&&(this.paused=t,this.apply())}setVoices(t,e=0){this.requested=t,this.headingDeg=e,this.apply()}dispose(){for(const t of[...this.voices.keys()])this.release(t);this.context?.close(),this.context=void 0}apply(){const t=this.context;if(!t)return;const e=this.paused?[]:this.requested,a=new Set(e.map(n=>n.id));for(const n of[...this.voices.keys()])a.has(n)||this.release(n);for(const n of e){const i=this.voices.get(n.id)??this.build(t,n);this.retarget(t,i,n)}}build(t,e){const a=t.createGain();a.gain.value=0;let n;const i=this.busOf(t);typeof t.createStereoPanner=="function"?(n=t.createStereoPanner(),a.connect(n).connect(i)):a.connect(i);const r=t.createGain(),s=e.character?.modulationDepth??0;r.gain.value=1-s/2;const o=t.createOscillator();o.type="sine";const l=t.createGain();l.gain.value=s/2,o.connect(l).connect(r.gain),r.connect(a);const d=t.createBufferSource();d.buffer=this.noise(t),d.loop=!0,d.loopStart=Math.random()*J*.5;const h=[],u=[],c=[];for(const D of g.OCTAVES){const R=t.createBiquadFilter();R.type="bandpass",R.frequency.value=D,R.Q.value=Q;const C=t.createBiquadFilter();C.type="bandpass",C.frequency.value=D,C.Q.value=Q;const N=t.createGain();N.gain.value=0,d.connect(R).connect(C).connect(N).connect(r),h.push(R),u.push(C),c.push(N)}const p=[];for(const[D,R]of[[e.character?.toneHz,e.character?.toneShare],[e.character?.humHz,e.character?.humShare]])if(D!==void 0)for(let C=1;C<=gt;C++){const N=t.createOscillator();N.type="sine",N.frequency.value=D*C;const V=t.createGain();V.gain.value=0,N.connect(V).connect(a),p.push({oscillator:N,gain:V,harmonic:C,baseHz:D,share:R??0})}const f=t.createGain();f.gain.value=0,f.connect(a.gain);const A=at.map(D=>{const R=t.createOscillator();return R.type="sine",R.frequency.value=D,R.connect(f),R}),E=t.createGain();E.gain.value=e.character?.roughness??Z;const T=t.createBufferSource();T.buffer=this.roughTable(t,pt),T.loop=!0,T.loopStart=Math.random()*F*.5,T.connect(E).connect(r.gain);const I=t.createGain();I.gain.value=(e.character?.roughness??Z)*ft;const S=t.createBufferSource();S.buffer=this.roughTable(t,mt),S.loop=!0,S.loopStart=Math.random()*F*.5,S.connect(I).connect(r.gain);let B;const G=this.busOf(t)&&this.reverb;G&&(B=t.createGain(),B.gain.value=0,a.connect(B).connect(G));const W=[d,T,S,o,...p.map(D=>D.oscillator),...A];for(const D of W)D.start();const q={nodes:[a,r,l,E,I,f,...p.map(D=>D.gain),...h,...u,...c,...B?[B]:[],...n?[n]:[],...W],sources:W,filters:h,seconds:u,gains:c,tones:p,lfo:o,lfoDepth:l,wander:A,wanderDepth:f,roughDepth:E,crackleDepth:I,beat:r,output:a,panner:n,send:B};return this.voices.set(e.id,q),q}retarget(t,e,a){const n=t.currentTime,i=(p,f)=>p.setTargetAtTime(f,n,ut),r=Math.min(bt,Math.max(At,a.dopplerRatio)),s=Math.min(Dt,Math.max(Et,Math.sqrt(a.dopplerRatio))),o=t.sampleRate*.45,l=a.bandAmplitudes.map((p,f)=>p*x.unweighting(g.OCTAVES[f])),d=Math.sqrt(l.reduce((p,f)=>p+f*f,0)),h=Math.min(1,Math.max(0,(a.distanceKm-et)/(St-et)));g.OCTAVES.forEach((p,f)=>{i(e.filters[f].frequency,Math.min(o,p*s)),i(e.seconds[f].frequency,Math.min(o,p*s)),i(e.gains[f].gain,l[f]*Math.sqrt(Ct/p))});const u=a.character;for(const{oscillator:p,gain:f,harmonic:A,baseHz:E,share:T}of e.tones){const I=E*A;i(p.frequency,I*r);const S=I*r;i(f.gain,S<o?T*Bt*l[x.bandOf(S)]/A:0)}u?.modulationHz!==void 0&&i(e.lfo.frequency,u.modulationHz*r);const c=d>0?it*(1-Math.exp(-d/it))/d:1;if(i(e.output.gain,c*(1-It*h)),i(e.wanderDepth.gain,c*Rt*h/at.length),e.send&&i(e.send.gain,vt*h),e.panner){const p=(a.azimuthDeg-this.headingDeg)*Math.PI/180;i(e.panner.pan,Math.max(-tt,Math.min(tt,Math.sin(p)))*(1-yt*h))}}static unweighting(t){return 10**(Math.min(Mt,Math.max(0,-g.aWeightingDb(t)))/20)}static bandOf(t){let e=0;return g.OCTAVES.forEach((a,n)=>{Math.abs(Math.log(t/a))<Math.abs(Math.log(t/g.OCTAVES[e]))&&(e=n)}),e}roughTable(t,e){const a=this.roughBuffers.get(e);if(a)return a;const n=Math.floor(t.sampleRate*F),i=t.createBuffer(1,n,t.sampleRate),r=i.getChannelData(0),s=Array.from({length:F*e},()=>(Math.random()*2-1)**3),o=t.sampleRate/e;for(let l=0;l<r.length;l++){const d=l/o,h=Math.floor(d),u=d-h,c=u*u*(3-2*u);r[l]=s[h%s.length]*(1-c)+s[(h+1)%s.length]*c}return this.roughBuffers.set(e,i),i}roomImpulse(t){const e=Math.floor(t.sampleRate*Ot),a=t.createBuffer(2,e,t.sampleRate);for(let n=0;n<2;n++){const i=a.getChannelData(n);let r=0;for(let s=0;s<e;s++){const o=s/t.sampleRate,l=.6*Math.exp(-o/(nt*2))+.04;r+=l*(Math.random()*2-1-r),i[s]=r*Math.exp(-o/nt)}}return a}busOf(t){if(this.bus)return this.bus;if(typeof t.createConvolver=="function"){const e=t.createConvolver();e.buffer=this.roomImpulse(t);const a=t.createGain();a.gain.value=.9,e.connect(a),this.reverb=e,this.reverbOut=a}if(typeof t.createDynamicsCompressor=="function"){const e=t.createDynamicsCompressor();e.threshold.value=-6,e.knee.value=3,e.ratio.value=4,e.attack.value=.005,e.release.value=.25,e.connect(t.destination),this.bus=e}else this.bus=t.destination;return this.reverbOut?.connect(this.bus),this.bus}release(t){const e=this.voices.get(t);if(!e)return;this.voices.delete(t);const a=this.context;a&&(e.output.gain.setTargetAtTime(0,a.currentTime,$/3),setTimeout(()=>{for(const n of e.sources)try{n.stop()}catch{}for(const n of e.nodes)n.disconnect()},$*1e3*3))}noise(t){if(this.noiseBuffer)return this.noiseBuffer;const e=t.createBuffer(1,t.sampleRate*J,t.sampleRate),a=e.getChannelData(0);for(let n=0;n<a.length;n++)a[n]=Math.random()*2-1;return this.noiseBuffer=e,e}}class v{static BASE_DB_A=30;static WIND_DB_A=[[0,10],[1,28],[2,36],[3,40],[5,46],[8,52],[12,58],[20,66]];static RAIN_DB_A=[[0,0],[.1,42],[.3,50],[.6,58],[1,65]];static BED_RMS=.2;static MINIMUM_REFERENCE=.008;static WIND_BED_MIN_MS=1;static WIND_BED_FULL_MS=20;static dbA(t){const e=[v.BASE_DB_A,v.along(v.WIND_DB_A,t.windSpeed)];return(t.precipitationType==="rain"||t.precipitationType==="hail")&&e.push(v.along(v.RAIN_DB_A,t.precipitationIntensity)),10*Math.log10(e.filter(a=>a>0).reduce((a,n)=>a+10**(n/10),0))}static bedVolume(t){const e=t.windSpeed>v.WIND_BED_MIN_MS?Math.min(t.windSpeed/v.WIND_BED_FULL_MS,1):0,a=t.precipitationType==="hail"?Math.min(1,t.precipitationIntensity*1.3+.2):t.precipitationType==="rain"?t.precipitationIntensity:0;return Math.hypot(e,a)}static referenceAmplitude(t){return Math.max(v.BED_RMS*v.bedVolume(t),v.MINIMUM_REFERENCE)}static along(t,e){if(e<=t[0][0])return t[0][1];for(let a=1;a<t.length;a++)if(e<=t[a][0]){const[n,i]=t[a-1],[r,s]=t[a];return i+(s-i)*(e-n)/(r-n)}return t[t.length-1][1]}}class _{static TYPES={A318:["Airbus A318","airliner-narrow",34.1,31.4],A319:["Airbus A319","airliner-narrow",34.1,33.8],A320:["Airbus A320","airliner-narrow",34.1,37.6],A321:["Airbus A321","airliner-narrow",34.1,44.5],A19N:["Airbus A319neo","airliner-narrow",35.8,33.8],A20N:["Airbus A320neo","airliner-narrow",35.8,37.6],A21N:["Airbus A321neo","airliner-narrow",35.8,44.5],B737:["Boeing 737-700","airliner-narrow",34.3,33.6],B738:["Boeing 737-800","airliner-narrow",35.8,39.5],B739:["Boeing 737-900","airliner-narrow",35.8,42.1],B38M:["Boeing 737 MAX 8","airliner-narrow",35.9,39.5],B39M:["Boeing 737 MAX 9","airliner-narrow",35.9,42.2],B752:["Boeing 757-200","airliner-narrow",38,47.3],B753:["Boeing 757-300","airliner-narrow",38,54.4],B762:["Boeing 767-200","airliner-wide",47.6,48.5],B763:["Boeing 767-300","airliner-wide",47.6,54.9],B764:["Boeing 767-400","airliner-wide",51.9,61.4],B772:["Boeing 777-200","airliner-wide",60.9,63.7],B77L:["Boeing 777-200LR","airliner-wide",64.8,63.7],B77W:["Boeing 777-300ER","airliner-wide",64.8,73.9],B788:["Boeing 787-8","airliner-wide",60.1,56.7],B789:["Boeing 787-9","airliner-wide",60.1,62.8],B78X:["Boeing 787-10","airliner-wide",60.1,68.3],B744:["Boeing 747-400","airliner-wide",64.4,70.7],B748:["Boeing 747-8","airliner-wide",68.4,76.3],A306:["Airbus A300-600","airliner-wide",44.8,54.1],A310:["Airbus A310","airliner-wide",43.9,46.7],A332:["Airbus A330-200","airliner-wide",60.3,58.8],A333:["Airbus A330-300","airliner-wide",60.3,63.7],A338:["Airbus A330-800","airliner-wide",64,58.8],A339:["Airbus A330-900","airliner-wide",64,63.7],A343:["Airbus A340-300","airliner-wide",60.3,63.7],A346:["Airbus A340-600","airliner-wide",63.5,75.4],A359:["Airbus A350-900","airliner-wide",64.8,66.8],A35K:["Airbus A350-1000","airliner-wide",64.8,73.8],A388:["Airbus A380-800","airliner-wide",79.8,72.7],E170:["Embraer 170","regional-jet",26,29.9],E75L:["Embraer 175","regional-jet",26,31.7],E75S:["Embraer 175","regional-jet",26,31.7],E190:["Embraer 190","regional-jet",28.7,36.2],E195:["Embraer 195","regional-jet",28.7,38.7],E290:["Embraer 190-E2","regional-jet",33.7,36.2],E295:["Embraer 195-E2","regional-jet",33.7,41.5],CRJ2:["Bombardier CRJ200","regional-jet",21.2,26.8],CRJ7:["Bombardier CRJ700","regional-jet",23.2,32.3],CRJ9:["Bombardier CRJ900","regional-jet",24.9,36.2],CRJX:["Bombardier CRJ1000","regional-jet",26.2,39.1],AT72:["ATR 72","regional-turboprop",27.1,27.2],AT76:["ATR 72-600","regional-turboprop",27.1,27.2],AT45:["ATR 42","regional-turboprop",24.6,22.7],DH8D:["Dash 8 Q400","regional-turboprop",28.4,32.8],DH8C:["Dash 8-300","regional-turboprop",27.4,25.7],SF34:["Saab 340","regional-turboprop",21.4,19.7],B190:["Beechcraft 1900","regional-turboprop",17.7,17.6],C25A:["Cessna CitationJet CJ2","business-jet",14.3,14.4],C56X:["Cessna Citation Excel","business-jet",17.2,16],C68A:["Cessna Citation Latitude","business-jet",22,18.9],C550:["Cessna Citation II","business-jet",15.8,14.4],E55P:["Embraer Phenom 300","business-jet",15.9,15.6],E50P:["Embraer Phenom 100","business-jet",12.3,12.8],GLF5:["Gulfstream G550","business-jet",28.5,29.4],FA7X:["Dassault Falcon 7X","business-jet",26.2,23.4],CL60:["Bombardier Challenger 600","business-jet",19.6,20.9],LJ45:["Learjet 45","business-jet",14.6,17.7],H25B:["Hawker 800","business-jet",15.7,15.6],C172:["Cessna 172","light-piston",11,8.3],C152:["Cessna 152","light-piston",10.2,7.3],C182:["Cessna 182","light-piston",10.9,8.8],P28A:["Piper Cherokee","light-piston",10.7,7.2],PA34:["Piper Seneca","light-piston",11.8,8.7],SR20:["Cirrus SR20","light-piston",10.9,7.9],SR22:["Cirrus SR22","light-piston",11.7,7.9],S22T:["Cirrus SR22T","light-piston",11.7,7.9],DA40:["Diamond DA40","light-piston",11.6,8.1],DA42:["Diamond DA42","light-piston",13.4,8.6],BE20:["Beechcraft King Air 200","turboprop-light",16.6,13.3],BE58:["Beechcraft Baron","light-piston",11.5,9.1],C208:["Cessna Caravan","turboprop-light",15.9,11.5],PC12:["Pilatus PC-12","turboprop-light",16.3,14.4],TBM9:["Daher TBM 900","turboprop-light",12.8,10.7],EC35:["Airbus H135","helicopter-light",10.2,12.1],EC45:["Airbus H145","helicopter-medium",11,13.6],AS50:["Airbus H125","helicopter-light",10.7,12.9],EC30:["Airbus H130","helicopter-light",10.7,12.6],B407:["Bell 407","helicopter-light",10.7,12.7],B06:["Bell 206","helicopter-light",10.2,12],B429:["Bell 429","helicopter-medium",10.9,13],B505:["Bell 505","helicopter-light",10.4,11.9],R44:["Robinson R44","helicopter-light",10.1,11.7],R22:["Robinson R22","helicopter-light",7.7,8.8],A109:["Agusta A109","helicopter-medium",11,13],A139:["Leonardo AW139","helicopter-medium",13.8,16.7],S92:["Sikorsky S-92","helicopter-heavy",17.2,20.9],H60:["Sikorsky UH-60 Black Hawk","helicopter-heavy",16.4,19.8],T38:["Northrop T-38 Talon","military-jet",7.7,14.1],HAWK:["BAE Hawk","military-jet",9.4,11.9],GLID:["Glider","glider",17,7],BALL:["Balloon","balloon",15,20],ULAC:["Ultralight","ultralight",9.5,6],C42:["Ikarus C42","ultralight",9.4,6.3],DRON:["Drone","unmanned",1,.6]};static CATEGORIES={A1:["Light aircraft","light-piston",11,8.3],A2:["Small aircraft","business-jet",15,15],A3:["Large aircraft","airliner-narrow",34.1,37.6],A4:["High-vortex large aircraft","airliner-narrow",38,47.3],A5:["Heavy aircraft","airliner-wide",60.3,63.7],A6:["High-performance aircraft","military-jet",8,14],A7:["Rotorcraft","helicopter-medium",10.7,12.7],B1:["Glider","glider",17,7],B2:["Lighter-than-air","balloon",15,20],B4:["Ultralight","ultralight",9.5,6],B6:["Unmanned aircraft","unmanned",1.5,1]};static GENERIC={name:"Airliner",kind:"airliner-narrow",spanM:34.1,lengthM:37.6,basis:"nothing"};static of(t){const e=t?.type?.toUpperCase(),a=e?_.TYPES[e]:void 0;if(a)return{code:e,name:a[0],kind:a[1],spanM:a[2],lengthM:a[3],basis:"type"};const n=t?.category?_.CATEGORIES[t.category]:void 0;return n?{name:n[0],kind:n[1],spanM:n[2],lengthM:n[3],basis:"category"}:{..._.GENERIC}}static isHelicopter(t){return t.kind.startsWith("helicopter")}}const rt="#ff2200",st="#00ff44",k="#ffffff",j="#ffa500",z="#ff0000",Tt="#2244ff",_t=[{id:"airliner",name:"Airliner",kinds:["aircraft"],create:()=>[{id:"nav-port",offsetM:{x:-17,y:0,z:0},color:rt,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:17,y:0,z:0},color:st,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-18},color:k,pattern:{kind:"steady"}},{id:"beacon-top",offsetM:{x:0,y:2,z:0},color:z,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"beacon-bottom",offsetM:{x:0,y:-2,z:0},color:z,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.18}},{id:"strobe-port",offsetM:{x:-17,y:0,z:-1},color:k,intensity:20,pattern:{kind:"flash",perMinute:60,dutyCycle:.01}},{id:"strobe-starboard",offsetM:{x:17,y:0,z:-1},color:k,intensity:20,pattern:{kind:"flash",perMinute:60,dutyCycle:.01,phase:.08}}]},{id:"helicopter",name:"Helicopter",kinds:["aircraft"],create:()=>[{id:"nav-port",offsetM:{x:-5,y:0,z:0},color:rt,pattern:{kind:"steady"}},{id:"nav-starboard",offsetM:{x:5,y:0,z:0},color:st,pattern:{kind:"steady"}},{id:"nav-tail",offsetM:{x:0,y:1,z:-7},color:k,pattern:{kind:"steady"}},{id:"beacon",offsetM:{x:0,y:2,z:-2},color:z,intensity:1.5,pattern:{kind:"flash",perMinute:45,dutyCycle:.2}},{id:"strobe",offsetM:{x:0,y:-1,z:0},color:k,intensity:15,pattern:{kind:"flash",perMinute:75,dutyCycle:.015}}]},{id:"car-headlights",name:"Car, headlights on",kinds:["vehicle"],create:()=>[{id:"head-left",offsetM:{x:-.7,y:.6,z:2},color:k,intensity:2,pattern:{kind:"steady"}},{id:"head-right",offsetM:{x:.7,y:.6,z:2},color:k,intensity:2,pattern:{kind:"steady"}},{id:"tail-left",offsetM:{x:-.7,y:.6,z:-2},color:z,pattern:{kind:"steady"}},{id:"tail-right",offsetM:{x:.7,y:.6,z:-2},color:z,pattern:{kind:"steady"}}]},{id:"car-hazards",name:"Car, hazard flashers",kinds:["vehicle"],create:()=>[{id:"hazard-front-left",offsetM:{x:-.8,y:.6,z:2},color:j,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-front-right",offsetM:{x:.8,y:.6,z:2},color:j,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-left",offsetM:{x:-.8,y:.6,z:-2},color:j,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}},{id:"hazard-rear-right",offsetM:{x:.8,y:.6,z:-2},color:j,pattern:{kind:"flash",perMinute:90,dutyCycle:.5}}]},{id:"emergency-beacons",name:"Emergency vehicle beacons",kinds:["vehicle"],create:()=>[{id:"beacon-blue",offsetM:{x:-.4,y:1.6,z:0},color:Tt,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1}},{id:"beacon-red",offsetM:{x:.4,y:1.6,z:0},color:z,intensity:2.5,pattern:{kind:"flash",perMinute:120,dutyCycle:.1,phase:.5}}]},{id:"streetlamp",name:"Streetlamp",kinds:["streetlight"],create:()=>[{id:"lamp",offsetM:{x:0,y:5,z:0},color:"#ffd9a0",intensity:2,pattern:{kind:"steady"}}]}];class w{static DUSK_SUN_ELEVATION_DEG=-.83;static ALWAYS=new Set(["airliner-narrow","airliner-wide","regional-turboprop","regional-jet","business-jet"]);static NONE=new Set(["glider","balloon"]);static BRIGHTNESS={"light-piston":[.5,.2,.5],"turboprop-light":[.7,.4,.8],ultralight:[.4,.2,.4],unmanned:[0,.05,0],"helicopter-light":[1,1,1],"helicopter-medium":[1,1,1],"helicopter-heavy":[1,1,1],"military-jet":[1,1,1]};static lampsOn(t,e){if(w.NONE.has(t))return{navigation:!1,beacon:!1,strobes:!1};if(w.ALWAYS.has(t))return{navigation:!0,beacon:!0,strobes:!0};const a=e<w.DUSK_SUN_ELEVATION_DEG;return t==="unmanned"?{navigation:!1,beacon:!1,strobes:a}:{navigation:a,beacon:a,strobes:a}}static lights(t,e){const a=w.lampsOn(t.kind,e),n=t.kind.startsWith("helicopter"),i=_t.find(c=>c.id===(n?"helicopter":"airliner")).create(),[r,s]=n?[5,7]:[17,18],o=t.spanM/2/r,l=t.lengthM/2/s,[d,h,u]=w.BRIGHTNESS[t.kind]??[1,1,1];return i.filter(c=>c.id.startsWith("nav")?a.navigation:c.id.startsWith("strobe")?a.strobes:c.id.startsWith("beacon")?a.beacon:!0).filter(c=>!(c.id.startsWith("beacon")&&!a.beacon)).map(c=>{const p=c.id.startsWith("nav")?d:c.id.startsWith("strobe")?h:u;return{...c,offsetM:{x:c.offsetM.x*o,y:c.offsetM.y,z:c.offsetM.z*l},intensity:(c.intensity??1)*p}}).filter(c=>(c.intensity??1)>0)}static bodyColor(t){return t.kind==="military-jet"?"#8a8e94":t.kind.startsWith("helicopter")?"#c8ccd1":t.kind==="unmanned"?"#2c2e33":"#dde0e4"}}class b{static ID_PREFIX=U.ID_PREFIX;static MAX_OBJECTS=40;static FT_TO_M=.3048;static DEG=Math.PI/180;static from(t,e,a,n=b.MAX_OBJECTS,i={}){return new Nt(t,e,a,n,i).build()}static idOf(t,e){return U.idOf(t,e)}static keyOf(t){return U.keyOf(t)}static HEIGHT_OVER_LENGTH=.29;static sizeOf(t){return{widthM:t.spanM,lengthM:t.lengthM,heightM:t.lengthM*b.HEIGHT_OVER_LENGTH}}static offsetOf(t,e){const a=L.seenFrom(t,{lat:e.lat,lng:e.lng,heightM:e.altitudeFt*b.FT_TO_M}),n=a.distanceKm*1e3,i=n*Math.cos(a.altitudeDeg*b.DEG);return{eastM:i*Math.sin(a.azimuthDeg*b.DEG),northM:i*Math.cos(a.azimuthDeg*b.DEG),upM:n*Math.sin(a.altitudeDeg*b.DEG),altitudeDeg:a.altitudeDeg,distanceKm:a.distanceKm}}static segments(t){const e=[];let a=[];for(const n of t.points){const i=a[a.length-1];i&&n.t-i.t>P.MAX_GAP_S*1e3&&(e.push(a),a=[]),a.push(n)}return e.push(a),e.filter(n=>n.length>=2)}static bearingDeg(t,e){return(Math.atan2(e.eastM-t.eastM,e.northM-t.northM)/b.DEG+360)%360}}class Nt{constructor(t,e,a,n,i){this.tracks=t,this.observer=e,this.startMs=a,this.maxObjects=n,this.options=i}build(){const t=[];for(const a of this.tracks){const n=b.keyOf(a),i=this.options.models?.get(n)??_.of(void 0);b.segments(a).forEach((r,s)=>{const o=r.map(c=>({point:c,at:b.offsetOf(this.observer,c)}));if(!o.some(c=>c.at.altitudeDeg>=0))return;const l=o.map((c,p)=>({t:c.point.t-this.startMs,eastM:c.at.eastM,northM:c.at.northM,altitudeM:c.at.upM,headingDeg:c.point.trackDeg??(p+1<o.length?b.bearingDeg(c.at,o[p+1].at):b.bearingDeg(o[p-1].at,c.at))})),d=b.idOf(a,s),h=o[Math.floor(o.length/2)].point,u=this.options.sunElevationAt?.(h)??90;t.push({object:{id:d,kind:"aircraft",eastM:l[0].eastM,northM:l[0].northM,headingDeg:l[0].headingDeg,sizeM:b.sizeOf(i),color:w.bodyColor(i),lights:w.lights(i,u),track:l},presence:{fromMs:l[0].t,untilMs:l[l.length-1].t},flight:{icao:a.icao,nonIcao:a.nonIcao,points:r},closestKm:Math.min(...o.map(c=>c.at.distanceKm))})})}t.sort((a,n)=>a.closestKm-n.closestKm);const e=t.slice(0,this.maxObjects);return{objects:e.map(a=>a.object),presence:new Map(e.map(a=>[a.object.id,a.presence])),flights:new Map(e.map(a=>[a.object.id,a.flight])),total:t.length,shown:e.length}}}const dt=[{id:"turbofan-narrow-body",name:"Turbofan airliner, narrow-body",kinds:["airliner-narrow"],totalDbA:148,shapeDb:[-32,-17,-9,-6,-5,-7,-12,-22],character:{toneHz:1800,toneShare:.3,humHz:90,humShare:.7}},{id:"turbofan-wide-body",name:"Turbofan airliner, wide-body",kinds:["airliner-wide"],totalDbA:151,shapeDb:[-28,-14,-7,-4,-3,-6,-12,-22],character:{toneHz:1200,toneShare:.3,humHz:70,humShare:.7}},{id:"regional-jet",name:"Regional jet",kinds:["regional-jet"],totalDbA:144,shapeDb:[-32,-17,-9,-5,-4,-6,-11,-21],character:{toneHz:1900,toneShare:.3,humHz:95,humShare:.7}},{id:"business-jet",name:"Business jet",kinds:["business-jet"],totalDbA:141,shapeDb:[-30,-15,-8,-4,-3,-4,-9,-19],character:{toneHz:2500,toneShare:.25,humHz:110,humShare:.7}},{id:"turboprop",name:"Turboprop",kinds:["regional-turboprop","turboprop-light"],totalDbA:138,shapeDb:[-14,-9,-8,-6,-8,-13,-20,-28],character:{toneHz:80,toneShare:.5}},{id:"light-piston",name:"Light piston aircraft",kinds:["light-piston"],totalDbA:130,shapeDb:[-18,-9,-5,-4,-8,-14,-22,-30],character:{toneHz:80,toneShare:.4}},{id:"ultralight",name:"Ultralight",kinds:["ultralight"],totalDbA:124,shapeDb:[-16,-8,-5,-4,-9,-15,-23,-31],character:{toneHz:140,toneShare:.4}},{id:"helicopter-light",name:"Light helicopter",kinds:["helicopter-light"],totalDbA:134,shapeDb:[-15,-8,-4,-3,-6,-10,-16,-24],character:{modulationHz:20,modulationDepth:.5}},{id:"helicopter-medium",name:"Medium helicopter",kinds:["helicopter-medium"],totalDbA:138,shapeDb:[-14,-7,-4,-3,-6,-10,-16,-24],character:{modulationHz:22,modulationDepth:.5}},{id:"helicopter-heavy",name:"Heavy helicopter",kinds:["helicopter-heavy"],totalDbA:144,shapeDb:[-12,-6,-4,-4,-7,-11,-17,-25],character:{modulationHz:17,modulationDepth:.5}},{id:"military-jet",name:"Military jet",kinds:["military-jet"],totalDbA:152,shapeDb:[-26,-12,-6,-3,-2,-3,-7,-15]},{id:"glider",name:"Glider",kinds:["glider"],totalDbA:85,shapeDb:[-30,-22,-15,-10,-8,-8,-14,-22]},{id:"balloon",name:"Hot-air balloon",kinds:["balloon"],totalDbA:100,shapeDb:[-25,-15,-9,-5,-3,-6,-12,-20]},{id:"unmanned",name:"Unmanned aircraft",kinds:["unmanned"],totalDbA:88,shapeDb:[-40,-30,-20,-12,-6,-3,-3,-8],character:{toneHz:450,toneShare:1}}],ot=dt.map(O=>({id:O.id,name:O.name,soundPowerA:O.shapeDb.map(t=>t+O.totalDbA-g.sumDb(O.shapeDb)),character:O.character}));class m{static DEFAULT_AMBIENT_DB_A=35;static DETECTION_MARGIN_DB=3;static AMBIENT_SHAPE_DB=[-12,-7,-5,-5,-7,-11,-17,-25];static HEARING_FLOOR_DB_A=0;static ITERATIONS=30;static CONVERGED_MS=.5;static VELOCITY_STEP_MS=500;static noiseOfKind(t){const e=dt.find(a=>a.kinds.includes(t));return ot.find(a=>a.id===(e?.id??"turbofan-narrow-body"))}static bandsAt(t,e,a=g.STANDARD){const n=20*Math.log10(Math.max(e*1e3,1))+11;return g.OCTAVES.map((i,r)=>t.soundPowerA[r]-n-g.absorptionDbPerKm(i,a)*e)}static couldBeHeard(t,e,a=m.DEFAULT_AMBIENT_DB_A,n=g.STANDARD){const i=m.ambientBands(a);return m.bandsAt(t,e,n).some((r,s)=>r>=Math.max(i[s]+m.DETECTION_MARGIN_DB,m.HEARING_FLOOR_DB_A))}static ambientBands(t){const e=m.AMBIENT_SHAPE_DB,a=g.sumDb(e);return e.map(n=>t+n-a)}static heardAt(t,e,a,n={}){const i=n.air??g.STANDARD,r=g.speedOfSound(i.temperatureC),s=t.points[t.points.length-1]?.t;if(s===void 0)return;let o=Math.min(a,s),l=P.positionAt(t,o);if(!l)return;let d=L.seenFrom(e,l.geo);for(let S=0;S<m.ITERATIONS;S++){const B=a-d.distanceKm*1e3*1e3/r,G=Math.abs(B-o);if(o=B,l=P.positionAt(t,o),!l)return;if(d=L.seenFrom(e,l.geo),G<m.CONVERGED_MS)break}const h=P.positionAt(t,a),u=h?L.seenFrom(e,h.geo):d,c=n.noise??ot[0],p=n.ambientDbA??m.DEFAULT_AMBIENT_DB_A,f=m.ambientBands(p),A=m.bandsAt(c,d.distanceKm,i),E=A.map((S,B)=>S>=Math.max(f[B]+m.DETECTION_MARGIN_DB,m.HEARING_FLOOR_DB_A)),T=A.indexOf(Math.max(...A)),I=E.lastIndexOf(!0);return{track:t,audible:E.some(Boolean),levelDbA:g.sumDb(A),bandsDbA:A,ambientDbA:p,delayS:(a-o)/1e3,emittedAtMs:o,sound:d,seen:u,lagDeg:m.angleBetween(d,u),dopplerRatio:m.doppler(t,e,o,r),dominantHz:g.OCTAVES[T],cutoffHz:I<0?void 0:g.OCTAVES[I]}}static profile(t,e,a,n,i=2e3,r={}){const s=[];let o,l,d=a;for(let h=a;h<=n;h+=i){const u=m.heardAt(t,e,h,r);u&&(!l||u.levelDbA>l.levelDbA)&&(l=u,d=h),u?.audible?o?o.untilMs=h:s.push(o={fromMs:h,untilMs:h}):o=void 0}return{track:t,audible:s,peakDbA:l?.levelDbA??-1/0,peakAtMs:d,peakDelayS:l?.delayS??0}}static angleBetween(t,e){const a=d=>{const h=d.altitudeDeg*Math.PI/180,u=d.azimuthDeg*Math.PI/180;return[Math.cos(h)*Math.sin(u),Math.cos(h)*Math.cos(u),Math.sin(h)]},[n,i,r]=a(t),[s,o,l]=a(e);return Math.acos(Math.min(1,Math.max(-1,n*s+i*o+r*l)))*180/Math.PI}static doppler(t,e,a,n){const i=m.VELOCITY_STEP_MS,r=P.positionAt(t,a-i),s=P.positionAt(t,a+i);if(!r||!s)return 1;const o=L.seenFrom(e,r.geo).distanceKm*1e3,l=L.seenFrom(e,s.geo).distanceKm*1e3;return 1/(1-(o-l)/(2*i/1e3)/n)}}class zt{static at(t,e,a,n,i={}){const r=P.seenFrom(t,a,n);if(!r)return;const s=_.of(e),o=m.heardAt(t,a,n,{noise:m.noiseOfKind(s.kind),...i});return{hex:`${t.nonIcao?"~":""}${t.icao.toString(16).padStart(6,"0")}`,registration:e?.registration,typeCode:s.code??e?.type,name:s.basis==="nothing"?void 0:s.name,kind:s.kind,basis:s.basis,military:e?.military===!0,restricted:e?.restricted===!0,altitudeFt:r.altitudeFt,groundSpeedKt:r.groundSpeedKt,trackDeg:r.trackDeg,sky:r.sky,angularRateDegPerS:r.angularRateDegPerS,hearing:o&&{audible:o.audible,levelDbA:o.levelDbA,ambientDbA:o.ambientDbA,delayS:o.delayS,lagDeg:o.lagDeg,dopplerRatio:o.dopplerRatio,cutoffHz:o.cutoffHz,dominantHz:o.dominantHz}}}}class y{static REFERENCE_AMPLITUDE=.02;static MASKING_RANGE_DB=6;static KNEE_DB=20;static COMPRESSION_RATIO=1.5;static EXPANSION_RATIO=1.8;static DEFAULT_MAX_VOICES=4;static candidates(t,e,a,n,i={}){const r=new Set;for(const[s,o]of t){const l=m.noiseOfKind(_.of(e.get(a(o))).kind);let d=1/0;for(const h of o.points)d=Math.min(d,L.seenFrom(n,{lat:h.lat,lng:h.lng,heightM:h.altitudeFt*.3048}).distanceKm);m.couldBeHeard(l,d,i.ambientDbA,i.air)&&r.add(s)}return r}static voices(t,e,a,n,i,r,s={}){const o=[];for(const l of t){const d=e.get(l);if(!d||s.only?.(l)===!1)continue;const h=_.of(a.get(n(d))).kind,u=m.noiseOfKind(h),c=m.heardAt(d,i,r,{...s,noise:u});c?.audible&&o.push({id:l,kind:h,bandAmplitudes:y.bandAmplitudes(c.bandsDbA,c.ambientDbA,s.referenceAmplitude),levelDbA:c.levelDbA,distanceKm:c.sound.distanceKm,dopplerRatio:c.dopplerRatio,azimuthDeg:c.sound.azimuthDeg,elevationDeg:c.sound.altitudeDeg,character:u.character})}return o.sort((l,d)=>d.levelDbA-l.levelDbA).slice(0,s.maxVoices??y.DEFAULT_MAX_VOICES)}static bandAmplitudes(t,e,a=y.REFERENCE_AMPLITUDE){const n=m.ambientBands(e),i=m.DETECTION_MARGIN_DB,r=g.sumDb(t),s=r-e,o=s>=y.KNEE_DB?y.KNEE_DB+(s-y.KNEE_DB)/y.COMPRESSION_RATIO:y.KNEE_DB-(y.KNEE_DB-s)*y.EXPANSION_RATIO,l=a*10**(o/20);return t.map((d,h)=>{const u=Math.min(1,Math.max(0,(d-n[h]-i+y.MASKING_RANGE_DB)/(2*y.MASKING_RANGE_DB)));return u*u*(3-2*u)*l*10**((d-r)/20)})}static BANDS_HZ=g.OCTAVES}class K{static ENGLISH={unnamed:"Aircraft {hex}",altitude:"{value} ft",speed:"{value} kt",heading:"heading {value}°",position:"{distance} km away, {elevation}° above the horizon, {bearing}",heard:"Heard at {level} dB(A), left the aircraft {delay} s ago, {lag}° behind it: {character}{pitch}",rumble:"a low rumble, nothing above {cutoff} Hz",muffled:"a dull noise, nothing above {cutoff} Hz",broad:"a broad roar",pitchHigher:", pitch {percent} % higher",pitchLower:", pitch {percent} % lower",inaudible:"Not audible here: {level} dB(A) against {ambient} dB(A) of ambient noise",soundUnknown:"Its sound cannot be worked out: the aircraft was not recorded yet when it left",contrailPersistent:"Leaves a trail that lasts: the air is supersaturated over ice ({rhi} % over ice)",contrailShort:"Leaves a short-lived trail: the air is dry over ice ({rhi} % over ice)",military:"military",restricted:"identity withheld by its owner",candidate:"A compatible candidate, not an identification"};static RUMBLE_BELOW_HZ=500;static DULL_BELOW_HZ=2e3;static PITCH_NOTICED=.03;static text(t,e,a,n){const i=(u,c=0)=>u.toLocaleString(n,{maximumFractionDigits:c}),r=(u,c)=>u.replace(/\{(\w+)\}/g,(p,f)=>c[f]??`{${f}}`),s=[],o=[t.registration,t.name].filter(Boolean).join(" · ");s.push(o||r(e.unnamed,{hex:t.hex}));const l=[r(e.altitude,{value:i(Math.round(t.altitudeFt/100)*100)}),t.groundSpeedKt===void 0?void 0:r(e.speed,{value:i(Math.round(t.groundSpeedKt))}),t.trackDeg===void 0?void 0:r(e.heading,{value:i(Math.round(t.trackDeg))})].filter(Boolean);s.push(l.join(" · ")),s.push(r(e.position,{distance:i(t.sky.distanceKm,t.sky.distanceKm<10?1:0),elevation:i(Math.round(t.sky.altitudeDeg)),bearing:a(t.sky.azimuthDeg)}));const d=t.hearing;if(!d)s.push(e.soundUnknown);else if(!d.audible)s.push(r(e.inaudible,{level:i(Math.round(d.levelDbA)),ambient:i(Math.round(d.ambientDbA))}));else{const u=d.cutoffHz??0,c=u<=K.RUMBLE_BELOW_HZ?e.rumble:u<=K.DULL_BELOW_HZ?e.muffled:e.broad,p=d.dopplerRatio-1,f=Math.abs(p)<K.PITCH_NOTICED?"":r(p>0?e.pitchHigher:e.pitchLower,{percent:i(Math.round(Math.abs(p)*100))});s.push(r(e.heard,{level:i(Math.round(d.levelDbA)),delay:i(Math.round(d.delayS)),lag:i(Math.round(d.lagDeg)),character:r(c,{cutoff:i(u)}),pitch:f}))}t.contrail&&s.push(r(t.contrail.persistent?e.contrailPersistent:e.contrailShort,{rhi:i(Math.round(t.contrail.iceRelativeHumidity*100))}));const h=[t.military?e.military:void 0,t.restricted?e.restricted:void 0].filter(Boolean);return h.length>0&&s.push(h.join(" · ")),s.push(e.candidate),s.join(`
|
|
2
|
+
`)}}class X{static EFFICIENCY={"airliner-narrow":.34,"airliner-wide":.38,"regional-jet":.32,"business-jet":.3,"military-jet":.22,unknown:.34};static efficiencyOf(t){return X.EFFICIENCY[t]}}class M{static EMISSION_INDEX_WATER=1.25;static COMBUSTION_HEAT=432e5;static AIR_HEAT_CAPACITY=1004;static MOLAR_MASS_RATIO=.622;static FT_TO_M=.3048;static TROPOPAUSE_M=11e3;static TROPOPAUSE_HPA=226.32;static ISOTHERMAL_SCALE_HEIGHT_M=6341.62;static pressureAtAltitudeFt(t){const e=t*M.FT_TO_M;return e<=M.TROPOPAUSE_M?1013.25*(1-225577e-10*e)**5.25588:M.TROPOPAUSE_HPA*Math.exp(-(e-M.TROPOPAUSE_M)/M.ISOTHERMAL_SCALE_HEIGHT_M)}static saturationOverWaterPa(t){const e=t+273.15;return Math.exp(54.842763-6763.22/e-4.21*Math.log(e)+367e-6*e+Math.tanh(.0415*(e-218.8))*(53.878-1331.22/e-9.44523*Math.log(e)+.014025*e))}static saturationOverIcePa(t){const e=t+273.15;return Math.exp(9.550426-5723.265/e+3.53068*Math.log(e)-.00728332*e)}static iceRelativeHumidity(t,e){return e*M.saturationOverWaterPa(t)/M.saturationOverIcePa(t)}static mixingSlope(t,e){return M.EMISSION_INDEX_WATER*M.AIR_HEAT_CAPACITY*t*100/(M.MOLAR_MASS_RATIO*M.COMBUSTION_HEAT*(1-e))}static criticalTemperatureC(t,e){const a=Math.log(M.mixingSlope(t,e)-.053);return-46.46+9.43*a+.72*a*a}static requiredHumidity(t,e,a){const n=M.criticalTemperatureC(t,e);return(M.mixingSlope(t,e)*(a-n)+M.saturationOverWaterPa(n))/M.saturationOverWaterPa(a)}static evaluate(t,e){const a=M.criticalTemperatureC(t.pressureHpa,e),n=M.requiredHumidity(t.pressureHpa,e,t.temperatureC),i=M.iceRelativeHumidity(t.temperatureC,t.relativeHumidity),r=t.temperatureC<a&&t.relativeHumidity>=n;return{forms:r,persistent:r&&i>=1,criticalTemperatureC:a,requiredHumidity:n,iceRelativeHumidity:i}}}class H{static HOLD_MS=36e5;static DEG=Math.PI/180;static GAS_CONSTANT_OVER_GRAVITY=287.05/9.80665;static at(t,e,a){if(t.length===0)return;const n=t[0],i=t[t.length-1];if(e<n.t-H.HOLD_MS||e>i.t+H.HOLD_MS)return;const r=t.findIndex(c=>c.t>e),s=r===0?t[0]:t[(r===-1?t.length:r)-1],o=r===-1||r===0?s:t[r],l=H.atLevel(s,a),d=H.atLevel(o,a);if(!l||!d)return;const h=o.t>s.t?Math.min(1,Math.max(0,(e-s.t)/(o.t-s.t))):0,u=(c,p)=>c+(p-c)*h;return{pressureHpa:a,temperatureC:u(l.temperatureC,d.temperatureC),relativeHumidity:u(l.relativeHumidity,d.relativeHumidity),driftEastMs:u(l.driftEastMs,d.driftEastMs),driftNorthMs:u(l.driftNorthMs,d.driftNorthMs),shearPerS:u(l.shearPerS,d.shearPerS)}}static atLevel(t,e){const a=t.levels;for(let n=0;n+1<a.length;n++){const i=a[n],r=a[n+1];if(e>i.pressureHpa||e<r.pressureHpa)continue;const s=(Math.log(i.pressureHpa)-Math.log(e))/(Math.log(i.pressureHpa)-Math.log(r.pressureHpa)),o=(c,p)=>c+(p-c)*s,l=c=>{const p=c.windFromDeg*H.DEG;return{east:-c.windSpeedMs*Math.sin(p),north:-c.windSpeedMs*Math.cos(p)}},d=l(i),h=l(r),u=H.GAS_CONSTANT_OVER_GRAVITY*((i.temperatureC+r.temperatureC)/2+273.15)*Math.log(i.pressureHpa/r.pressureHpa);return{pressureHpa:e,temperatureC:o(i.temperatureC,r.temperatureC),relativeHumidity:o(i.relativeHumidity,r.relativeHumidity),driftEastMs:o(d.east,h.east),driftNorthMs:o(d.north,h.north),shearPerS:Math.hypot(h.east-d.east,h.north-d.north)/u}}}}class Gt{static plan(t,e,a,n){if(a.length===0)return[];const i=[];for(const r of t.objects){const s=t.flights.get(r.id),o=r.track;if(!s||!o||o.length!==s.points.length)continue;const l=e?.get(U.keyOf(s))??_.of(void 0),d=X.efficiencyOf(l.kind);if(d===void 0)continue;const h=[];o.forEach((u,c)=>{const p=s.points[c],f=M.pressureAtAltitudeFt(p.altitudeFt),A=H.at(a,n+u.t,f),E=A&&M.evaluate(A,d);h.push({tMs:u.t,eastM:u.eastM,northM:u.northM,upM:u.altitudeM??0,forms:E?.forms??!1,persistent:E?.persistent??!1,lifetimeS:E?Y.lifetimeS(E.iceRelativeHumidity):0,driftEastMs:A?.driftEastMs??0,driftNorthMs:A?.driftNorthMs??0,shearPerS:A?.shearPerS??Y.TYPICAL_SHEAR_PER_S,iceRelativeHumidity:E?.iceRelativeHumidity??0})}),h.some((u,c)=>u.forms&&h[c+1]?.forms)&&i.push({id:r.id,spanM:l.spanM,points:h})}return i}}const ct=[500,400,300,250,200,150],Ht=["temperature","relative_humidity","wind_speed","wind_direction"],wt="2022-01-01",lt=.25;class kt{fetchImpl;baseUrl;cache=new Map;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.baseUrl=t.baseUrl??"https://historical-forecast-api.open-meteo.com/v1/forecast"}between(t,e,a){const n=new Date(e).toISOString().slice(0,10);if(n<wt)return Promise.resolve({status:"outside"});const i=new Date(a).toISOString().slice(0,10),s=`${`${Math.round(t.lat/lt)},${Math.round(t.lng/lt)}`}|${n}|${i}`;let o=this.cache.get(s);return o||(o=this.read(t,n,i),this.cache.set(s,o),o.then(l=>{l.status==="failed"&&this.cache.delete(s)})),o}async read(t,e,a){const n=ct.flatMap(s=>Ht.map(o=>`${o}_${s}hPa`)),i=new URLSearchParams({latitude:String(t.lat),longitude:String(t.lng),start_date:e,end_date:a,hourly:n.join(","),wind_speed_unit:"ms",timezone:"UTC"}),r=`${this.baseUrl}?${i}`;try{const s=await this.fetchImpl(r);if(!s.ok)return{status:"failed"};const o=await s.json();return this.decode(o,{id:"open-meteo-forecast",name:"Open-Meteo (historical forecast)",url:r})}catch{return{status:"failed"}}}decode(t,e){const a=t.hourly;if(!a?.time)return{status:"outside"};const n=[];return a.time.forEach((i,r)=>{const s=[];for(const o of ct){const l=p=>a[`${p}_${o}hPa`]?.[r],d=l("temperature"),h=l("relative_humidity"),u=l("wind_speed"),c=l("wind_direction");if([d,h,u,c].some(p=>p==null))return;s.push({pressureHpa:o,temperatureC:d,relativeHumidity:h/100,windSpeedMs:u,windFromDeg:c})}n.push({t:Date.parse(`${i}Z`),levels:s})}),n.length>0?{status:"found",samples:n,source:e}:{status:"outside"}}}const Ft=[{id:"open-meteo-forecast",name:"Open-Meteo (historical forecast)",credit:"Weather data by Open-Meteo.com, CC BY 4.0",creditUrl:"https://open-meteo.com/en/docs/historical-forecast-api",create:()=>new kt}];export{x as AircraftAudio,Gt as AircraftContrails,_ as AircraftModels,v as AmbientNoise,b as TrafficDecor,zt as TrafficInfos,y as TrafficSound,K as TrafficTooltip,Ft as UPPER_AIR_SOURCES};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class I{static FORMATION_S=.3;static DIFFUSION_M_PER_S=.2;static TYPICAL_SHEAR_PER_S=.003;static INITIAL_DEPTH_M=150;static DEEPENING_M_PER_S=.1;static YOUNG_OPTICAL_DEPTH=.5;static DILUTION_EXPONENT=.75;static MIXING_S=1500;static INVISIBLE=.006;static MIN_LIFETIME_S=15;static LIFETIME_SPAN_S=120;static widthM(t,E,_=I.TYPICAL_SHEAR_PER_S){const s=Math.max(0,E),N=_*(I.INITIAL_DEPTH_M*s+I.DEEPENING_M_PER_S*s*s/2);return t+I.DIFFUSION_M_PER_S*s+N}static lifetimeS(t){const E=Math.min(1,Math.max(0,t));return I.MIN_LIFETIME_S+I.LIFETIME_SPAN_S*E*E}static opacity(t,E){if(t<I.FORMATION_S)return 0;let _;if(E.persistent){const N=(E.spanM/I.widthM(E.spanM,t,E.shearPerS))**I.DILUTION_EXPONENT;_=I.YOUNG_OPTICAL_DEPTH*N*Math.exp(-t/I.MIXING_S)}else{if(t>=E.lifetimeS)return 0;_=I.YOUNG_OPTICAL_DEPTH*(1-t/E.lifetimeS)**2}const s=1-Math.exp(-_);return s<I.INVISIBLE?0:s}}export{I as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{G as T,n as w,v as N,M as A,w as G,x as O}from"./rr0-sighting.mjs";import{C as x}from"./ContrailGrowth-CuAzwIoc.js";class f{static MAX_SEGMENTS=4e3;static MIN_PIXELS=2;static UNRESOLVED_CONTRAST=.5;static VERTICES_PER_SEGMENT=12;object;group=new T;trails=[];positions=new Float32Array(f.MAX_SEGMENTS*f.VERTICES_PER_SEGMENT*3);colors=new Float32Array(f.MAX_SEGMENTS*f.VERTICES_PER_SEGMENT*4);segments=0;constructor(){const t=new w;t.setAttribute("position",new N(this.positions,3)),t.setAttribute("color",new N(this.colors,4)),t.setDrawRange(0,0),this.object=new A(t,new G({vertexColors:!0,transparent:!0,depthWrite:!1,side:O})),this.object.frustumCulled=!1,this.object.name="contrails",this.group.name="contrails",this.group.add(this.object)}get segmentCount(){return this.segments}set(t){this.trails=t}update(t,s,r){let h=0;this.segments=0;for(const i of this.trails){const a=this.samplesOf(i,t,s),e=r(i.id);for(let c=0;c+1<a.length;c++){const o=a[c],p=a[c+1];if(!o.forms||!p.forms)continue;if(this.segments>=f.MAX_SEGMENTS)break;const l=this.pushSegment(h,o,p,i.spanM,e,s);l>h&&this.segments++,h=l}}const M=this.object.geometry;M.setDrawRange(0,h);for(const[i,a]of[["position",3],["color",4]]){const e=M.getAttribute(i);e.clearUpdateRanges(),h>0&&e.addUpdateRange(0,h*a),e.needsUpdate=!0}}samplesOf(t,s,r){const h=s-x.FORMATION_S*1e3,M=[],i=(o,p,l,d,m,y)=>({x:p+o.driftEastMs*m+r.origin.x,y:d,z:-(l+o.driftNorthMs*m)+r.origin.z,age:m,forms:y,point:o});let a=-1;t.points.forEach((o,p)=>{o.tMs>h||(a=p,M.push(i(o,o.eastM,o.northM,o.upM,(s-o.tMs)/1e3,o.forms)))});const e=t.points[a],c=t.points[a+1];if(e&&c){const o=(h-e.tMs)/(c.tMs-e.tMs),p=(l,d)=>l+(d-l)*o;M.push(i(e,p(e.eastM,c.eastM),p(e.northM,c.northM),p(e.upM,c.upM),x.FORMATION_S,e.forms&&c.forms))}return M}pushSegment(t,s,r,h,M,i){const a={persistent:s.point.persistent,lifetimeS:s.point.lifetimeS,spanM:h,shearPerS:s.point.shearPerS},e=x.opacity(s.age,a),c=x.opacity(r.age,a);if(e<=0&&c<=0)return t;const o={x:r.x-s.x,y:r.y-s.y,z:r.z-s.z};if(Math.hypot(o.x,o.y,o.z)<1e-6)return t;const p={x:(s.x+r.x)/2-i.eye.x,y:(s.y+r.y)/2-i.eye.y,z:(s.z+r.z)/2-i.eye.z},l=this.normalise(this.cross(o,p)),d=(n,u)=>{const g=Math.hypot(n.x-i.eye.x,n.y-i.eye.y,n.z-i.eye.z),E=x.widthM(h,n.age,n.point.shearPerS),R=Math.max(E,f.MIN_PIXELS*i.pixelRad*g);return{half:R/2,alpha:u*(E/R)**f.UNRESOLVED_CONTRAST}},m=[{sample:s,...d(s,e)},{sample:r,...d(r,c)}],y=(n,u)=>{const g=t*3;this.positions[g]=n.sample.x+l.x*n.half*u,this.positions[g+1]=n.sample.y+l.y*n.half*u,this.positions[g+2]=n.sample.z+l.z*n.half*u;const E=t*4;this.colors[E]=M[0],this.colors[E+1]=M[1],this.colors[E+2]=M[2],this.colors[E+3]=u===0?n.alpha:0,t++},[S,z]=m;for(const[n,u]of[[-1,0],[1,0]])y(S,n),y(S,u),y(z,n),y(S,u),y(z,u),y(z,n);return t}cross(t,s){return{x:t.y*s.z-t.z*s.y,y:t.z*s.x-t.x*s.z,z:t.x*s.y-t.y*s.x}}normalise(t){const s=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/s,y:t.y/s,z:t.z/s}}dispose(){this.object.geometry.dispose(),this.object.material.dispose(),this.group.removeFromParent()}}export{f as ContrailSystem};
|