@buley/hexgrid-3d 3.2.4 → 3.3.1
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/algorithms/AdvancedStatistics.d.ts +2 -2
- package/dist/algorithms/AdvancedStatistics.d.ts.map +1 -1
- package/dist/algorithms/AdvancedStatistics.js +2 -2
- package/dist/algorithms/BayesianStatistics.d.ts +6 -0
- package/dist/algorithms/BayesianStatistics.d.ts.map +1 -1
- package/dist/algorithms/BayesianStatistics.js +54 -0
- package/dist/algorithms/FlowField.d.ts +11 -0
- package/dist/algorithms/FlowField.d.ts.map +1 -1
- package/dist/algorithms/FlowField.js +13 -0
- package/dist/algorithms/FluidSimulation.d.ts +21 -3
- package/dist/algorithms/FluidSimulation.d.ts.map +1 -1
- package/dist/algorithms/FluidSimulation.js +40 -0
- package/dist/algorithms/GraphAlgorithms.d.ts +1 -1
- package/dist/algorithms/GraphAlgorithms.d.ts.map +1 -1
- package/dist/algorithms/GraphAlgorithms.js +87 -15
- package/dist/algorithms/OutlierDetection.d.ts +4 -0
- package/dist/algorithms/OutlierDetection.d.ts.map +1 -1
- package/dist/algorithms/OutlierDetection.js +15 -3
- package/dist/algorithms/ParticleSystem.d.ts +46 -3
- package/dist/algorithms/ParticleSystem.d.ts.map +1 -1
- package/dist/algorithms/ParticleSystem.js +118 -15
- package/dist/components/HexGrid.d.ts +32 -2
- package/dist/components/HexGrid.d.ts.map +1 -1
- package/dist/components/HexGrid.js +5456 -25
- package/dist/components/NarrationOverlay.d.ts +2 -2
- package/dist/components/NarrationOverlay.d.ts.map +1 -1
- package/dist/components/NarrationOverlay.js +1 -1
- package/dist/components/debug/PoolStatsOverlay.d.ts +6 -0
- package/dist/components/debug/PoolStatsOverlay.d.ts.map +1 -0
- package/dist/components/debug/PoolStatsOverlay.js +18 -0
- package/dist/components/index.d.ts +3 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/lib/html-utils.d.ts +2 -0
- package/dist/lib/html-utils.d.ts.map +1 -0
- package/dist/lib/html-utils.js +7 -0
- package/dist/lib/logger.d.ts +20 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +9 -0
- package/dist/lib/narration.d.ts +5 -0
- package/dist/lib/narration.d.ts.map +1 -1
- package/dist/lib/narration.js +19 -0
- package/dist/lib/stats-tracker.d.ts +2 -0
- package/dist/lib/stats-tracker.d.ts.map +1 -1
- package/dist/lib/stats-tracker.js +13 -0
- package/dist/lib/theme-colors.d.ts +9 -0
- package/dist/lib/theme-colors.d.ts.map +1 -1
- package/dist/lib/theme-colors.js +18 -1
- package/dist/math/Matrix4.d.ts +179 -2
- package/dist/math/Matrix4.d.ts.map +1 -1
- package/dist/math/Matrix4.js +528 -8
- package/dist/math/Quaternion.d.ts +69 -0
- package/dist/math/Quaternion.d.ts.map +1 -1
- package/dist/math/Quaternion.js +439 -0
- package/dist/math/SpatialIndex.d.ts +32 -13
- package/dist/math/SpatialIndex.d.ts.map +1 -1
- package/dist/math/SpatialIndex.js +239 -33
- package/package.json +4 -2
|
@@ -1,12 +1,112 @@
|
|
|
1
|
+
import { Vector2 } from '../math/Vector3';
|
|
2
|
+
export class ParticleEmitter {
|
|
3
|
+
constructor(config) {
|
|
4
|
+
this.config = config;
|
|
5
|
+
}
|
|
6
|
+
emit() {
|
|
7
|
+
const spreadX = (Math.random() - 0.5) * 2 * this.config.velocitySpread.x;
|
|
8
|
+
const spreadY = (Math.random() - 0.5) * 2 * this.config.velocitySpread.y;
|
|
9
|
+
const c = this.config.color;
|
|
10
|
+
return {
|
|
11
|
+
x: this.config.position.x,
|
|
12
|
+
y: this.config.position.y,
|
|
13
|
+
vx: this.config.velocity.x + spreadX,
|
|
14
|
+
vy: this.config.velocity.y + spreadY,
|
|
15
|
+
size: this.config.size,
|
|
16
|
+
color: `rgba(${c[0]}, ${c[1]}, ${c[2]}, ${c[3] / 255})`,
|
|
17
|
+
alpha: 1,
|
|
18
|
+
lifetime: this.config.lifetime,
|
|
19
|
+
age: 0,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
1
23
|
export class ParticleSystem {
|
|
2
|
-
constructor() {
|
|
24
|
+
constructor(config) {
|
|
3
25
|
this.particles = [];
|
|
26
|
+
this.emitters = [];
|
|
27
|
+
this.config = config;
|
|
28
|
+
}
|
|
29
|
+
createEmitter(emitterConfig) {
|
|
30
|
+
const emitter = new ParticleEmitter(emitterConfig);
|
|
31
|
+
this.emitters.push(emitter);
|
|
32
|
+
return emitter;
|
|
33
|
+
}
|
|
34
|
+
removeEmitter(emitter) {
|
|
35
|
+
const idx = this.emitters.indexOf(emitter);
|
|
36
|
+
if (idx !== -1) {
|
|
37
|
+
this.emitters.splice(idx, 1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
update(deltaTime) {
|
|
41
|
+
// Emit from emitters
|
|
42
|
+
const rate = this.config.emissionRate ?? 10;
|
|
43
|
+
const toEmit = Math.floor(rate * deltaTime);
|
|
44
|
+
for (const emitter of this.emitters) {
|
|
45
|
+
for (let i = 0; i < toEmit; i++) {
|
|
46
|
+
if (this.particles.length >= this.config.maxParticles)
|
|
47
|
+
break;
|
|
48
|
+
this.particles.push(emitter.emit());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Update particles
|
|
52
|
+
const gravity = this.config.gravity ?? new Vector2(0, 0);
|
|
53
|
+
const drag = this.config.drag ?? 1;
|
|
54
|
+
for (let i = this.particles.length - 1; i >= 0; i--) {
|
|
55
|
+
const p = this.particles[i];
|
|
56
|
+
p.age += deltaTime;
|
|
57
|
+
if (p.age >= p.lifetime) {
|
|
58
|
+
this.particles.splice(i, 1);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
p.vx += gravity.x * deltaTime;
|
|
62
|
+
p.vy += gravity.y * deltaTime;
|
|
63
|
+
p.vx *= drag;
|
|
64
|
+
p.vy *= drag;
|
|
65
|
+
p.x += p.vx * deltaTime;
|
|
66
|
+
p.y += p.vy * deltaTime;
|
|
67
|
+
p.alpha = 1 - p.age / p.lifetime;
|
|
68
|
+
}
|
|
4
69
|
}
|
|
5
|
-
|
|
6
|
-
|
|
70
|
+
burst(position, count, options) {
|
|
71
|
+
for (let i = 0; i < count; i++) {
|
|
72
|
+
if (this.particles.length >= this.config.maxParticles)
|
|
73
|
+
break;
|
|
74
|
+
const spreadX = (Math.random() - 0.5) * 2 * options.velocitySpread.x;
|
|
75
|
+
const spreadY = (Math.random() - 0.5) * 2 * options.velocitySpread.y;
|
|
76
|
+
const c = options.color;
|
|
77
|
+
this.particles.push({
|
|
78
|
+
x: position.x,
|
|
79
|
+
y: position.y,
|
|
80
|
+
vx: options.velocity.x + spreadX,
|
|
81
|
+
vy: options.velocity.y + spreadY,
|
|
82
|
+
size: options.size,
|
|
83
|
+
color: `rgba(${c[0]}, ${c[1]}, ${c[2]}, ${c[3] / 255})`,
|
|
84
|
+
alpha: 1,
|
|
85
|
+
lifetime: options.lifetime,
|
|
86
|
+
age: 0,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
spawn(config) {
|
|
91
|
+
if (this.particles.length >= this.config.maxParticles)
|
|
92
|
+
return;
|
|
93
|
+
const c = config.color;
|
|
94
|
+
const spreadX = (Math.random() - 0.5) * 2 * config.velocitySpread.x;
|
|
95
|
+
const spreadY = (Math.random() - 0.5) * 2 * config.velocitySpread.y;
|
|
96
|
+
this.particles.push({
|
|
97
|
+
x: config.position.x,
|
|
98
|
+
y: config.position.y,
|
|
99
|
+
vx: config.velocity.x + spreadX,
|
|
100
|
+
vy: config.velocity.y + spreadY,
|
|
101
|
+
size: config.size,
|
|
102
|
+
color: `rgba(${c[0]}, ${c[1]}, ${c[2]}, ${c[3] / 255})`,
|
|
103
|
+
alpha: 1,
|
|
104
|
+
lifetime: config.lifetime,
|
|
105
|
+
age: 0,
|
|
106
|
+
});
|
|
7
107
|
}
|
|
8
|
-
|
|
9
|
-
|
|
108
|
+
getActiveCount() {
|
|
109
|
+
return this.particles.length;
|
|
10
110
|
}
|
|
11
111
|
getPositions() {
|
|
12
112
|
return this.particles;
|
|
@@ -19,7 +119,7 @@ export class ParticleEffectManager {
|
|
|
19
119
|
constructor(config) {
|
|
20
120
|
this.systems = new Map();
|
|
21
121
|
this.config = config;
|
|
22
|
-
this.systems.set('default', new ParticleSystem());
|
|
122
|
+
this.systems.set('default', new ParticleSystem({ maxParticles: config.maxParticles }));
|
|
23
123
|
}
|
|
24
124
|
triggerEffect(effect, position, options) {
|
|
25
125
|
const system = this.systems.get('default');
|
|
@@ -27,15 +127,18 @@ export class ParticleEffectManager {
|
|
|
27
127
|
return;
|
|
28
128
|
const count = options?.count ?? 1;
|
|
29
129
|
const color = options?.color ?? [1, 1, 1];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
130
|
+
system.burst(position, count, {
|
|
131
|
+
velocity: options?.velocity ?? new Vector2(0, 0),
|
|
132
|
+
velocitySpread: new Vector2(1, 1),
|
|
133
|
+
lifetime: 1,
|
|
134
|
+
size: 4,
|
|
135
|
+
color: [
|
|
136
|
+
Math.round(color[0] * 255),
|
|
137
|
+
Math.round(color[1] * 255),
|
|
138
|
+
Math.round(color[2] * 255),
|
|
139
|
+
255,
|
|
140
|
+
],
|
|
141
|
+
});
|
|
39
142
|
}
|
|
40
143
|
update(deltaTime) {
|
|
41
144
|
for (const system of this.systems.values()) {
|
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
2
|
+
import type { GridItem, Photo } from '../types';
|
|
3
|
+
export type { Photo };
|
|
4
|
+
export interface HexGridProps<T = unknown> {
|
|
5
|
+
items?: GridItem<T>[];
|
|
6
|
+
photos?: Photo[];
|
|
7
|
+
onItemClick?: (item: GridItem<T>) => void;
|
|
8
|
+
onHexClick?: (photo: Photo) => void;
|
|
9
|
+
spacing?: number;
|
|
10
|
+
canvasRef?: React.RefObject<HTMLCanvasElement>;
|
|
11
|
+
onLeaderboardUpdate?: (leaderboard: Array<{
|
|
12
|
+
photoId: string;
|
|
13
|
+
territory: number;
|
|
14
|
+
position: number;
|
|
15
|
+
}>) => void;
|
|
16
|
+
autoplayQueueLimit?: number;
|
|
17
|
+
onAutoplayQueueLimitChange?: (limit: number) => void;
|
|
18
|
+
modalOpen?: boolean;
|
|
19
|
+
userId?: string;
|
|
20
|
+
username?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface Infection {
|
|
23
|
+
photo: Photo;
|
|
24
|
+
gridPosition: [number, number];
|
|
25
|
+
infectionTime: number;
|
|
26
|
+
generation: number;
|
|
27
|
+
uvBounds: [number, number, number, number];
|
|
28
|
+
scale: number;
|
|
29
|
+
growthRate: number;
|
|
30
|
+
tilesX: number;
|
|
31
|
+
tilesY: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const HexGrid: <T = unknown>({ items, photos: photosProp, onItemClick, onHexClick, spacing, canvasRef: externalCanvasRef, onLeaderboardUpdate, autoplayQueueLimit, onAutoplayQueueLimitChange, modalOpen, userId, username }: HexGridProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
4
34
|
export default HexGrid;
|
|
5
35
|
//# sourceMappingURL=HexGrid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HexGrid.d.ts","sourceRoot":"","sources":["../../src/components/HexGrid.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HexGrid.d.ts","sourceRoot":"","sources":["../../src/components/HexGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAA;AAYhF,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAI/C,YAAY,EAAE,KAAK,EAAE,CAAA;AAWrB,MAAM,WAAW,YAAY,CAAC,CAA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