-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
69 lines (61 loc) · 2.15 KB
/
Copy pathApp.tsx
File metadata and controls
69 lines (61 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import React, { useRef, useState } from 'react';
import { GraphScene } from './GraphScene';
import { OverlayUI } from './components/OverlayUI';
import { generateGraphData } from './data/generator';
import { NodeData, GraphRef } from './types';
// Generate data once outside component to avoid regeneration on render
const data = generateGraphData();
const App: React.FC = () => {
const [selectedNode, setSelectedNode] = useState<NodeData | null>(null);
const graphRef = useRef<GraphRef>(null);
// Example: Navigate to specific coordinates
const handleNavigate = (view: 'overview' | 'detail' | 'side') => {
if (!graphRef.current) return;
switch (view) {
case 'overview':
graphRef.current.flyTo([0, 0, 1000]);
break;
case 'detail':
// Fly to the injected cube
graphRef.current.flyTo([50, 50, 50], 2);
// Look at it
graphRef.current.lookAt([50, 50, 50], 2);
break;
case 'side':
graphRef.current.flyTo([500, 200, 0]);
graphRef.current.lookAt([0, 0, 0]);
break;
}
};
return (
<div className="relative w-screen h-screen overflow-hidden bg-black">
{/* 1. Spatial Background */}
<GraphScene
ref={graphRef}
data={data}
onNodeSelect={setSelectedNode}
selectedNodeId={selectedNode?.id || null}
>
{/* 2. Injected 3D Content (Optional) */}
{/* Children passed here will be rendered in the 3D scene */}
</GraphScene>
<OverlayUI selectedNode={selectedNode} onClose={() => setSelectedNode(null)} />
{/* 3. HTML Navigation Controls */}
<div className="absolute bottom-8 left-8 flex space-x-4 z-20">
<button
onClick={() => handleNavigate('overview')}
className="bg-white/10 text-white px-4 py-2 rounded hover:bg-white/20 transition backdrop-blur-md"
>
Overview
</button>
<button
onClick={() => handleNavigate('side')}
className="bg-white/10 text-white px-4 py-2 rounded hover:bg-white/20 transition backdrop-blur-md"
>
Side View
</button>
</div>
</div>
);
};
export default App;