diff --git a/front/package.json b/front/package.json index 8bd44d7..32aba92 100644 --- a/front/package.json +++ b/front/package.json @@ -10,9 +10,14 @@ "preview": "vite preview" }, "dependencies": { + "@react-three/drei": "^9.120.0", + "@react-three/fiber": "^8.17.10", + "@types/three": "^0.170.0", "react": "^18.3.1", "react-dom": "^18.3.1", - "react-router": "^7.0.2" + "react-router": "^7.0.2", + "three": "^0.171.0", + "three-stdlib": "^2.34.0" }, "devDependencies": { "@eslint/js": "^9.15.0", diff --git a/front/src/components/3d/Ocean.tsx b/front/src/components/3d/Ocean.tsx new file mode 100644 index 0000000..63981b4 --- /dev/null +++ b/front/src/components/3d/Ocean.tsx @@ -0,0 +1,49 @@ +// src/components/Ocean.tsx +import React, { useEffect, useRef } from 'react'; +import * as THREE from 'three'; +import { Water } from 'three/examples/jsm/objects/Water.js'; + +const Ocean: React.FC = () => { + + const waterGeometry = new THREE.PlaneGeometry(10000, 10000); + const waterOption = { + textureWidth: 512, + textureHeight: 512, + waterNormals: new THREE.TextureLoader().load('https://threejs.org/examples/textures/waternormals.jpg', function (texture) { + texture.wrapS = texture.wrapT = THREE.RepeatWrapping; + }), + alpha: 1.0, + sunDirection: new THREE.Vector3(), + sunColor: 0xffffff, + waterColor: 0x001e0f, + distortionScale: 3.7, + fog: false, + }; + const water = new Water(waterGeometry, waterOption); + water.rotation.x = -Math.PI / 2; + + const waterRef = useRef(null); + useEffect(() => { + if (waterRef.current) { + waterRef.current.add(water); + } + }, [waterRef]); + + + useEffect(() => { + const animate = () => { + requestAnimationFrame(animate); + water.material.uniforms['time'].value += 1.0 / 60.0; + }; + animate(); + }, []); + + return ( + + + + + ); +}; + +export default Ocean; diff --git a/front/src/index.css b/front/src/index.css index 6119ad9..02a41f8 100644 --- a/front/src/index.css +++ b/front/src/index.css @@ -3,7 +3,7 @@ line-height: 1.5; font-weight: 400; - color-scheme: light dark; + color-scheme: light dark; color: rgba(255, 255, 255, 0.87); background-color: #242424; diff --git a/front/src/main.tsx b/front/src/main.tsx index 4de8dee..3bc8b7f 100644 --- a/front/src/main.tsx +++ b/front/src/main.tsx @@ -2,7 +2,7 @@ import { BrowserRouter, Route, Routes } from "react-router"; import { createRoot } from 'react-dom/client' import './index.css' import App from './App.tsx' -import MainPage from "./pages/MainPage.tsx"; +import MainPage from "./pages/main.tsx"; import GamePage from "./pages/GamePage.tsx"; diff --git a/front/src/pages/GamePage.tsx b/front/src/pages/GamePage.tsx index f984288..c1eb1e9 100644 --- a/front/src/pages/GamePage.tsx +++ b/front/src/pages/GamePage.tsx @@ -1,9 +1,29 @@ +import { Canvas } from "@react-three/fiber"; +import { OrbitControls, Sky } from "@react-three/drei"; +import * as THREE from "three"; +import { useEffect, useRef } from "react"; +import Ocean from "../components/3d/Ocean"; + + + export default function GamePage() { return ( -
-

Game Page

+
+ + + + + + + + + + + + + +
) -} - +} \ No newline at end of file diff --git a/front/src/pages/MainPage.tsx b/front/src/pages/main.tsx similarity index 100% rename from front/src/pages/MainPage.tsx rename to front/src/pages/main.tsx