From 9faef572032614175c99217c489d9da2f699189b Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sat, 30 Dec 2023 00:40:38 -0500 Subject: [PATCH] th' space background --- .tokeignore | 5 +- backend/src/main.rs | 11 +- backend/src/routes/mod.rs | 1 + frontend/README.md | 30 ---- frontend/package.json | 1 + frontend/pnpm-lock.yaml | 293 +++++++++++++++++++++++++++++++- frontend/src/routes/MapView.tsx | 42 +++-- prisma/schema.prisma | 19 +-- triangle/src/lib.rs | 39 +++-- 9 files changed, 367 insertions(+), 74 deletions(-) delete mode 100644 frontend/README.md diff --git a/.tokeignore b/.tokeignore index 483a9c4..b63d95b 100644 --- a/.tokeignore +++ b/.tokeignore @@ -1 +1,4 @@ -package-lock.json \ No newline at end of file +package-lock.json +triangle-sys/src/triangle.c +triangle-sys/src/triangle.h +pnpm-lock.yaml \ No newline at end of file diff --git a/backend/src/main.rs b/backend/src/main.rs index 2433329..8cad709 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -60,7 +60,7 @@ async fn main() -> Result<()> { // Generate a new triangulation let result = { // Generate a circle of points - let radius = 50.0; + let radius = 1000.0; const NUM_POINTS: usize = 30; let point_list = (0..NUM_POINTS) .map(|n| n as f64 * (2.0 * PI) / NUM_POINTS as f64) @@ -70,7 +70,10 @@ async fn main() -> Result<()> { }); triangulate( - TrianglulateOpts::builder().point_list(point_list).build()?, + TrianglulateOpts::builder() + .point_list(point_list) + .voronoi(true) + .build()?, )? }; @@ -87,8 +90,8 @@ async fn main() -> Result<()> { .map(|point| { star_system::create_unchecked( universe.id.clone(), - point.x as i32, - point.y as i32, + point.x, + point.y, vec![], ) }) diff --git a/backend/src/routes/mod.rs b/backend/src/routes/mod.rs index 4ea2f10..3d8f764 100644 --- a/backend/src/routes/mod.rs +++ b/backend/src/routes/mod.rs @@ -30,6 +30,7 @@ pub async fn universe_map( .prisma .star_system() .find_many(vec![star_system::universe_id::equals(universe_id.clone())]) + .select(star_system::select!({ coord_x coord_y })) .exec() .await .unwrap(); diff --git a/frontend/README.md b/frontend/README.md deleted file mode 100644 index 0d6babe..0000000 --- a/frontend/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# React + TypeScript + Vite - -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. - -Currently, two official plugins are available: - -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh - -## Expanding the ESLint configuration - -If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: - -- Configure the top-level `parserOptions` property like this: - -```js -export default { - // other rules... - parserOptions: { - ecmaVersion: 'latest', - sourceType: 'module', - project: ['./tsconfig.json', './tsconfig.node.json'], - tsconfigRootDir: __dirname, - }, -} -``` - -- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` -- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` -- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list diff --git a/frontend/package.json b/frontend/package.json index 4a1cdb5..8602970 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -16,6 +16,7 @@ "@blueprintjs/core": "^5.7.2", "@blueprintjs/icons": "^5.5.0", "@blueprintjs/table": "^5.0.20", + "@react-three/drei": "^9.92.7", "@react-three/fiber": "^8.15.12", "@types/three": "^0.160.0", "normalize.css": "^8.0.1", diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 0ea843a..0288fa6 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -14,6 +14,9 @@ dependencies: '@blueprintjs/table': specifier: ^5.0.20 version: 5.0.20(@types/react@18.2.46)(react-dom@18.2.0)(react@18.2.0) + '@react-three/drei': + specifier: ^9.92.7 + version: 9.92.7(@react-three/fiber@8.15.12)(@types/three@0.160.0)(react-dom@18.2.0)(react@18.2.0)(three@0.160.0) '@react-three/fiber': specifier: ^8.15.12 version: 8.15.12(react-dom@18.2.0)(react@18.2.0)(three@0.160.0) @@ -419,6 +422,10 @@ packages: resolution: {integrity: sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==} dev: true + /@mediapipe/tasks-vision@0.10.8: + resolution: {integrity: sha512-Rp7ll8BHrKB3wXaRFKhrltwZl1CiXGdibPxuWXvqGnKTnv8fqa/nvftYNuSbf+pbJWKYCXdBtYTITdAUTGGh0Q==} + dev: false + /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -444,6 +451,105 @@ packages: resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==} dev: false + /@react-spring/animated@9.6.1(react@18.2.0): + resolution: {integrity: sha512-ls/rJBrAqiAYozjLo5EPPLLOb1LM0lNVQcXODTC1SMtS6DbuBCPaKco5svFUQFMP2dso3O+qcC4k9FsKc0KxMQ==} + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + dependencies: + '@react-spring/shared': 9.6.1(react@18.2.0) + '@react-spring/types': 9.6.1 + react: 18.2.0 + dev: false + + /@react-spring/core@9.6.1(react@18.2.0): + resolution: {integrity: sha512-3HAAinAyCPessyQNNXe5W0OHzRfa8Yo5P748paPcmMowZ/4sMfaZ2ZB6e5x5khQI8NusOHj8nquoutd6FRY5WQ==} + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + dependencies: + '@react-spring/animated': 9.6.1(react@18.2.0) + '@react-spring/rafz': 9.6.1 + '@react-spring/shared': 9.6.1(react@18.2.0) + '@react-spring/types': 9.6.1 + react: 18.2.0 + dev: false + + /@react-spring/rafz@9.6.1: + resolution: {integrity: sha512-v6qbgNRpztJFFfSE3e2W1Uz+g8KnIBs6SmzCzcVVF61GdGfGOuBrbjIcp+nUz301awVmREKi4eMQb2Ab2gGgyQ==} + dev: false + + /@react-spring/shared@9.6.1(react@18.2.0): + resolution: {integrity: sha512-PBFBXabxFEuF8enNLkVqMC9h5uLRBo6GQhRMQT/nRTnemVENimgRd+0ZT4yFnAQ0AxWNiJfX3qux+bW2LbG6Bw==} + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + dependencies: + '@react-spring/rafz': 9.6.1 + '@react-spring/types': 9.6.1 + react: 18.2.0 + dev: false + + /@react-spring/three@9.6.1(@react-three/fiber@8.15.12)(react@18.2.0)(three@0.160.0): + resolution: {integrity: sha512-Tyw2YhZPKJAX3t2FcqvpLRb71CyTe1GvT3V+i+xJzfALgpk10uPGdGaQQ5Xrzmok1340DAeg2pR/MCfaW7b8AA==} + peerDependencies: + '@react-three/fiber': '>=6.0' + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + three: '>=0.126' + dependencies: + '@react-spring/animated': 9.6.1(react@18.2.0) + '@react-spring/core': 9.6.1(react@18.2.0) + '@react-spring/shared': 9.6.1(react@18.2.0) + '@react-spring/types': 9.6.1 + '@react-three/fiber': 8.15.12(react-dom@18.2.0)(react@18.2.0)(three@0.160.0) + react: 18.2.0 + three: 0.160.0 + dev: false + + /@react-spring/types@9.6.1: + resolution: {integrity: sha512-POu8Mk0hIU3lRXB3bGIGe4VHIwwDsQyoD1F394OK7STTiX9w4dG3cTLljjYswkQN+hDSHRrj4O36kuVa7KPU8Q==} + dev: false + + /@react-three/drei@9.92.7(@react-three/fiber@8.15.12)(@types/three@0.160.0)(react-dom@18.2.0)(react@18.2.0)(three@0.160.0): + resolution: {integrity: sha512-97M/1lc0swq4WEDk4H0p4pePyjbuzBq+qXj768nVEghalfUXqwXIcSg2KClFATP25xnqdpAU9MOTujFLS2/USw==} + peerDependencies: + '@react-three/fiber': '>=8.0' + react: '>=18.0' + react-dom: '>=18.0' + three: '>=0.137' + peerDependenciesMeta: + react-dom: + optional: true + dependencies: + '@babel/runtime': 7.23.7 + '@mediapipe/tasks-vision': 0.10.8 + '@react-spring/three': 9.6.1(@react-three/fiber@8.15.12)(react@18.2.0)(three@0.160.0) + '@react-three/fiber': 8.15.12(react-dom@18.2.0)(react@18.2.0)(three@0.160.0) + '@use-gesture/react': 10.3.0(react@18.2.0) + camera-controls: 2.7.3(three@0.160.0) + cross-env: 7.0.3 + detect-gpu: 5.0.37 + glsl-noise: 0.0.0 + lodash.clamp: 4.0.3 + lodash.omit: 4.5.0 + lodash.pick: 4.4.0 + maath: 0.10.7(@types/three@0.160.0)(three@0.160.0) + meshline: 3.1.7(three@0.160.0) + react: 18.2.0 + react-composer: 5.0.3(react@18.2.0) + react-dom: 18.2.0(react@18.2.0) + react-merge-refs: 1.1.0 + stats-gl: 2.0.1 + stats.js: 0.17.0 + suspend-react: 0.1.3(react@18.2.0) + three: 0.160.0 + three-mesh-bvh: 0.6.8(three@0.160.0) + three-stdlib: 2.28.9(three@0.160.0) + troika-three-text: 0.47.2(three@0.160.0) + utility-types: 3.10.0 + uuid: 9.0.1 + zustand: 3.7.2(react@18.2.0) + transitivePeerDependencies: + - '@types/three' + dev: false + /@react-three/fiber@8.15.12(react-dom@18.2.0)(react@18.2.0)(three@0.160.0): resolution: {integrity: sha512-yg0CyXVHIdSbNjM/GAgDrGJnKLTsfTlaR5FoJGEh9IgVKptOoudnFZhBt/Cau4rzx2X6eLmB1+aWOm1dEHSUpg==} peerDependencies: @@ -717,10 +823,18 @@ packages: resolution: {integrity: sha512-myfUej5naTBWnqOCc/MdVOLVjXUXtIA+NpDrDBKJtLLg2shUjBu3cZmB/85RyitKc55+lUUyl7oRfLOvkr2hsw==} dev: true + /@types/draco3d@1.4.9: + resolution: {integrity: sha512-4MMUjMQb4yA5fJ4osXx+QxGHt0/ZSy4spT6jL1HM7Tn8OJEC35siqdnpOo+HxPhYjqEFumKfGVF9hJfdyKBIBA==} + dev: false + /@types/json-schema@7.0.15: resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} dev: true + /@types/offscreencanvas@2019.7.3: + resolution: {integrity: sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==} + dev: false + /@types/prop-types@15.7.11: resolution: {integrity: sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==} @@ -909,6 +1023,19 @@ packages: resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} dev: true + /@use-gesture/core@10.3.0: + resolution: {integrity: sha512-rh+6MND31zfHcy9VU3dOZCqGY511lvGcfyJenN4cWZe0u1BH6brBpBddLVXhF2r4BMqWbvxfsbL7D287thJU2A==} + dev: false + + /@use-gesture/react@10.3.0(react@18.2.0): + resolution: {integrity: sha512-3zc+Ve99z4usVP6l9knYVbVnZgfqhKah7sIG+PS2w+vpig2v2OLct05vs+ZXMzwxdNCMka8B+8WlOo0z6Pn6DA==} + peerDependencies: + react: '>= 16.8.0' + dependencies: + '@use-gesture/core': 10.3.0 + react: 18.2.0 + dev: false + /@vitejs/plugin-react-swc@3.5.0(vite@5.0.10): resolution: {integrity: sha512-1PrOvAaDpqlCV+Up8RkAh9qaiUjoDUcjtttyhXDKw53XA6Ve16SOp6cCOpRs8Dj8DqUQs6eTW5YkLcLJjrXAig==} peerDependencies: @@ -979,6 +1106,12 @@ packages: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} dev: false + /bidi-js@1.0.3: + resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==} + dependencies: + require-from-string: 2.0.2 + dev: false + /big-integer@1.6.52: resolution: {integrity: sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==} engines: {node: '>=0.6'} @@ -1040,6 +1173,14 @@ packages: tslib: 2.6.2 dev: false + /camera-controls@2.7.3(three@0.160.0): + resolution: {integrity: sha512-L4mxjBd3u8qiOLozdWrH2P8ZybSsDXBF7iyNyqNEFJhPUkovmuARWR8JTc1B/qlclOIg6FvZZA/0uAZMMim0mw==} + peerDependencies: + three: '>=0.126.1' + dependencies: + three: 0.160.0 + dev: false + /capital-case@1.0.4: resolution: {integrity: sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==} dependencies: @@ -1114,6 +1255,14 @@ packages: upper-case: 2.0.2 dev: false + /cross-env@7.0.3: + resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==} + engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'} + hasBin: true + dependencies: + cross-spawn: 7.0.3 + dev: false + /cross-spawn@7.0.3: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} engines: {node: '>= 8'} @@ -1121,7 +1270,6 @@ packages: path-key: 3.1.1 shebang-command: 2.0.0 which: 2.0.2 - dev: true /csstype@3.1.3: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} @@ -1146,6 +1294,12 @@ packages: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: true + /detect-gpu@5.0.37: + resolution: {integrity: sha512-EraWs84faI4iskB4qvE39bevMIazEvd1RpoyGLOBesRLbiz6eMeJqqRPHjEFClfRByYZzi9IzU35rBXIO76oDw==} + dependencies: + webgl-constants: 1.1.1 + dev: false + /detect-node@2.1.0: resolution: {integrity: sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==} dev: false @@ -1178,6 +1332,10 @@ packages: tslib: 2.6.2 dev: false + /draco3d@1.5.6: + resolution: {integrity: sha512-+3NaRjWktb5r61ZFoDejlykPEFKT5N/LkbXsaddlw6xNSXBanUYpFc2AXXpbJDilPHazcSreU/DpQIaxfX0NfQ==} + dev: false + /esbuild@0.19.11: resolution: {integrity: sha512-HJ96Hev2hX/6i5cDVwcqiJBBtuo9+FeIJOtZ9W1kA5M6AMJRHUZlpYZ1/SbEwtO0ioNAW8rUooVpC/WehY2SfA==} engines: {node: '>=12'} @@ -1446,6 +1604,10 @@ packages: slash: 3.0.0 dev: true + /glsl-noise@0.0.0: + resolution: {integrity: sha512-b/ZCF6amfAUb7dJM/MxRs7AetQEahYzJ8PtgfrmEdtw6uyGOr+ZSGtgjFm6mfsBkxJ4d2W7kg+Nlqzqvn3Bc0w==} + dev: false + /graphemer@1.4.0: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} dev: true @@ -1528,7 +1690,6 @@ packages: /isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - dev: true /its-fine@1.1.1(react@18.2.0): resolution: {integrity: sha512-v1Ia1xl20KbuSGlwoaGsW0oxsw8Be+TrXweidxD9oT/1lAh6O3K3/GIM95Tt6WCiv6W+h2M7RB1TwdoAjQyyKw==} @@ -1587,10 +1748,22 @@ packages: p-locate: 5.0.0 dev: true + /lodash.clamp@4.0.3: + resolution: {integrity: sha512-HvzRFWjtcguTW7yd8NJBshuNaCa8aqNFtnswdT7f/cMd/1YKy5Zzoq4W/Oxvnx9l7aeY258uSdDfM793+eLsVg==} + dev: false + /lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} dev: true + /lodash.omit@4.5.0: + resolution: {integrity: sha512-XeqSp49hNGmlkj2EJlfrQFIzQ6lXdNro9sddtQzcJY8QaoC2GO0DT7xaIokHeyM+mIT0mPMlPvkYzg2xCuHdZg==} + dev: false + + /lodash.pick@4.4.0: + resolution: {integrity: sha512-hXt6Ul/5yWjfklSGvLQl8vM//l3FtyHZeuelpzK6mm99pNvN9yTDruNZPEJZD1oWrqo+izBmB7oUfWgcCX7s4Q==} + dev: false + /loose-envify@1.4.0: resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} hasBin: true @@ -1611,6 +1784,16 @@ packages: yallist: 4.0.0 dev: true + /maath@0.10.7(@types/three@0.160.0)(three@0.160.0): + resolution: {integrity: sha512-zQ2xd7dNOIVTjAS+hj22fyj1EFYmOJX6tzKjZ92r6WDoq8hyFxjuGA2q950tmR4iC/EKXoMQdSipkaJVuUHDTg==} + peerDependencies: + '@types/three': '>=0.144.0' + three: '>=0.144.0' + dependencies: + '@types/three': 0.160.0 + three: 0.160.0 + dev: false + /match-sorter@6.3.1: resolution: {integrity: sha512-mxybbo3pPNuA+ZuCUhm5bwNkXrJTbsk5VWbR5wiwz/GC6LIiegBGn2w3O08UG/jdbYLinw51fSQ5xNU1U3MgBw==} dependencies: @@ -1623,6 +1806,14 @@ packages: engines: {node: '>= 8'} dev: true + /meshline@3.1.7(three@0.160.0): + resolution: {integrity: sha512-uf9fPI9wy0Ie0kZjvKuIkf2n7gi3ih0wdTeb/kmSvmzpPyEL5d9lFohg9+JV9VC4sQUBOZDgxu6fnjn57goSHg==} + peerDependencies: + three: '>=0.137' + dependencies: + three: 0.160.0 + dev: false + /meshoptimizer@0.18.1: resolution: {integrity: sha512-ZhoIoL7TNV4s5B6+rx5mC//fw8/POGyNxS/DZyCJeiZ12ScLfVwRE/GfsxwiTkMYYD5DmK2/JXnEVXqL4rF+Sw==} dev: false @@ -1767,7 +1958,6 @@ packages: /path-key@3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} - dev: true /path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} @@ -1792,6 +1982,10 @@ packages: source-map-js: 1.0.2 dev: true + /potpack@1.0.2: + resolution: {integrity: sha512-choctRBIV9EMT9WGAZHn3V7t0Z2pMQyl0EZE6pFc/6ml3ssw7Dlf/oAOvFwjm1HVsqfQN8GfeFyJ+d8tRzqueQ==} + dev: false + /prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -1814,6 +2008,15 @@ packages: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} dev: true + /react-composer@5.0.3(react@18.2.0): + resolution: {integrity: sha512-1uWd07EME6XZvMfapwZmc7NgCZqDemcvicRi3wMJzXsQLvZ3L7fTHVyPy1bZdnWXM4iPjYuNE+uJ41MLKeTtnA==} + peerDependencies: + react: ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 + dependencies: + prop-types: 15.8.1 + react: 18.2.0 + dev: false + /react-dom@18.2.0(react@18.2.0): resolution: {integrity: sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==} peerDependencies: @@ -1842,6 +2045,10 @@ packages: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} dev: false + /react-merge-refs@1.1.0: + resolution: {integrity: sha512-alTKsjEL0dKH/ru1Iyn7vliS2QRcBp9zZPGoWxUOvRGWPUYgjo+V01is7p04It6KhgrzhJGnIj9GgX8W4bZoCQ==} + dev: false + /react-popper@2.3.0(@popperjs/core@2.11.8)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-e1hj8lL3uM+sgSR4Lxzn5h1GxBlpa4CQz0XLF8kx4MDrDRWY0Ena4c97PUeSX9i5W3UAfDP0z0FXCTQkoXUl3Q==} peerDependencies: @@ -1956,6 +2163,11 @@ packages: resolution: {integrity: sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA==} dev: false + /require-from-string@2.0.2: + resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} + engines: {node: '>=0.10.0'} + dev: false + /resolve-from@4.0.0: resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} engines: {node: '>=4'} @@ -2042,12 +2254,10 @@ packages: engines: {node: '>=8'} dependencies: shebang-regex: 3.0.0 - dev: true /shebang-regex@3.0.0: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} - dev: true /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} @@ -2066,6 +2276,14 @@ packages: engines: {node: '>=0.10.0'} dev: true + /stats-gl@2.0.1: + resolution: {integrity: sha512-EhFm1AxoSBK3MflkFawZ4jmOX1dWu0nBAtCpvGxGsondEvCpsohbpRpM8pi8UAcxG5eRsDsCiRcxdH20j3Rp9A==} + dev: false + + /stats.js@0.17.0: + resolution: {integrity: sha512-hNKz8phvYLPEcRkeG1rsGmV5ChMjKDAWU7/OJJdDErPBNChQXxCo3WZurGpnWc6gZhAzEPFad1aVgyOANH1sMw==} + dev: false + /strip-ansi@6.0.1: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} @@ -2097,6 +2315,28 @@ packages: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} dev: true + /three-mesh-bvh@0.6.8(three@0.160.0): + resolution: {integrity: sha512-EGebF9DZx1S8+7OZYNNTT80GXJZVf+UYXD/HyTg/e2kR/ApofIFfUS4ZzIHNnUVIadpnLSzM4n96wX+l7GMbnQ==} + peerDependencies: + three: '>= 0.151.0' + dependencies: + three: 0.160.0 + dev: false + + /three-stdlib@2.28.9(three@0.160.0): + resolution: {integrity: sha512-rZr9r4wwigQ3VjvvXRpwri1zswv4an/WpW2zPKmylfG2p2Du6AAsmjGbwICxWjPCg1jR0sJN8p8s8msFBg0RaQ==} + peerDependencies: + three: '>=0.128.0' + dependencies: + '@types/draco3d': 1.4.9 + '@types/offscreencanvas': 2019.7.3 + '@types/webxr': 0.5.10 + draco3d: 1.5.6 + fflate: 0.6.10 + potpack: 1.0.2 + three: 0.160.0 + dev: false + /three@0.160.0: resolution: {integrity: sha512-DLU8lc0zNIPkM7rH5/e1Ks1Z8tWCGRq6g8mPowdDJpw1CFBJMU7UoJjC6PefXW7z//SSl0b2+GCw14LB+uDhng==} dev: false @@ -2108,6 +2348,30 @@ packages: is-number: 7.0.0 dev: true + /troika-three-text@0.47.2(three@0.160.0): + resolution: {integrity: sha512-qylT0F+U7xGs+/PEf3ujBdJMYWbn0Qci0kLqI5BJG2kW1wdg4T1XSxneypnF05DxFqJhEzuaOR9S2SjiyknMng==} + peerDependencies: + three: '>=0.125.0' + dependencies: + bidi-js: 1.0.3 + three: 0.160.0 + troika-three-utils: 0.47.2(three@0.160.0) + troika-worker-utils: 0.47.2 + webgl-sdf-generator: 1.1.1 + dev: false + + /troika-three-utils@0.47.2(three@0.160.0): + resolution: {integrity: sha512-/28plhCxfKtH7MSxEGx8e3b/OXU5A0xlwl+Sbdp0H8FXUHKZDoksduEKmjQayXYtxAyuUiCRunYIv/8Vi7aiyg==} + peerDependencies: + three: '>=0.125.0' + dependencies: + three: 0.160.0 + dev: false + + /troika-worker-utils@0.47.2: + resolution: {integrity: sha512-mzss4MeyzUkYBppn4x5cdAqrhBHFEuVmMMgLMTyFV23x6GvQMyo+/R5E5Lsbrt7WSt5RfvewjcwD1DChRTA9lA==} + dev: false + /ts-api-utils@1.0.3(typescript@5.3.3): resolution: {integrity: sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==} engines: {node: '>=16.13.0'} @@ -2164,6 +2428,16 @@ packages: punycode: 2.3.1 dev: true + /utility-types@3.10.0: + resolution: {integrity: sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==} + engines: {node: '>= 4'} + dev: false + + /uuid@9.0.1: + resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} + hasBin: true + dev: false + /vite@5.0.10(sass@1.69.6): resolution: {integrity: sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw==} engines: {node: ^18.0.0 || >=20.0.0} @@ -2206,13 +2480,20 @@ packages: loose-envify: 1.4.0 dev: false + /webgl-constants@1.1.1: + resolution: {integrity: sha512-LkBXKjU5r9vAW7Gcu3T5u+5cvSvh5WwINdr0C+9jpzVB41cjQAP5ePArDtk/WHYdVj0GefCgM73BA7FlIiNtdg==} + dev: false + + /webgl-sdf-generator@1.1.1: + resolution: {integrity: sha512-9Z0JcMTFxeE+b2x1LJTdnaT8rT8aEp7MVxkNwoycNmJWwPdzoXzMh0BjJSh/AEFP+KPYZUli814h8bJZFIZ2jA==} + dev: false + /which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} hasBin: true dependencies: isexe: 2.0.0 - dev: true /wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} diff --git a/frontend/src/routes/MapView.tsx b/frontend/src/routes/MapView.tsx index 987e331..a50e7e7 100644 --- a/frontend/src/routes/MapView.tsx +++ b/frontend/src/routes/MapView.tsx @@ -1,14 +1,25 @@ import { useRef, useState } from "react"; import { useQuery } from "react-query"; -import { Canvas, useFrame, type MeshProps } from "@react-three/fiber"; +import { + Canvas, + useFrame, + type MeshProps, + useLoader, +} from "@react-three/fiber"; import styles from "./MapView.module.scss"; import { useParams } from "react-router-dom"; +import { MapControls } from "@react-three/drei"; +import { DoubleSide, TextureLoader } from "three"; export default function MapView({}) { const { universeId } = useParams(); const { isLoading, data } = useQuery(`universe ${universeId} points`, () => fetch(`/api/universe/${universeId}/map`).then((res) => res.json()), ); + const outerSpace = useLoader( + TextureLoader, + "https://s3-us-west-2.amazonaws.com/s.cdpn.io/96252/space.jpg", + ); if (isLoading) return <>...; console.log("data", data); @@ -17,34 +28,40 @@ export default function MapView({}) {
- + {/* */} + + + + + + {data.points.map((point) => { - console.log("point", point); - return ( - - ); + const x = point.coordX / 80; + const y = point.coordY / 80; + console.log("point", x, y); + return ; })}
); } -function Box(props: MeshProps) { +function Box({ position, ...props }: MeshProps) { const meshRef = useRef(); const [hovered, setHover] = useState(false); const [active, setActive] = useState(false); + // Subscribe this component to the render-loop, rotate the mesh every frame useFrame((_state, delta) => { meshRef.current.rotation.x += delta; }); + // Return view, these are regular three.js elements expressed in JSX return ( setActive(!active)} @@ -52,7 +69,10 @@ function Box(props: MeshProps) { onPointerOut={(_event) => setHover(false)} > - + ); } diff --git a/prisma/schema.prisma b/prisma/schema.prisma index b0c56b6..d220d22 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -55,31 +55,28 @@ model Empire { } model StarSystem { + id String @id @default(uuid()) universeId String universe Universe @relation(fields: [universeId], references: [id]) - coordX Int - coordY Int + coordX Float + coordY Float inbound StarSystemEdges[] @relation("inbound") outbound StarSystemEdges[] @relation("outbound") - - @@id([universeId, coordX, coordY]) } model StarSystemEdges { universeId String universe Universe @relation(fields: [universeId], references: [id]) - fromX Int - fromY Int - from StarSystem @relation(fields: [universeId, fromX, fromY], references: [universeId, coordX, coordY], name: "outbound") + fromSystemId String + from StarSystem @relation(fields: [fromSystemId], references: [id], name: "outbound") - toX Int - toY Int - to StarSystem @relation(fields: [universeId, toX, toY], references: [universeId, coordX, coordY], name: "inbound") + toSystemId String + to StarSystem @relation(fields: [toSystemId], references: [id], name: "inbound") - @@id([universeId, fromX, fromY, toX, toY]) + @@id([universeId, fromSystemId, toSystemId]) } model Planet { diff --git a/triangle/src/lib.rs b/triangle/src/lib.rs index ede7a62..e67b69f 100644 --- a/triangle/src/lib.rs +++ b/triangle/src/lib.rs @@ -33,6 +33,7 @@ pub struct Point { #[derive(Debug)] pub struct TriangulateResult { pub point_list: Vec, + pub voronoi_point_list: Vec, } pub fn triangulate

(opts: TrianglulateOpts

) -> Result @@ -40,6 +41,12 @@ where P: IntoIterator, { let mut switches = Vec::new(); + switches.push("p"); + switches.push("c"); + switches.push("z"); + switches.push("A"); + switches.push("e"); + switches.push("n"); if opts.voronoi { switches.push("v"); } @@ -78,21 +85,31 @@ where ) }; - println!("Triangulated."); + println!("Triangulated {}.", output.numberoftriangles); - let flat_point_list = unsafe { - Vec::from_raw_parts( - output.pointlist, - output.numberofpoints as usize * 2, - output.numberofpoints as usize * 2, - ) - }; - let point_list = flat_point_list + let point_list = point_list_from_flat_point_list( + output.pointlist, + output.numberofpoints as usize * 2, + ); + + let voronoi_point_list = point_list_from_flat_point_list( + vorout.pointlist, + vorout.numberofpoints as usize * 2, + ); + + Ok(TriangulateResult { + point_list, + voronoi_point_list, + }) +} + +fn point_list_from_flat_point_list(ptr: *mut f64, len: usize) -> Vec { + let flat_point_list = unsafe { Vec::from_raw_parts(ptr, len, len) }; + flat_point_list .chunks(2) .map(|points| Point { x: points[0], y: points[1], }) - .collect::>(); - Ok(TriangulateResult { point_list }) + .collect::>() }