@buley/hexgrid-3d 1.1.0 → 1.1.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/build_log.txt +500 -0
- package/build_src_log.txt +8 -0
- package/package.json +1 -1
- package/site/.eslintrc.json +3 -0
- package/site/DEPLOYMENT.md +196 -0
- package/site/INDEX.md +127 -0
- package/site/QUICK_START.md +86 -0
- package/site/README.md +85 -0
- package/site/SITE_SUMMARY.md +180 -0
- package/site/next.config.js +12 -0
- package/site/package.json +26 -0
- package/site/src/app/docs/page.tsx +148 -0
- package/site/src/app/examples/page.tsx +133 -0
- package/site/src/app/globals.css +160 -0
- package/site/src/app/layout.tsx +29 -0
- package/site/src/app/page.tsx +163 -0
- package/site/tsconfig.json +29 -0
- package/site/vercel.json +6 -0
- package/src/adapters/DashAdapter.ts +57 -0
- package/src/algorithms/ParticleSystem3D.ts +25 -4
- package/src/components/NarrationOverlay.tsx +1 -1
- package/src/lib/narration.ts +17 -0
- package/src/lib/stats-tracker.ts +25 -0
- package/src/lib/theme-colors.ts +12 -0
- package/src/math/HexCoordinates.ts +852 -4
- package/src/math/Vector3.ts +482 -15
- package/src/types/shared-utils.d.ts +10 -0
- package/src/types.ts +1 -0
- package/tsconfig.json +21 -14
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter for Zero-Copy Data Sync between Dash 2.0 and HexGrid-3D.
|
|
3
|
+
*
|
|
4
|
+
* This adapter subscribes to a Dash "LiveQuery" which returns pointers to shared memory (SharedArrayBuffer)
|
|
5
|
+
* or Float32Arrays. It then syncs this data directly to the HexGridWasm instance.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Placeholder types until we link the actual Dash package
|
|
9
|
+
interface DashQueryHandle {
|
|
10
|
+
ptr: number;
|
|
11
|
+
size: number;
|
|
12
|
+
buffer: SharedArrayBuffer | ArrayBuffer;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class DashAdapter {
|
|
16
|
+
private dash: any; // Will be typed when we link @buley/dash
|
|
17
|
+
|
|
18
|
+
constructor(dashInstance: any) {
|
|
19
|
+
this.dash = dashInstance;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Subscribe to a semantic query in Dash and sync results to HexGrid.
|
|
24
|
+
*
|
|
25
|
+
* @param query The vector search query
|
|
26
|
+
* @param gridInstance The WASM instance of the HexGrid
|
|
27
|
+
*/
|
|
28
|
+
bindSemanticSearch(query: string, particleSystem: any) {
|
|
29
|
+
console.log('[DashAdapter] Binding semantic search:', query);
|
|
30
|
+
|
|
31
|
+
// Hypothetical Zero-Copy API from Dash 2.0
|
|
32
|
+
if (this.dash.liveQueryPtr) {
|
|
33
|
+
this.dash.liveQueryPtr(`SELECT embedding FROM dash_vec_idx WHERE embedding MATCH '${query}'`).subscribe((handle: DashQueryHandle) => {
|
|
34
|
+
console.log(`[DashAdapter] Received ${handle.size} bytes from Dash.`);
|
|
35
|
+
|
|
36
|
+
// Assume the handle.buffer contains [pos, color, scale] interleaved or tightly packed
|
|
37
|
+
// For this MVP, we treat it as just positions
|
|
38
|
+
const floatView = new Float32Array(handle.buffer);
|
|
39
|
+
|
|
40
|
+
// Zero-Copy Injection logic would go here
|
|
41
|
+
// We can't strictly "inject" one buffer into 3 separate Float32Arrays unless they are contiguous in the SAB
|
|
42
|
+
// or we create views into offsets.
|
|
43
|
+
|
|
44
|
+
// Hypothetical offset logic:
|
|
45
|
+
const count = handle.size / 4 / 7; // pos + color + scale = 3+3+1 = 7 floats
|
|
46
|
+
|
|
47
|
+
// particleSystem.setSharedBuffers({
|
|
48
|
+
// positions: floatView.subarray(0, count * 3),
|
|
49
|
+
// colors: floatView.subarray(count * 3, count * 6),
|
|
50
|
+
// scales: floatView.subarray(count * 6, count * 7)
|
|
51
|
+
// });
|
|
52
|
+
});
|
|
53
|
+
} else {
|
|
54
|
+
console.warn('[DashAdapter] Dash instance does not support Zero-Copy liveQueryPtr yet.');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -88,6 +88,12 @@ export interface ParticleSystem3DConfig {
|
|
|
88
88
|
boundsCenter?: Vector3;
|
|
89
89
|
/** Bounce factor when hitting bounds (0 = absorb, 1 = perfect bounce) */
|
|
90
90
|
bounceFactor?: number;
|
|
91
|
+
/** Zero-copy shared buffers */
|
|
92
|
+
sharedBuffers?: {
|
|
93
|
+
positions: Float32Array;
|
|
94
|
+
colors: Float32Array;
|
|
95
|
+
scales: Float32Array;
|
|
96
|
+
};
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
/**
|
|
@@ -134,10 +140,25 @@ export class ParticleSystem3D {
|
|
|
134
140
|
this.boundsCenter = config.boundsCenter ?? new Vector3(0, 0, 0);
|
|
135
141
|
this.bounceFactor = config.bounceFactor ?? 0.5;
|
|
136
142
|
|
|
137
|
-
// Pre-allocate buffers
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
// Pre-allocate buffers (unless provided via config for zero-copy)
|
|
144
|
+
if (config.sharedBuffers) {
|
|
145
|
+
this.positionBuffer = config.sharedBuffers.positions;
|
|
146
|
+
this.colorBuffer = config.sharedBuffers.colors;
|
|
147
|
+
this.scaleBuffer = config.sharedBuffers.scales;
|
|
148
|
+
} else {
|
|
149
|
+
this.positionBuffer = new Float32Array(this.maxParticles * 3);
|
|
150
|
+
this.colorBuffer = new Float32Array(this.maxParticles * 3);
|
|
151
|
+
this.scaleBuffer = new Float32Array(this.maxParticles);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Zero-Copy Binding: Inject shared buffers from WASM/Dash
|
|
157
|
+
*/
|
|
158
|
+
setSharedBuffers(buffers: { positions: Float32Array, colors: Float32Array, scales: Float32Array }) {
|
|
159
|
+
this.positionBuffer = buffers.positions;
|
|
160
|
+
this.colorBuffer = buffers.colors;
|
|
161
|
+
this.scaleBuffer = buffers.scales;
|
|
141
162
|
}
|
|
142
163
|
|
|
143
164
|
/**
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface NarrationMessage {
|
|
2
|
+
generation: number;
|
|
3
|
+
timestamp: string;
|
|
4
|
+
priority: number;
|
|
5
|
+
text: string;
|
|
6
|
+
eventType?: string;
|
|
7
|
+
sparkline?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class NarrationManager {
|
|
11
|
+
static getInstance(): any {
|
|
12
|
+
return {
|
|
13
|
+
subscribe: () => () => {},
|
|
14
|
+
getState: () => ({})
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class StatsTracker {
|
|
2
|
+
static getInstance(): StatsTracker {
|
|
3
|
+
return new StatsTracker();
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
getCurrentStats(): any {
|
|
7
|
+
return {
|
|
8
|
+
generation: 1,
|
|
9
|
+
activeMemesCount: 10,
|
|
10
|
+
totalHexesInfected: 100,
|
|
11
|
+
populationStability: 0.5
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getAllTimeRecords(): any {
|
|
16
|
+
return {
|
|
17
|
+
highestTerritory: { value: 100 },
|
|
18
|
+
longestSurvivalStreak: { value: 50 }
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getLeaderboard(limit: number): any[] {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const ThemeColors = {
|
|
2
|
+
primary: '#000000',
|
|
3
|
+
secondary: '#ffffff'
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export function getAccentRgba(alpha: number = 1): string {
|
|
7
|
+
return `rgba(0, 255, 255, ${alpha})`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function getAccentHex(): string {
|
|
11
|
+
return '#00ffff';
|
|
12
|
+
}
|