@buley/hexgrid-3d 3.0.1 → 3.2.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 (209) hide show
  1. package/dist/HexGridEnhanced.d.ts +15 -0
  2. package/dist/HexGridEnhanced.d.ts.map +1 -0
  3. package/dist/HexGridEnhanced.js +1 -0
  4. package/dist/Snapshot.d.ts +594 -0
  5. package/dist/Snapshot.d.ts.map +1 -0
  6. package/dist/Snapshot.js +757 -0
  7. package/dist/adapters/DashAdapter.d.ts +18 -0
  8. package/dist/adapters/DashAdapter.d.ts.map +1 -0
  9. package/dist/adapters/DashAdapter.js +42 -0
  10. package/dist/adapters.d.ts +53 -0
  11. package/dist/adapters.d.ts.map +1 -0
  12. package/dist/adapters.js +14 -0
  13. package/dist/algorithms/AdvancedStatistics.d.ts +52 -0
  14. package/dist/algorithms/AdvancedStatistics.d.ts.map +1 -0
  15. package/dist/algorithms/AdvancedStatistics.js +307 -0
  16. package/dist/algorithms/BayesianStatistics.d.ts +86 -0
  17. package/dist/algorithms/BayesianStatistics.d.ts.map +1 -0
  18. package/dist/algorithms/BayesianStatistics.js +263 -0
  19. package/dist/algorithms/FlowField.d.ts +55 -0
  20. package/dist/algorithms/FlowField.d.ts.map +1 -0
  21. package/dist/algorithms/FlowField.js +80 -0
  22. package/dist/algorithms/FlowField3D.d.ts +166 -0
  23. package/dist/algorithms/FlowField3D.d.ts.map +1 -0
  24. package/dist/algorithms/FlowField3D.js +327 -0
  25. package/dist/algorithms/FluidEngineFactory.d.ts +15 -0
  26. package/dist/algorithms/FluidEngineFactory.d.ts.map +1 -0
  27. package/dist/algorithms/FluidEngineFactory.js +41 -0
  28. package/dist/algorithms/FluidSimulation.d.ts +41 -0
  29. package/dist/algorithms/FluidSimulation.d.ts.map +1 -0
  30. package/dist/algorithms/FluidSimulation.js +74 -0
  31. package/dist/algorithms/FluidSimulation3D.d.ts +137 -0
  32. package/dist/algorithms/FluidSimulation3D.d.ts.map +1 -0
  33. package/dist/algorithms/FluidSimulation3D.js +464 -0
  34. package/dist/algorithms/FluidSimulation3DGPU.d.ts +41 -0
  35. package/dist/algorithms/FluidSimulation3DGPU.d.ts.map +1 -0
  36. package/dist/algorithms/FluidSimulation3DGPU.js +328 -0
  37. package/dist/algorithms/FluidSimulationWebNN.d.ts +56 -0
  38. package/dist/algorithms/FluidSimulationWebNN.d.ts.map +1 -0
  39. package/dist/algorithms/FluidSimulationWebNN.js +84 -0
  40. package/dist/algorithms/GraphAlgorithms.d.ts +48 -0
  41. package/dist/algorithms/GraphAlgorithms.d.ts.map +1 -0
  42. package/dist/algorithms/GraphAlgorithms.js +122 -0
  43. package/dist/algorithms/OutlierDetection.d.ts +49 -0
  44. package/dist/algorithms/OutlierDetection.d.ts.map +1 -0
  45. package/dist/algorithms/OutlierDetection.js +284 -0
  46. package/dist/algorithms/ParticleSystem.d.ts +36 -0
  47. package/dist/algorithms/ParticleSystem.d.ts.map +1 -0
  48. package/dist/algorithms/ParticleSystem.js +59 -0
  49. package/dist/algorithms/ParticleSystem3D.d.ts +206 -0
  50. package/dist/algorithms/ParticleSystem3D.d.ts.map +1 -0
  51. package/dist/algorithms/ParticleSystem3D.js +371 -0
  52. package/dist/algorithms/index.d.ts +16 -0
  53. package/dist/algorithms/index.d.ts.map +1 -0
  54. package/{src/algorithms/index.ts → dist/algorithms/index.js} +0 -2
  55. package/dist/compat.d.ts +24 -0
  56. package/dist/compat.d.ts.map +1 -0
  57. package/dist/compat.js +88 -0
  58. package/dist/components/HexGrid.d.ts +5 -0
  59. package/dist/components/HexGrid.d.ts.map +1 -0
  60. package/dist/components/HexGrid.js +39 -0
  61. package/dist/components/NarrationOverlay.d.ts +16 -0
  62. package/dist/components/NarrationOverlay.d.ts.map +1 -0
  63. package/dist/components/NarrationOverlay.js +132 -0
  64. package/{src/components/index.ts → dist/components/index.d.ts} +1 -1
  65. package/dist/components/index.d.ts.map +1 -0
  66. package/dist/components/index.js +1 -0
  67. package/dist/features.d.ts +54 -0
  68. package/dist/features.d.ts.map +1 -0
  69. package/dist/features.js +74 -0
  70. package/dist/index.d.ts +12 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +17 -0
  73. package/dist/lib/narration.d.ts +12 -0
  74. package/dist/lib/narration.d.ts.map +1 -0
  75. package/dist/lib/narration.js +8 -0
  76. package/dist/lib/stats-tracker.d.ts +7 -0
  77. package/dist/lib/stats-tracker.d.ts.map +1 -0
  78. package/dist/lib/stats-tracker.js +22 -0
  79. package/dist/lib/theme-colors.d.ts +7 -0
  80. package/dist/lib/theme-colors.d.ts.map +1 -0
  81. package/dist/lib/theme-colors.js +10 -0
  82. package/dist/math/HexCoordinates.d.ts +140 -0
  83. package/dist/math/HexCoordinates.d.ts.map +1 -0
  84. package/dist/math/HexCoordinates.js +741 -0
  85. package/dist/math/Matrix4.d.ts +9 -0
  86. package/dist/math/Matrix4.d.ts.map +1 -0
  87. package/dist/math/Matrix4.js +19 -0
  88. package/dist/math/Quaternion.d.ts +11 -0
  89. package/dist/math/Quaternion.d.ts.map +1 -0
  90. package/dist/math/Quaternion.js +23 -0
  91. package/dist/math/SpatialIndex.d.ts +34 -0
  92. package/dist/math/SpatialIndex.d.ts.map +1 -0
  93. package/dist/math/SpatialIndex.js +75 -0
  94. package/dist/math/Vector3.d.ts +110 -0
  95. package/dist/math/Vector3.d.ts.map +1 -0
  96. package/dist/math/Vector3.js +426 -0
  97. package/dist/math/index.d.ts +11 -0
  98. package/dist/math/index.d.ts.map +1 -0
  99. package/{src/math/index.ts → dist/math/index.js} +0 -1
  100. package/dist/note-adapter.d.ts +44 -0
  101. package/dist/note-adapter.d.ts.map +1 -0
  102. package/dist/note-adapter.js +86 -0
  103. package/dist/ontology-adapter.d.ts +13 -0
  104. package/dist/ontology-adapter.d.ts.map +1 -0
  105. package/dist/ontology-adapter.js +65 -0
  106. package/dist/stores/index.d.ts +2 -0
  107. package/dist/stores/index.d.ts.map +1 -0
  108. package/dist/stores/uiStore.d.ts +18 -0
  109. package/dist/stores/uiStore.d.ts.map +1 -0
  110. package/dist/stores/uiStore.js +77 -0
  111. package/dist/types/index.d.ts +4 -0
  112. package/dist/types/index.d.ts.map +1 -0
  113. package/dist/types/index.js +1 -0
  114. package/dist/types.d.ts +126 -0
  115. package/dist/types.d.ts.map +1 -0
  116. package/dist/types.js +4 -0
  117. package/dist/utils/image-utils.d.ts +13 -0
  118. package/dist/utils/image-utils.d.ts.map +1 -0
  119. package/dist/utils/image-utils.js +23 -0
  120. package/dist/wasm/HexGridWasmWrapper.d.ts +131 -0
  121. package/dist/wasm/HexGridWasmWrapper.d.ts.map +1 -0
  122. package/dist/wasm/HexGridWasmWrapper.js +610 -0
  123. package/dist/wasm/index.d.ts +7 -0
  124. package/dist/wasm/index.d.ts.map +1 -0
  125. package/{src/wasm/index.ts → dist/wasm/index.js} +0 -1
  126. package/dist/webgpu/WebGPUContext.d.ts +20 -0
  127. package/dist/webgpu/WebGPUContext.d.ts.map +1 -0
  128. package/dist/webgpu/WebGPUContext.js +60 -0
  129. package/dist/webnn/WebNNContext.d.ts +38 -0
  130. package/dist/webnn/WebNNContext.d.ts.map +1 -0
  131. package/dist/webnn/WebNNContext.js +66 -0
  132. package/dist/workers/hexgrid-math.d.ts +79 -0
  133. package/dist/workers/hexgrid-math.d.ts.map +1 -0
  134. package/dist/workers/hexgrid-math.js +136 -0
  135. package/dist/workers/hexgrid-worker.worker.d.ts +35 -0
  136. package/dist/workers/hexgrid-worker.worker.d.ts.map +1 -0
  137. package/dist/workers/hexgrid-worker.worker.js +2014 -0
  138. package/package.json +20 -7
  139. package/.eslintrc.json +0 -28
  140. package/build_log.txt +0 -500
  141. package/build_src_log.txt +0 -8
  142. package/examples/basic-usage.tsx +0 -52
  143. package/public/hexgrid-worker.js +0 -2475
  144. package/rust/Cargo.toml +0 -41
  145. package/rust/src/lib.rs +0 -740
  146. package/rust/src/math.rs +0 -574
  147. package/rust/src/spatial.rs +0 -245
  148. package/rust/src/statistics.rs +0 -496
  149. package/site/.eslintrc.json +0 -3
  150. package/site/DEPLOYMENT.md +0 -196
  151. package/site/INDEX.md +0 -127
  152. package/site/QUICK_START.md +0 -86
  153. package/site/README.md +0 -85
  154. package/site/SITE_SUMMARY.md +0 -180
  155. package/site/next.config.js +0 -12
  156. package/site/package.json +0 -26
  157. package/site/src/app/docs/page.tsx +0 -272
  158. package/site/src/app/examples/page.tsx +0 -151
  159. package/site/src/app/globals.css +0 -160
  160. package/site/src/app/layout.tsx +0 -39
  161. package/site/src/app/page.tsx +0 -235
  162. package/site/tsconfig.json +0 -29
  163. package/site/vercel.json +0 -6
  164. package/src/HexGridEnhanced.ts +0 -16
  165. package/src/Snapshot.ts +0 -1607
  166. package/src/adapters/DashAdapter.ts +0 -57
  167. package/src/adapters.ts +0 -63
  168. package/src/algorithms/AdvancedStatistics.ts +0 -362
  169. package/src/algorithms/BayesianStatistics.ts +0 -348
  170. package/src/algorithms/FlowField.ts +0 -150
  171. package/src/algorithms/FlowField3D.ts +0 -573
  172. package/src/algorithms/FluidEngineFactory.ts +0 -44
  173. package/src/algorithms/FluidSimulation.ts +0 -115
  174. package/src/algorithms/FluidSimulation3D.ts +0 -664
  175. package/src/algorithms/FluidSimulation3DGPU.ts +0 -402
  176. package/src/algorithms/FluidSimulationWebNN.ts +0 -141
  177. package/src/algorithms/GraphAlgorithms.ts +0 -191
  178. package/src/algorithms/OutlierDetection.ts +0 -425
  179. package/src/algorithms/ParticleSystem.ts +0 -95
  180. package/src/algorithms/ParticleSystem3D.ts +0 -567
  181. package/src/compat.ts +0 -96
  182. package/src/components/HexGrid.tsx +0 -61
  183. package/src/components/NarrationOverlay.tsx +0 -309
  184. package/src/features.ts +0 -125
  185. package/src/index.ts +0 -30
  186. package/src/lib/narration.ts +0 -17
  187. package/src/lib/stats-tracker.ts +0 -25
  188. package/src/lib/theme-colors.ts +0 -12
  189. package/src/math/HexCoordinates.ts +0 -863
  190. package/src/math/Matrix4.ts +0 -25
  191. package/src/math/Quaternion.ts +0 -37
  192. package/src/math/SpatialIndex.ts +0 -114
  193. package/src/math/Vector3.ts +0 -540
  194. package/src/note-adapter.ts +0 -132
  195. package/src/ontology-adapter.ts +0 -84
  196. package/src/stores/uiStore.ts +0 -85
  197. package/src/types/index.ts +0 -3
  198. package/src/types/shared-utils.d.ts +0 -10
  199. package/src/types/wgsl.d.ts +0 -4
  200. package/src/types.ts +0 -164
  201. package/src/utils/image-utils.ts +0 -28
  202. package/src/wasm/HexGridWasmWrapper.ts +0 -801
  203. package/src/webgpu/WebGPUContext.ts +0 -71
  204. package/src/webgpu/shaders/fluid_sim.wgsl +0 -140
  205. package/src/webnn/WebNNContext.ts +0 -99
  206. package/src/workers/hexgrid-math.ts +0 -182
  207. package/src/workers/hexgrid-worker.worker.ts +0 -2781
  208. package/tsconfig.json +0 -26
  209. /package/{src/stores/index.ts → dist/stores/index.js} +0 -0
@@ -0,0 +1,263 @@
1
+ export class BetaDistribution {
2
+ constructor(alpha, beta) {
3
+ this.alpha = alpha;
4
+ this.beta = beta;
5
+ }
6
+ mean() {
7
+ const total = this.alpha + this.beta;
8
+ return total === 0 ? 0.5 : this.alpha / total;
9
+ }
10
+ variance() {
11
+ const total = this.alpha + this.beta;
12
+ if (total <= 1)
13
+ return 0;
14
+ return (this.alpha * this.beta) / (total * total * (total + 1));
15
+ }
16
+ }
17
+ export class MarkovChain {
18
+ constructor() {
19
+ this.transitions = new Map();
20
+ }
21
+ addTransition(from, to) {
22
+ if (!this.transitions.has(from)) {
23
+ this.transitions.set(from, new Map());
24
+ }
25
+ const map = this.transitions.get(from);
26
+ map.set(to, (map.get(to) ?? 0) + 1);
27
+ }
28
+ probabilities(from) {
29
+ const map = this.transitions.get(from);
30
+ if (!map)
31
+ return [];
32
+ const total = Array.from(map.values()).reduce((sum, val) => sum + val, 0);
33
+ return Array.from(map.entries()).map(([to, count]) => ({
34
+ to,
35
+ probability: total === 0 ? 0 : count / total,
36
+ }));
37
+ }
38
+ }
39
+ export class KalmanFilter {
40
+ constructor(initialState, initialUncertainty, processNoise, measurementNoise) {
41
+ this.state = initialState;
42
+ this.uncertainty = initialUncertainty;
43
+ this.processNoise = processNoise;
44
+ this.measurementNoise = measurementNoise;
45
+ }
46
+ update(measurement) {
47
+ const predictedUncertainty = this.uncertainty + this.processNoise;
48
+ const kalmanGain = predictedUncertainty / (predictedUncertainty + this.measurementNoise);
49
+ this.state = this.state + kalmanGain * (measurement - this.state);
50
+ this.uncertainty = (1 - kalmanGain) * predictedUncertainty;
51
+ }
52
+ step() {
53
+ // Predict next state without measurement
54
+ this.uncertainty += this.processNoise;
55
+ return this.state;
56
+ }
57
+ predict(steps = 1) {
58
+ // Predict future state
59
+ let state = this.state;
60
+ for (let i = 0; i < steps; i++) {
61
+ state = state; // Simple prediction (no process model)
62
+ }
63
+ return state;
64
+ }
65
+ forecast(steps) {
66
+ const predictions = [];
67
+ const uncertainties = [];
68
+ let state = this.state;
69
+ let uncertainty = this.uncertainty;
70
+ for (let i = 0; i < steps; i++) {
71
+ uncertainty += this.processNoise;
72
+ predictions.push(state);
73
+ uncertainties.push(uncertainty);
74
+ }
75
+ return { predictions, uncertainties };
76
+ }
77
+ getState() {
78
+ return this.state;
79
+ }
80
+ getUncertainty() {
81
+ return this.uncertainty;
82
+ }
83
+ }
84
+ export function bayesianWinProbability(wins, losses) {
85
+ const total = wins + losses;
86
+ if (total === 0)
87
+ return 0.5;
88
+ return wins / total;
89
+ }
90
+ export function bayesianConquestRate(successes, trials) {
91
+ if (trials === 0)
92
+ return 0;
93
+ return successes / trials;
94
+ }
95
+ export function bayesianChangepoint(values) {
96
+ if (values.length < 2)
97
+ return 0;
98
+ const mid = Math.floor(values.length / 2);
99
+ return mid;
100
+ }
101
+ export function generateProbabilitySnapshot(labels) {
102
+ const probability = labels.length > 0 ? 1 / labels.length : 0;
103
+ return {
104
+ probabilities: labels.map((label) => ({ label, probability })),
105
+ };
106
+ }
107
+ // Dirichlet Distribution
108
+ export class DirichletDistribution {
109
+ constructor(alphas) {
110
+ this.alphas = alphas;
111
+ }
112
+ mean() {
113
+ const sum = this.alphas.reduce((s, a) => s + a, 0);
114
+ return this.alphas.map((a) => (sum === 0 ? 0 : a / sum));
115
+ }
116
+ }
117
+ // Normal Distribution
118
+ export class NormalDistribution {
119
+ constructor(mean, variance) {
120
+ this.mean = mean;
121
+ this.variance = variance;
122
+ }
123
+ sample() {
124
+ // Box-Muller transform
125
+ const u1 = Math.random();
126
+ const u2 = Math.random();
127
+ const z0 = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
128
+ return z0 * Math.sqrt(this.variance) + this.mean;
129
+ }
130
+ }
131
+ // Poisson Distribution
132
+ export class PoissonDistribution {
133
+ constructor(lambda) {
134
+ this.lambda = lambda;
135
+ }
136
+ sample() {
137
+ let k = 0;
138
+ let p = 1;
139
+ const L = Math.exp(-this.lambda);
140
+ do {
141
+ k++;
142
+ p *= Math.random();
143
+ } while (p > L);
144
+ return k - 1;
145
+ }
146
+ }
147
+ // Exponential Distribution
148
+ export class ExponentialDistribution {
149
+ constructor(lambda) {
150
+ this.lambda = lambda;
151
+ }
152
+ sample() {
153
+ return -Math.log(1 - Math.random()) / this.lambda;
154
+ }
155
+ }
156
+ // Hidden Markov Model
157
+ export class HiddenMarkovModel {
158
+ constructor(states) {
159
+ this.states = states;
160
+ this.transitions = new Map();
161
+ this.emissions = new Map();
162
+ }
163
+ addTransition(from, to, probability) {
164
+ if (!this.transitions.has(from)) {
165
+ this.transitions.set(from, new Map());
166
+ }
167
+ this.transitions.get(from).set(to, probability);
168
+ }
169
+ addEmission(state, observation, probability) {
170
+ if (!this.emissions.has(state)) {
171
+ this.emissions.set(state, new Map());
172
+ }
173
+ this.emissions.get(state).set(observation, probability);
174
+ }
175
+ }
176
+ // Bayesian A/B Test
177
+ export function bayesianABTest(successA, trialsA, successB, trialsB) {
178
+ const probA = trialsA === 0 ? 0.5 : successA / trialsA;
179
+ const probB = trialsB === 0 ? 0.5 : successB / trialsB;
180
+ return probB - probA; // Difference in probabilities
181
+ }
182
+ // Bayes Factor
183
+ export function bayesFactor(priorOdds, likelihoodRatio) {
184
+ return priorOdds * likelihoodRatio;
185
+ }
186
+ // MAP Estimate (Maximum A Posteriori)
187
+ export function mapEstimate(data, prior) {
188
+ const sum = data.reduce((s, x) => s + x, 0);
189
+ const n = data.length;
190
+ const alpha = prior.alpha + sum;
191
+ const beta = prior.beta + n - sum;
192
+ return alpha / (alpha + beta);
193
+ }
194
+ // Learn Markov Chain from sequence
195
+ export function learnMarkovChain(sequence) {
196
+ const chain = new MarkovChain();
197
+ for (let i = 0; i < sequence.length - 1; i++) {
198
+ chain.addTransition(sequence[i], sequence[i + 1]);
199
+ }
200
+ return chain;
201
+ }
202
+ // Bootstrap Confidence Interval
203
+ export function bootstrapConfidenceInterval(data, iterations = 1000, confidence = 0.95) {
204
+ const samples = [];
205
+ for (let i = 0; i < iterations; i++) {
206
+ const sample = [];
207
+ for (let j = 0; j < data.length; j++) {
208
+ sample.push(data[Math.floor(Math.random() * data.length)] ?? 0);
209
+ }
210
+ samples.push(sample.reduce((s, x) => s + x, 0) / sample.length);
211
+ }
212
+ samples.sort((a, b) => a - b);
213
+ const lowerIdx = Math.floor(((1 - confidence) / 2) * samples.length);
214
+ const upperIdx = Math.floor(((1 + confidence) / 2) * samples.length);
215
+ return {
216
+ lower: samples[lowerIdx] ?? 0,
217
+ upper: samples[upperIdx] ?? 0,
218
+ };
219
+ }
220
+ // Monte Carlo Integration
221
+ export function monteCarloIntegrate(fn, a, b, samples = 1000) {
222
+ let sum = 0;
223
+ for (let i = 0; i < samples; i++) {
224
+ const x = a + Math.random() * (b - a);
225
+ sum += fn(x);
226
+ }
227
+ return ((b - a) * sum) / samples;
228
+ }
229
+ // Mutual Information
230
+ export function mutualInformation(x, y) {
231
+ // Simplified implementation
232
+ if (x.length !== y.length || x.length === 0)
233
+ return 0;
234
+ const n = x.length;
235
+ const hx = shannonEntropy(x);
236
+ const hy = shannonEntropy(y);
237
+ // Simplified: assume independence for now
238
+ return Math.max(0, hx + hy - (hx + hy) * 0.5);
239
+ }
240
+ function shannonEntropy(values) {
241
+ const total = values.reduce((s, v) => s + Math.abs(v), 0);
242
+ if (total === 0)
243
+ return 0;
244
+ return values.reduce((sum, val) => {
245
+ const p = Math.abs(val) / total;
246
+ return p === 0 ? sum : sum - p * Math.log2(p);
247
+ }, 0);
248
+ }
249
+ // Conditional Entropy
250
+ export function conditionalEntropy(x, y) {
251
+ if (x.length !== y.length || x.length === 0)
252
+ return 0;
253
+ // Simplified: return marginal entropy
254
+ return shannonEntropy(x);
255
+ }
256
+ // Normalized Mutual Information
257
+ export function normalizedMutualInformation(x, y) {
258
+ const mi = mutualInformation(x, y);
259
+ const hx = shannonEntropy(x);
260
+ const hy = shannonEntropy(y);
261
+ const denom = Math.sqrt(hx * hy);
262
+ return denom === 0 ? 0 : mi / denom;
263
+ }
@@ -0,0 +1,55 @@
1
+ import { Vector2 } from '../math/Vector3';
2
+ export interface FlowFieldConfig {
3
+ width: number;
4
+ height: number;
5
+ resolution: number;
6
+ }
7
+ export interface Streamline {
8
+ points: Vector2[];
9
+ }
10
+ export declare class FlowField2D {
11
+ private config;
12
+ private sources;
13
+ constructor(config: FlowFieldConfig);
14
+ clear(): void;
15
+ addSource(x: number, y: number, vx: number, vy: number, strength: number): void;
16
+ update(_deltaTime: number): void;
17
+ sample(x: number, y: number): Vector2;
18
+ sampleFull(x: number, y: number): {
19
+ velocity: Vector2;
20
+ divergence: number;
21
+ curl: number;
22
+ };
23
+ traceStreamline(x: number, y: number, options: {
24
+ maxLength: number;
25
+ stepSize: number;
26
+ maxSteps: number;
27
+ }): Streamline;
28
+ }
29
+ export declare class InfectionFlowAnalyzer {
30
+ private width;
31
+ private height;
32
+ constructor(width: number, height: number);
33
+ getFlowData(_infections: Map<number, unknown>, _positions: Array<{
34
+ x: number;
35
+ y: number;
36
+ }>): Array<{
37
+ centroid: Vector2;
38
+ velocity: Vector2;
39
+ }>;
40
+ }
41
+ export declare class HeatMap {
42
+ private width;
43
+ private height;
44
+ private resolution;
45
+ private data;
46
+ constructor(config: {
47
+ width: number;
48
+ height: number;
49
+ resolution: number;
50
+ kernelRadius: number;
51
+ });
52
+ addPoint(x: number, y: number, value: number): void;
53
+ getData(): Float32Array;
54
+ }
55
+ //# sourceMappingURL=FlowField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowField.d.ts","sourceRoot":"","sources":["../../src/algorithms/FlowField.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,OAAO,EAAE,CAAC;CACnB;AAUD,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,OAAO,CAAgB;gBAEnB,MAAM,EAAE,eAAe;IAInC,KAAK,IAAI,IAAI;IAIb,SAAS,CACP,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,GACf,IAAI;IAIP,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIhC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;IAiBrC,UAAU,CACR,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAS1D,eAAe,CACb,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GACjE,UAAU;CAiBd;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;gBAEX,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAKzC,WAAW,CACT,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,UAAU,EAAE,KAAK,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAC1C,KAAK,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;CAGnD;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,IAAI,CAAe;gBAEf,MAAM,EAAE;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB;IAOD,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAanD,OAAO,IAAI,YAAY;CAGxB"}
@@ -0,0 +1,80 @@
1
+ import { Vector2 } from '../math/Vector3';
2
+ export class FlowField2D {
3
+ constructor(config) {
4
+ this.sources = [];
5
+ this.config = config;
6
+ }
7
+ clear() {
8
+ this.sources = [];
9
+ }
10
+ addSource(x, y, vx, vy, strength) {
11
+ this.sources.push({ x, y, vx, vy, strength });
12
+ }
13
+ update(_deltaTime) {
14
+ // No-op for stub
15
+ }
16
+ sample(x, y) {
17
+ if (this.sources.length === 0) {
18
+ return new Vector2(0, 0);
19
+ }
20
+ let vx = 0;
21
+ let vy = 0;
22
+ for (const source of this.sources) {
23
+ const dx = x - source.x;
24
+ const dy = y - source.y;
25
+ const distance = Math.hypot(dx, dy) || 1;
26
+ const influence = source.strength / distance;
27
+ vx += source.vx * influence;
28
+ vy += source.vy * influence;
29
+ }
30
+ return new Vector2(vx, vy);
31
+ }
32
+ sampleFull(x, y) {
33
+ const velocity = this.sample(x, y);
34
+ return {
35
+ velocity,
36
+ divergence: velocity.x * 0.01,
37
+ curl: velocity.y * 0.01,
38
+ };
39
+ }
40
+ traceStreamline(x, y, options) {
41
+ const points = [new Vector2(x, y)];
42
+ let current = new Vector2(x, y);
43
+ for (let i = 0; i < options.maxSteps; i++) {
44
+ const velocity = this.sample(current.x, current.y);
45
+ const next = new Vector2(current.x + velocity.x * options.stepSize, current.y + velocity.y * options.stepSize);
46
+ points.push(next);
47
+ current = next;
48
+ if (points.length * options.stepSize >= options.maxLength) {
49
+ break;
50
+ }
51
+ }
52
+ return { points };
53
+ }
54
+ }
55
+ export class InfectionFlowAnalyzer {
56
+ constructor(width, height) {
57
+ this.width = width;
58
+ this.height = height;
59
+ }
60
+ getFlowData(_infections, _positions) {
61
+ return [];
62
+ }
63
+ }
64
+ export class HeatMap {
65
+ constructor(config) {
66
+ this.width = Math.max(1, Math.round(config.width / config.resolution));
67
+ this.height = Math.max(1, Math.round(config.height / config.resolution));
68
+ this.resolution = config.resolution;
69
+ this.data = new Float32Array(this.width * this.height);
70
+ }
71
+ addPoint(x, y, value) {
72
+ const gridX = Math.min(this.width - 1, Math.max(0, Math.floor(x / this.resolution)));
73
+ const gridY = Math.min(this.height - 1, Math.max(0, Math.floor(y / this.resolution)));
74
+ const index = gridY * this.width + gridX;
75
+ this.data[index] += value;
76
+ }
77
+ getData() {
78
+ return this.data;
79
+ }
80
+ }
@@ -0,0 +1,166 @@
1
+ /**
2
+ * 3D Flow Field
3
+ *
4
+ * A 3D vector field supporting vortices, attractors, and streamline tracing.
5
+ * Used for creating swirling "fluid soup" motion in the Pensieve.
6
+ */
7
+ import { Vector3 } from '../math/Vector3';
8
+ /**
9
+ * Configuration for the flow field
10
+ */
11
+ export interface FlowField3DConfig {
12
+ /** Field width in cells */
13
+ width: number;
14
+ /** Field height in cells */
15
+ height: number;
16
+ /** Field depth in cells */
17
+ depth: number;
18
+ /** Cell size (world units per cell) */
19
+ resolution: number;
20
+ }
21
+ /**
22
+ * A vortex source in the flow field
23
+ */
24
+ export interface Vortex3D {
25
+ /** Center position */
26
+ center: Vector3;
27
+ /** Axis of rotation (normalized) */
28
+ axis: Vector3;
29
+ /** Rotational strength (positive = counterclockwise when looking along axis) */
30
+ strength: number;
31
+ /** Influence radius */
32
+ radius: number;
33
+ /** Falloff type */
34
+ falloff: 'linear' | 'quadratic' | 'gaussian';
35
+ }
36
+ /**
37
+ * An attractor/repeller in the flow field
38
+ */
39
+ export interface Attractor3D {
40
+ /** Center position */
41
+ center: Vector3;
42
+ /** Strength (positive = attract, negative = repel) */
43
+ strength: number;
44
+ /** Influence radius */
45
+ radius: number;
46
+ /** Falloff type */
47
+ falloff: 'linear' | 'quadratic' | 'inverse-square';
48
+ }
49
+ /**
50
+ * A directional source in the flow field
51
+ */
52
+ export interface DirectionalSource3D {
53
+ /** Position */
54
+ position: Vector3;
55
+ /** Direction vector (will be normalized) */
56
+ direction: Vector3;
57
+ /** Strength */
58
+ strength: number;
59
+ /** Influence radius */
60
+ radius: number;
61
+ }
62
+ /**
63
+ * Options for streamline tracing
64
+ */
65
+ export interface StreamlineOptions {
66
+ /** Maximum number of steps */
67
+ maxSteps?: number;
68
+ /** Step size (world units) */
69
+ stepSize?: number;
70
+ /** Minimum velocity magnitude to continue tracing */
71
+ minVelocity?: number;
72
+ /** Whether to trace backwards as well */
73
+ bidirectional?: boolean;
74
+ }
75
+ /**
76
+ * Full field sample including velocity, divergence, and curl
77
+ */
78
+ export interface FieldSample {
79
+ /** Velocity at the sampled point */
80
+ velocity: Vector3;
81
+ /** Divergence (scalar) - measure of "outward flow" */
82
+ divergence: number;
83
+ /** Curl (vector) - measure of rotation */
84
+ curl: Vector3;
85
+ }
86
+ /**
87
+ * 3D Flow Field with vortices, attractors, and sources
88
+ */
89
+ export declare class FlowField3D {
90
+ protected width: number;
91
+ protected height: number;
92
+ protected depth: number;
93
+ protected resolution: number;
94
+ protected size: number;
95
+ protected fieldX: Float32Array;
96
+ protected fieldY: Float32Array;
97
+ protected fieldZ: Float32Array;
98
+ protected vortices: Vortex3D[];
99
+ protected attractors: Attractor3D[];
100
+ protected sources: DirectionalSource3D[];
101
+ protected noiseTime: number;
102
+ constructor(config: FlowField3DConfig);
103
+ /**
104
+ * Add a vortex to the field
105
+ */
106
+ addVortex(center: Vector3, axis: Vector3, strength: number, radius: number, falloff?: Vortex3D['falloff']): void;
107
+ /**
108
+ * Add an attractor (positive strength) or repeller (negative strength)
109
+ */
110
+ addAttractor(center: Vector3, strength: number, radius?: number, falloff?: Attractor3D['falloff']): void;
111
+ /**
112
+ * Add a directional source
113
+ */
114
+ addSource(position: Vector3, velocity: Vector3, strength: number, radius?: number): void;
115
+ /**
116
+ * Clear all sources
117
+ */
118
+ clearSources(): void;
119
+ /**
120
+ * Sample the velocity at a world position
121
+ */
122
+ sample(position: Vector3): Vector3;
123
+ /**
124
+ * Sample the full field including curl and divergence
125
+ */
126
+ sampleFull(position: Vector3): FieldSample;
127
+ /**
128
+ * Trace a streamline from a starting point
129
+ */
130
+ traceStreamline(start: Vector3, options?: StreamlineOptions): Vector3[];
131
+ /**
132
+ * Update the flow field (for time-varying fields)
133
+ */
134
+ update(dt: number): void;
135
+ /**
136
+ * Get field dimensions
137
+ */
138
+ getDimensions(): {
139
+ width: number;
140
+ height: number;
141
+ depth: number;
142
+ resolution: number;
143
+ };
144
+ private sampleVortex;
145
+ private sampleAttractor;
146
+ private sampleSource;
147
+ }
148
+ /**
149
+ * Pensieve-specific flow field with aesthetic presets
150
+ */
151
+ export declare class PensieveFlowField extends FlowField3D {
152
+ constructor(size?: number);
153
+ /**
154
+ * Add default vortices for pensieve aesthetic
155
+ */
156
+ private addDefaultVortices;
157
+ /**
158
+ * Add mouse interaction force
159
+ */
160
+ addMouseForce(position: Vector3, direction: Vector3, strength?: number): void;
161
+ /**
162
+ * Clear mouse forces (call after interaction ends)
163
+ */
164
+ clearMouseForces(): void;
165
+ }
166
+ //# sourceMappingURL=FlowField3D.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlowField3D.d.ts","sourceRoot":"","sources":["../../src/algorithms/FlowField3D.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,sBAAsB;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,oCAAoC;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,gFAAgF;IAChF,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,OAAO,EAAE,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,sBAAsB;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,OAAO,EAAE,QAAQ,GAAG,WAAW,GAAG,gBAAgB,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,eAAe;IACf,QAAQ,EAAE,OAAO,CAAC;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