@holoscript/engine 6.0.3 → 6.0.4
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/AutoMesher-CK47F6AV.js +17 -0
- package/dist/GPUBuffers-2LHBCD7X.js +9 -0
- package/dist/WebGPUContext-TNEUYU2Y.js +11 -0
- package/dist/animation/index.cjs +38 -38
- package/dist/animation/index.d.cts +1 -1
- package/dist/animation/index.d.ts +1 -1
- package/dist/animation/index.js +1 -1
- package/dist/audio/index.cjs +16 -6
- package/dist/audio/index.d.cts +1 -1
- package/dist/audio/index.d.ts +1 -1
- package/dist/audio/index.js +1 -1
- package/dist/camera/index.cjs +23 -23
- package/dist/camera/index.d.cts +1 -1
- package/dist/camera/index.d.ts +1 -1
- package/dist/camera/index.js +1 -1
- package/dist/character/index.cjs +6 -4
- package/dist/character/index.js +1 -1
- package/dist/choreography/index.cjs +1194 -0
- package/dist/choreography/index.d.cts +687 -0
- package/dist/choreography/index.d.ts +687 -0
- package/dist/choreography/index.js +1156 -0
- package/dist/chunk-2CSNRI2N.js +217 -0
- package/dist/chunk-33T2WINR.js +266 -0
- package/dist/chunk-35R73OFM.js +1257 -0
- package/dist/chunk-4MMDSUNP.js +1256 -0
- package/dist/chunk-5V6HOU72.js +319 -0
- package/dist/chunk-6QOP6PYF.js +1038 -0
- package/dist/chunk-7KMJVHIL.js +8944 -0
- package/dist/chunk-7VPUC62U.js +1106 -0
- package/dist/chunk-A2Y6RCAT.js +1878 -0
- package/dist/chunk-AHM42MK6.js +8944 -0
- package/dist/chunk-BL7IDTHE.js +218 -0
- package/dist/chunk-CITOMSWL.js +10462 -0
- package/dist/chunk-CXDPKW2K.js +8944 -0
- package/dist/chunk-CXZPLD4S.js +223 -0
- package/dist/chunk-CZYJE7IH.js +5169 -0
- package/dist/chunk-D2OP7YC7.js +6325 -0
- package/dist/chunk-EDRVQHUU.js +1544 -0
- package/dist/chunk-EJSLOOW2.js +3589 -0
- package/dist/chunk-F53SFGW5.js +1878 -0
- package/dist/chunk-HCFPELPY.js +919 -0
- package/dist/chunk-HNEE36PY.js +93 -0
- package/dist/chunk-HYXNV36F.js +1256 -0
- package/dist/chunk-IB7KHVFY.js +821 -0
- package/dist/chunk-IBBO7YYG.js +690 -0
- package/dist/chunk-ILIBGINU.js +5470 -0
- package/dist/chunk-IS4MHLKN.js +5479 -0
- package/dist/chunk-JT2PFKWD.js +5479 -0
- package/dist/chunk-K4CUB4NY.js +1038 -0
- package/dist/chunk-KATDQXRJ.js +10462 -0
- package/dist/chunk-KBQE6ZFJ.js +8944 -0
- package/dist/chunk-KBVD5K7E.js +560 -0
- package/dist/chunk-KCDPVQRY.js +4088 -0
- package/dist/chunk-KN4QJPKN.js +8944 -0
- package/dist/chunk-KWJ3ROSI.js +8944 -0
- package/dist/chunk-L45VF6DD.js +919 -0
- package/dist/chunk-LY4T37YK.js +307 -0
- package/dist/chunk-MDN5WZXA.js +1544 -0
- package/dist/chunk-MGCDP6VU.js +928 -0
- package/dist/chunk-NCX7X6G2.js +8681 -0
- package/dist/chunk-OF54BPVD.js +913 -0
- package/dist/chunk-OWSN2Q3Q.js +690 -0
- package/dist/chunk-PRRB5TTA.js +406 -0
- package/dist/chunk-PXWVQF76.js +4086 -0
- package/dist/chunk-PYCOIDT2.js +812 -0
- package/dist/chunk-PZCSADOV.js +928 -0
- package/dist/chunk-Q2XBVS2K.js +1038 -0
- package/dist/chunk-QDZRXWN5.js +1776 -0
- package/dist/chunk-RNWOZ6WQ.js +913 -0
- package/dist/chunk-ROLFT4CJ.js +1693 -0
- package/dist/chunk-SLTJRZ2N.js +266 -0
- package/dist/chunk-SRUS5XSU.js +4088 -0
- package/dist/chunk-TKCA3WZ5.js +5409 -0
- package/dist/chunk-TNRMXYI2.js +1650 -0
- package/dist/chunk-TQB3GJGM.js +9763 -0
- package/dist/chunk-TUFGXG6K.js +510 -0
- package/dist/chunk-U6KMTGQJ.js +632 -0
- package/dist/chunk-VMGJQST6.js +8681 -0
- package/dist/chunk-X4F4TCG4.js +5470 -0
- package/dist/chunk-ZIFROE75.js +1544 -0
- package/dist/chunk-ZIJQYHSQ.js +1204 -0
- package/dist/combat/index.cjs +4 -4
- package/dist/combat/index.d.cts +1 -1
- package/dist/combat/index.d.ts +1 -1
- package/dist/combat/index.js +1 -1
- package/dist/ecs/index.cjs +1 -1
- package/dist/ecs/index.js +1 -1
- package/dist/environment/index.cjs +14 -14
- package/dist/environment/index.d.cts +1 -1
- package/dist/environment/index.d.ts +1 -1
- package/dist/environment/index.js +1 -1
- package/dist/gpu/index.cjs +4810 -0
- package/dist/gpu/index.js +3714 -0
- package/dist/hologram/index.cjs +27 -1
- package/dist/hologram/index.js +1 -1
- package/dist/index-B2PIsAmR.d.cts +2180 -0
- package/dist/index-B2PIsAmR.d.ts +2180 -0
- package/dist/index-BHySEPX7.d.cts +2921 -0
- package/dist/index-BJV21zuy.d.cts +341 -0
- package/dist/index-BJV21zuy.d.ts +341 -0
- package/dist/index-BQutTphC.d.cts +790 -0
- package/dist/index-ByIq2XrS.d.cts +3910 -0
- package/dist/index-BysHjDSO.d.cts +224 -0
- package/dist/index-BysHjDSO.d.ts +224 -0
- package/dist/index-CKwAJGck.d.ts +455 -0
- package/dist/index-CUl3QstQ.d.cts +3006 -0
- package/dist/index-CUl3QstQ.d.ts +3006 -0
- package/dist/index-CmYtNiI-.d.cts +953 -0
- package/dist/index-CmYtNiI-.d.ts +953 -0
- package/dist/index-CnRzWxi_.d.cts +522 -0
- package/dist/index-CnRzWxi_.d.ts +522 -0
- package/dist/index-CwRWbSC7.d.ts +2921 -0
- package/dist/index-CxKIBstO.d.ts +790 -0
- package/dist/index-DJ6-R8vh.d.cts +455 -0
- package/dist/index-DQKisbcI.d.cts +4968 -0
- package/dist/index-DQKisbcI.d.ts +4968 -0
- package/dist/index-DRT2zJez.d.ts +3910 -0
- package/dist/index-DfNLiAka.d.cts +192 -0
- package/dist/index-DfNLiAka.d.ts +192 -0
- package/dist/index-nMvkoRm8.d.cts +405 -0
- package/dist/index-nMvkoRm8.d.ts +405 -0
- package/dist/index-s9yOFU37.d.cts +604 -0
- package/dist/index-s9yOFU37.d.ts +604 -0
- package/dist/index.cjs +22966 -6960
- package/dist/index.d.cts +864 -20
- package/dist/index.d.ts +864 -20
- package/dist/index.js +3062 -48
- package/dist/input/index.cjs +1 -1
- package/dist/input/index.js +1 -1
- package/dist/orbital/index.cjs +3 -3
- package/dist/orbital/index.d.cts +1 -1
- package/dist/orbital/index.d.ts +1 -1
- package/dist/orbital/index.js +1 -1
- package/dist/particles/index.cjs +16 -16
- package/dist/particles/index.d.cts +1 -1
- package/dist/particles/index.d.ts +1 -1
- package/dist/particles/index.js +1 -1
- package/dist/physics/index.cjs +2377 -21
- package/dist/physics/index.d.cts +1 -1
- package/dist/physics/index.d.ts +1 -1
- package/dist/physics/index.js +35 -1
- package/dist/postfx/index.cjs +3491 -0
- package/dist/postfx/index.js +93 -0
- package/dist/procedural/index.cjs +1 -1
- package/dist/procedural/index.js +1 -1
- package/dist/puppeteer-5VF6KDVO.js +52197 -0
- package/dist/puppeteer-IZVZ3SG4.js +52197 -0
- package/dist/rendering/index.cjs +33 -32
- package/dist/rendering/index.d.cts +1 -1
- package/dist/rendering/index.d.ts +1 -1
- package/dist/rendering/index.js +8 -6
- package/dist/runtime/index.cjs +23 -13
- package/dist/runtime/index.d.cts +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +8 -6
- package/dist/runtime/protocols/index.cjs +349 -0
- package/dist/runtime/protocols/index.js +15 -0
- package/dist/scene/index.cjs +8 -8
- package/dist/scene/index.d.cts +1 -1
- package/dist/scene/index.d.ts +1 -1
- package/dist/scene/index.js +1 -1
- package/dist/shader/index.cjs +3087 -0
- package/dist/shader/index.js +3044 -0
- package/dist/simulation/index.cjs +10680 -0
- package/dist/simulation/index.d.cts +3 -0
- package/dist/simulation/index.d.ts +3 -0
- package/dist/simulation/index.js +307 -0
- package/dist/spatial/index.cjs +2443 -0
- package/dist/spatial/index.d.cts +1545 -0
- package/dist/spatial/index.d.ts +1545 -0
- package/dist/spatial/index.js +2400 -0
- package/dist/terrain/index.cjs +1 -1
- package/dist/terrain/index.d.cts +1 -1
- package/dist/terrain/index.d.ts +1 -1
- package/dist/terrain/index.js +1 -1
- package/dist/transformers.node-4NKAPD5U.js +45620 -0
- package/dist/vm/index.cjs +7 -8
- package/dist/vm/index.d.cts +1 -1
- package/dist/vm/index.d.ts +1 -1
- package/dist/vm/index.js +1 -1
- package/dist/vm-bridge/index.cjs +2 -2
- package/dist/vm-bridge/index.d.cts +2 -2
- package/dist/vm-bridge/index.d.ts +2 -2
- package/dist/vm-bridge/index.js +1 -1
- package/dist/vr/index.cjs +6 -6
- package/dist/vr/index.js +1 -1
- package/dist/world/index.cjs +3 -3
- package/dist/world/index.d.cts +1 -1
- package/dist/world/index.d.ts +1 -1
- package/dist/world/index.js +1 -1
- package/package.json +53 -21
- package/LICENSE +0 -21
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-AKLW2MUS.js";
|
|
4
|
+
|
|
5
|
+
// src/orbital/index.ts
|
|
6
|
+
var orbital_exports = {};
|
|
7
|
+
__export(orbital_exports, {
|
|
8
|
+
AttentionEngine: () => AttentionEngine,
|
|
9
|
+
TimeManager: () => TimeManager,
|
|
10
|
+
calculatePosition: () => calculatePosition,
|
|
11
|
+
dateToJulian: () => dateToJulian,
|
|
12
|
+
generateOrbitalPath: () => generateOrbitalPath,
|
|
13
|
+
julianToDate: () => julianToDate,
|
|
14
|
+
toDegrees: () => toDegrees
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// src/orbital/KeplerianCalculator.ts
|
|
18
|
+
function toRadians(degrees) {
|
|
19
|
+
return degrees * (Math.PI / 180);
|
|
20
|
+
}
|
|
21
|
+
function toDegrees(radians) {
|
|
22
|
+
return radians * (180 / Math.PI);
|
|
23
|
+
}
|
|
24
|
+
function normalizeAngle(degrees) {
|
|
25
|
+
degrees = degrees % 360;
|
|
26
|
+
if (degrees < 0) degrees += 360;
|
|
27
|
+
return degrees;
|
|
28
|
+
}
|
|
29
|
+
function solveKeplerEquation(meanAnomaly, eccentricity, tolerance = 1e-8) {
|
|
30
|
+
let E = meanAnomaly;
|
|
31
|
+
let delta = Infinity;
|
|
32
|
+
let iterations = 0;
|
|
33
|
+
const maxIterations = 100;
|
|
34
|
+
while (Math.abs(delta) > tolerance && iterations < maxIterations) {
|
|
35
|
+
const f = E - eccentricity * Math.sin(E) - meanAnomaly;
|
|
36
|
+
const fPrime = 1 - eccentricity * Math.cos(E);
|
|
37
|
+
delta = f / fPrime;
|
|
38
|
+
E = E - delta;
|
|
39
|
+
iterations++;
|
|
40
|
+
}
|
|
41
|
+
return E;
|
|
42
|
+
}
|
|
43
|
+
function calculateTrueAnomaly(eccentricAnomaly, eccentricity) {
|
|
44
|
+
const cosE = Math.cos(eccentricAnomaly);
|
|
45
|
+
const sinE = Math.sin(eccentricAnomaly);
|
|
46
|
+
const cosV = (cosE - eccentricity) / (1 - eccentricity * cosE);
|
|
47
|
+
const sinV = Math.sqrt(1 - eccentricity * eccentricity) * sinE / (1 - eccentricity * cosE);
|
|
48
|
+
return Math.atan2(sinV, cosV);
|
|
49
|
+
}
|
|
50
|
+
function calculatePosition(elements, julianDate) {
|
|
51
|
+
const {
|
|
52
|
+
semiMajorAxis,
|
|
53
|
+
eccentricity,
|
|
54
|
+
inclination,
|
|
55
|
+
longitudeAscending,
|
|
56
|
+
argumentPeriapsis,
|
|
57
|
+
meanAnomalyEpoch,
|
|
58
|
+
orbitalPeriod
|
|
59
|
+
} = elements;
|
|
60
|
+
const meanMotion = 360 / orbitalPeriod;
|
|
61
|
+
const meanAnomaly = normalizeAngle(meanAnomalyEpoch + meanMotion * julianDate);
|
|
62
|
+
const M = toRadians(meanAnomaly);
|
|
63
|
+
const E = solveKeplerEquation(M, eccentricity);
|
|
64
|
+
const v = calculateTrueAnomaly(E, eccentricity);
|
|
65
|
+
const r = semiMajorAxis * (1 - eccentricity * Math.cos(E));
|
|
66
|
+
const xOrbital = r * Math.cos(v);
|
|
67
|
+
const yOrbital = r * Math.sin(v);
|
|
68
|
+
const i = toRadians(inclination);
|
|
69
|
+
const omega = toRadians(argumentPeriapsis);
|
|
70
|
+
const Omega = toRadians(longitudeAscending);
|
|
71
|
+
const cosOmega = Math.cos(omega);
|
|
72
|
+
const sinOmega = Math.sin(omega);
|
|
73
|
+
const cosI = Math.cos(i);
|
|
74
|
+
const sinI = Math.sin(i);
|
|
75
|
+
const cosCapOmega = Math.cos(Omega);
|
|
76
|
+
const sinCapOmega = Math.sin(Omega);
|
|
77
|
+
const x = (cosCapOmega * cosOmega - sinCapOmega * sinOmega * cosI) * xOrbital + (-cosCapOmega * sinOmega - sinCapOmega * cosOmega * cosI) * yOrbital;
|
|
78
|
+
const y = (sinCapOmega * cosOmega + cosCapOmega * sinOmega * cosI) * xOrbital + (-sinCapOmega * sinOmega + cosCapOmega * cosOmega * cosI) * yOrbital;
|
|
79
|
+
const z = sinOmega * sinI * xOrbital + cosOmega * sinI * yOrbital;
|
|
80
|
+
return { x, y, z };
|
|
81
|
+
}
|
|
82
|
+
function dateToJulian(date) {
|
|
83
|
+
const j2000 = (/* @__PURE__ */ new Date("2000-01-01T12:00:00Z")).getTime();
|
|
84
|
+
const ms = date.getTime();
|
|
85
|
+
return (ms - j2000) / (1e3 * 60 * 60 * 24);
|
|
86
|
+
}
|
|
87
|
+
function julianToDate(julianDate) {
|
|
88
|
+
const j2000 = (/* @__PURE__ */ new Date("2000-01-01T12:00:00Z")).getTime();
|
|
89
|
+
const ms = j2000 + julianDate * (1e3 * 60 * 60 * 24);
|
|
90
|
+
return new Date(ms);
|
|
91
|
+
}
|
|
92
|
+
function generateOrbitalPath(elements, numPoints = 100) {
|
|
93
|
+
const points = [];
|
|
94
|
+
const orbitalPeriod = elements.orbitalPeriod;
|
|
95
|
+
for (let i = 0; i < numPoints; i++) {
|
|
96
|
+
const julianDate = i / numPoints * orbitalPeriod;
|
|
97
|
+
points.push(calculatePosition(elements, julianDate));
|
|
98
|
+
}
|
|
99
|
+
points.push(points[0]);
|
|
100
|
+
return points;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// src/orbital/TimeManager.ts
|
|
104
|
+
var TimeManager = class {
|
|
105
|
+
julianDate;
|
|
106
|
+
timeScale = 1;
|
|
107
|
+
// 1 = real-time, 10 = 10x speed
|
|
108
|
+
isPaused = false;
|
|
109
|
+
lastUpdateTime = 0;
|
|
110
|
+
callbacks = /* @__PURE__ */ new Set();
|
|
111
|
+
intervalId = null;
|
|
112
|
+
constructor(startDate = /* @__PURE__ */ new Date()) {
|
|
113
|
+
this.julianDate = dateToJulian(startDate);
|
|
114
|
+
this.lastUpdateTime = Date.now();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Start the time simulation loop
|
|
118
|
+
*/
|
|
119
|
+
start() {
|
|
120
|
+
if (this.intervalId !== null) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this.lastUpdateTime = Date.now();
|
|
124
|
+
this.intervalId = setInterval(() => {
|
|
125
|
+
this.update(Date.now());
|
|
126
|
+
}, 1e3 / 60);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Stop the time simulation loop
|
|
130
|
+
*/
|
|
131
|
+
stop() {
|
|
132
|
+
if (this.intervalId !== null) {
|
|
133
|
+
clearInterval(this.intervalId);
|
|
134
|
+
this.intervalId = null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Update tick
|
|
139
|
+
*/
|
|
140
|
+
update(currentTime) {
|
|
141
|
+
if (!this.isPaused) {
|
|
142
|
+
const deltaMs = currentTime - this.lastUpdateTime;
|
|
143
|
+
this.advance(deltaMs);
|
|
144
|
+
}
|
|
145
|
+
this.lastUpdateTime = currentTime;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Advance simulation time
|
|
149
|
+
*
|
|
150
|
+
* @param deltaMs - Milliseconds elapsed in real time
|
|
151
|
+
*/
|
|
152
|
+
advance(deltaMs) {
|
|
153
|
+
if (this.isPaused) return;
|
|
154
|
+
const realDays = deltaMs / (1e3 * 60 * 60 * 24);
|
|
155
|
+
const simulationDays = realDays * this.timeScale;
|
|
156
|
+
this.julianDate += simulationDays;
|
|
157
|
+
this.notifyCallbacks();
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Pause time progression
|
|
161
|
+
*/
|
|
162
|
+
pause() {
|
|
163
|
+
this.isPaused = true;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Resume time progression
|
|
167
|
+
*/
|
|
168
|
+
play() {
|
|
169
|
+
this.isPaused = false;
|
|
170
|
+
this.lastUpdateTime = Date.now();
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Toggle pause/play
|
|
174
|
+
*/
|
|
175
|
+
togglePause() {
|
|
176
|
+
if (this.isPaused) {
|
|
177
|
+
this.play();
|
|
178
|
+
} else {
|
|
179
|
+
this.pause();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Set time scale (speed multiplier)
|
|
184
|
+
*
|
|
185
|
+
* @param scale - Time scale (1 = real-time, 10 = 10x speed, etc.)
|
|
186
|
+
*/
|
|
187
|
+
setTimeScale(scale) {
|
|
188
|
+
this.timeScale = Math.max(0.1, scale);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Get current time scale
|
|
192
|
+
*/
|
|
193
|
+
getTimeScale() {
|
|
194
|
+
return this.timeScale;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Set simulation date
|
|
198
|
+
*
|
|
199
|
+
* @param date - JavaScript Date object
|
|
200
|
+
*/
|
|
201
|
+
setDate(date) {
|
|
202
|
+
this.julianDate = dateToJulian(date);
|
|
203
|
+
this.notifyCallbacks();
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get current simulation date as Julian date
|
|
207
|
+
*/
|
|
208
|
+
getJulianDate() {
|
|
209
|
+
return this.julianDate;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Get current simulation date as JavaScript Date
|
|
213
|
+
*/
|
|
214
|
+
getDate() {
|
|
215
|
+
return julianToDate(this.julianDate);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Check if time is paused
|
|
219
|
+
*/
|
|
220
|
+
getIsPaused() {
|
|
221
|
+
return this.isPaused;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Register a callback for time updates
|
|
225
|
+
*
|
|
226
|
+
* @param callback - Function to call when time updates
|
|
227
|
+
*/
|
|
228
|
+
onUpdate(callback) {
|
|
229
|
+
this.callbacks.add(callback);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Unregister a time update callback
|
|
233
|
+
*
|
|
234
|
+
* @param callback - Callback function to remove
|
|
235
|
+
*/
|
|
236
|
+
offUpdate(callback) {
|
|
237
|
+
this.callbacks.delete(callback);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Notify all registered callbacks of time update
|
|
241
|
+
*/
|
|
242
|
+
notifyCallbacks() {
|
|
243
|
+
const date = this.getDate();
|
|
244
|
+
for (const callback of this.callbacks) {
|
|
245
|
+
callback(this.julianDate, date);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Get time state for serialization
|
|
250
|
+
*/
|
|
251
|
+
getState() {
|
|
252
|
+
return {
|
|
253
|
+
julianDate: this.julianDate,
|
|
254
|
+
timeScale: this.timeScale,
|
|
255
|
+
isPaused: this.isPaused,
|
|
256
|
+
date: this.getDate().toISOString()
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
// src/orbital/AttentionEngine.ts
|
|
262
|
+
var AttentionEngine = class {
|
|
263
|
+
/**
|
|
264
|
+
* Calculates the attention weight of a target entity relative to an observer.
|
|
265
|
+
* Incorporates 4 factors: Proximity, Movement, Base Saliency, and Recency (mocked).
|
|
266
|
+
*/
|
|
267
|
+
static calculateWeight(observerPos, target) {
|
|
268
|
+
const dx = target.position[0] - observerPos[0];
|
|
269
|
+
const dy = target.position[1] - observerPos[1];
|
|
270
|
+
const dz = target.position[2] - observerPos[2];
|
|
271
|
+
const distSq = dx * dx + dy * dy + dz * dz;
|
|
272
|
+
const proximityWeight = Math.max(0, 1 - distSq / 1e4);
|
|
273
|
+
let movementWeight = 0;
|
|
274
|
+
if (target.velocity) {
|
|
275
|
+
const speedSq = target.velocity.x ** 2 + target.velocity.y ** 2 + target.velocity.z ** 2;
|
|
276
|
+
movementWeight = Math.min(1, speedSq / 100);
|
|
277
|
+
}
|
|
278
|
+
const saliencyWeight = target.saliencyBase || 0.1;
|
|
279
|
+
const recencyWeight = 0.5;
|
|
280
|
+
const total = proximityWeight * 0.5 + movementWeight * 0.3 + saliencyWeight * 0.1 + recencyWeight * 0.1;
|
|
281
|
+
return Math.min(1, Math.max(0, total));
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Filters a massive array of entities down to strictly the top K most attended
|
|
285
|
+
* objects around the observer to save inference/rendering payload.
|
|
286
|
+
*/
|
|
287
|
+
static getTopKEntities(observerPos, entities, k) {
|
|
288
|
+
if (entities.length <= k) return entities.map((e) => e.id);
|
|
289
|
+
const scores = entities.map((e) => ({
|
|
290
|
+
entityId: e.id,
|
|
291
|
+
weight: this.calculateWeight(observerPos, e)
|
|
292
|
+
}));
|
|
293
|
+
scores.sort((a, b) => b.weight - a.weight);
|
|
294
|
+
return scores.slice(0, k).map((s) => s.entityId);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
export {
|
|
299
|
+
toDegrees,
|
|
300
|
+
calculatePosition,
|
|
301
|
+
dateToJulian,
|
|
302
|
+
julianToDate,
|
|
303
|
+
generateOrbitalPath,
|
|
304
|
+
TimeManager,
|
|
305
|
+
AttentionEngine,
|
|
306
|
+
orbital_exports
|
|
307
|
+
};
|