Spaces:
Paused
Paused
Upload 9 files
Browse files- client/index.html +1 -12
- client/package.json +1 -23
- client/src/App.tsx +1 -3
- client/src/Scene.tsx +39 -0
- client/src/main.tsx +1 -5
- client/tsconfig.json +1 -11
- server/package.json +1 -22
- server/src/index.ts +1 -11
- server/tsconfig.json +1 -12
client/index.html
CHANGED
|
@@ -1,12 +1 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="utf-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
-
<title>Neuro Galaxies</title>
|
| 7 |
-
</head>
|
| 8 |
-
<body>
|
| 9 |
-
<div id="root"></div>
|
| 10 |
-
<script type="module" src="/src/main.tsx"></script>
|
| 11 |
-
</body>
|
| 12 |
-
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html><html><body><div id='root'></div><script type='module' src='/src/main.tsx'></script></body></html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client/package.json
CHANGED
|
@@ -1,23 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "neuro-client",
|
| 3 |
-
"version": "1.0.0",
|
| 4 |
-
"private": true,
|
| 5 |
-
"type": "module",
|
| 6 |
-
"scripts": {
|
| 7 |
-
"dev": "vite",
|
| 8 |
-
"build": "vite build",
|
| 9 |
-
"preview": "vite preview"
|
| 10 |
-
},
|
| 11 |
-
"dependencies": {
|
| 12 |
-
"react": "^18.2.0",
|
| 13 |
-
"react-dom": "^18.2.0",
|
| 14 |
-
"three": "^0.152.2"
|
| 15 |
-
},
|
| 16 |
-
"devDependencies": {
|
| 17 |
-
"typescript": "^5.5.0",
|
| 18 |
-
"vite": "^5.0.0",
|
| 19 |
-
"@vitejs/plugin-react": "^4.2.1",
|
| 20 |
-
"@types/react": "^18.2.28",
|
| 21 |
-
"@types/react-dom": "^18.2.11"
|
| 22 |
-
}
|
| 23 |
-
}
|
|
|
|
| 1 |
+
{"name":"client","private":true,"version":"1.0.0","scripts":{"dev":"vite","build":"vite build","preview":"vite preview"},"dependencies":{"react":"18.2.0","react-dom":"18.2.0","@react-three/fiber":"8.15.10","three":"0.152.2","@react-three/drei":"9.93.0"},"devDependencies":{"vite":"5.0.0","@vitejs/plugin-react":"4.2.1","typescript":"5.5.0"}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client/src/App.tsx
CHANGED
|
@@ -1,3 +1 @@
|
|
| 1 |
-
import React from 'react'
|
| 2 |
-
import Scene from './scene/Scene'
|
| 3 |
-
export default function App(){ return <Scene/> }
|
|
|
|
| 1 |
+
import React from 'react';import Scene from './Scene';export default()=> <Scene/>;
|
|
|
|
|
|
client/src/Scene.tsx
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React,{useRef} from 'react';import {Canvas,useFrame} from '@react-three/fiber';import {OrbitControls} from '@react-three/drei';import * as THREE from 'three';
|
| 2 |
+
|
| 3 |
+
function Comet(){
|
| 4 |
+
const mesh=useRef<THREE.Mesh>(null!);
|
| 5 |
+
const vel=new THREE.Vector3((Math.random()-0.5)*0.2,(Math.random()-0.5)*0.2,(Math.random()-0.5)*0.2);
|
| 6 |
+
useFrame(()=>{
|
| 7 |
+
mesh.current.position.add(vel);
|
| 8 |
+
});
|
| 9 |
+
return <mesh ref={mesh}>
|
| 10 |
+
<sphereGeometry args={[0.12,16,16]}/>
|
| 11 |
+
<meshBasicMaterial color={'white'} transparent opacity={0.9} />
|
| 12 |
+
</mesh>;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function Galaxy(){
|
| 16 |
+
const group=useRef<THREE.Group>(null!);
|
| 17 |
+
const nodes=[...Array(20)].map((_,i)=>({
|
| 18 |
+
pos:[(Math.random()-0.5)*10,(Math.random()-0.5)*5,(Math.random()-0.5)*10]
|
| 19 |
+
}));
|
| 20 |
+
return <group ref={group}>
|
| 21 |
+
{nodes.map((n,i)=>(
|
| 22 |
+
<mesh key={i} position={n.pos}>
|
| 23 |
+
<sphereGeometry args={[0.3,12,12]}/>
|
| 24 |
+
<meshStandardMaterial color={`hsl(${i*20},80%,60%)`}/>
|
| 25 |
+
</mesh>
|
| 26 |
+
))}
|
| 27 |
+
{Array.from({length:8}).map((_,i)=><Comet key={'c'+i}/>)}
|
| 28 |
+
</group>;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
export default function Scene(){
|
| 32 |
+
return <Canvas camera={{position:[0,0,15]}}>
|
| 33 |
+
<color attach="background" args={['#030610']} />
|
| 34 |
+
<ambientLight intensity={0.6}/>
|
| 35 |
+
<directionalLight intensity={0.4} position={[5,10,5]}/>
|
| 36 |
+
<Galaxy/>
|
| 37 |
+
<OrbitControls/>
|
| 38 |
+
</Canvas>;
|
| 39 |
+
}
|
client/src/main.tsx
CHANGED
|
@@ -1,5 +1 @@
|
|
| 1 |
-
import React from 'react'
|
| 2 |
-
import { createRoot } from 'react-dom/client'
|
| 3 |
-
import App from './App'
|
| 4 |
-
import './styles.css'
|
| 5 |
-
createRoot(document.getElementById('root')!).render(<App />)
|
|
|
|
| 1 |
+
import React from 'react';import {createRoot} from 'react-dom/client';import App from './App';createRoot(document.getElementById('root')!).render(<App/>);
|
|
|
|
|
|
|
|
|
|
|
|
client/tsconfig.json
CHANGED
|
@@ -1,11 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"compilerOptions": {
|
| 3 |
-
"target": "ES2022",
|
| 4 |
-
"module": "ESNext",
|
| 5 |
-
"jsx": "react-jsx",
|
| 6 |
-
"moduleResolution": "Node",
|
| 7 |
-
"strict": true,
|
| 8 |
-
"esModuleInterop": true
|
| 9 |
-
},
|
| 10 |
-
"include": ["src"]
|
| 11 |
-
}
|
|
|
|
| 1 |
+
{"compilerOptions":{"jsx":"react-jsx","module":"ESNext","target":"ES2022","moduleResolution":"Node","strict":true},"include":["src"]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server/package.json
CHANGED
|
@@ -1,22 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "neuro-server",
|
| 3 |
-
"version": "1.0.0",
|
| 4 |
-
"type": "module",
|
| 5 |
-
"scripts": {
|
| 6 |
-
"dev": "ts-node-dev --respawn --transpile-only src/index.ts",
|
| 7 |
-
"build": "tsc -p .",
|
| 8 |
-
"start": "node dist/index.js"
|
| 9 |
-
},
|
| 10 |
-
"dependencies": {
|
| 11 |
-
"express": "^4.18.2",
|
| 12 |
-
"cors": "^2.8.5",
|
| 13 |
-
"dotenv": "^16.3.1",
|
| 14 |
-
"node-fetch": "^3.4.2"
|
| 15 |
-
},
|
| 16 |
-
"devDependencies": {
|
| 17 |
-
"typescript": "^5.5.0",
|
| 18 |
-
"ts-node-dev": "^2.0.0",
|
| 19 |
-
"@types/node": "^20.5.6",
|
| 20 |
-
"@types/express": "^4.17.21"
|
| 21 |
-
}
|
| 22 |
-
}
|
|
|
|
| 1 |
+
{"name":"server","type":"module","scripts":{"dev":"ts-node-dev --respawn src/index.ts","build":"tsc -p ."},"dependencies":{"express":"4.18.2","cors":"2.8.5","dotenv":"16.3.1","node-fetch":"3.4.2"},"devDependencies":{"typescript":"5.5.0","ts-node-dev":"2.0.0","@types/node":"20.5.6","@types/express":"4.17.21"}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server/src/index.ts
CHANGED
|
@@ -1,11 +1 @@
|
|
| 1 |
-
import express from 'express'
|
| 2 |
-
import cors from 'cors'
|
| 3 |
-
import dotenv from 'dotenv'
|
| 4 |
-
import apiRouter from './routes/api.js'
|
| 5 |
-
dotenv.config()
|
| 6 |
-
const app = express()
|
| 7 |
-
app.use(cors())
|
| 8 |
-
app.use(express.json())
|
| 9 |
-
app.use('/api', apiRouter)
|
| 10 |
-
const port = Number(process.env.PORT||4000)
|
| 11 |
-
app.listen(port, ()=>{ console.log('server listening', port) })
|
|
|
|
| 1 |
+
import express from 'express';import cors from 'cors';import dotenv from 'dotenv';dotenv.config();const app=express();app.use(cors());app.use(express.json());app.post('/api/generate',(req,res)=>{res.json({ok:true});});app.listen(4000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server/tsconfig.json
CHANGED
|
@@ -1,12 +1 @@
|
|
| 1 |
-
{
|
| 2 |
-
"compilerOptions": {
|
| 3 |
-
"outDir": "dist",
|
| 4 |
-
"rootDir": "src",
|
| 5 |
-
"module": "ESNext",
|
| 6 |
-
"target": "ES2022",
|
| 7 |
-
"moduleResolution": "Node",
|
| 8 |
-
"strict": true,
|
| 9 |
-
"esModuleInterop": true
|
| 10 |
-
},
|
| 11 |
-
"include": ["src"]
|
| 12 |
-
}
|
|
|
|
| 1 |
+
{"compilerOptions":{"outDir":"dist","rootDir":"src","module":"ESNext","target":"ES2022","strict":true,"moduleResolution":"Node","esModuleInterop":true},"include":["src"]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|