From 79cb86998ab673f363f2d3f94d68cb40f2d8352f Mon Sep 17 00:00:00 2001 From: zojgame Date: Wed, 10 Jan 2024 17:54:01 +0500 Subject: [PATCH] refactoring --- src/App.css | 2 +- src/App.jsx | 63 +++++++++++++++++++++++---------------------------- src/index.css | 4 ++-- src/main.jsx | 8 +++---- 4 files changed, 35 insertions(+), 42 deletions(-) diff --git a/src/App.css b/src/App.css index 75f52b6..5cc1498 100644 --- a/src/App.css +++ b/src/App.css @@ -1,4 +1,4 @@ #root { - margin: 0 auto; + /* margin: 0 auto; */ text-align: center; } diff --git a/src/App.jsx b/src/App.jsx index 2d3e858..f14b370 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -93,8 +93,8 @@ const nodes = [ }, ]; -init(); -animate(); +// init(); +// animate(); function createSphere( radius, @@ -146,6 +146,7 @@ function createButton(title, x, y, z) { const btn = document.createElement("button"); btn.textContent = title; btn.style.backgroundColor = "#fff"; + btn.style.color = "#000"; btn.style.border = "none"; btn.style.borderRadius = "50%"; btn.style.height = "60px"; @@ -204,8 +205,8 @@ function removeButtons(buttons) { } } -function createScene() { - const container = document.getElementById("root"); +function createScene(refContainer) { + // const container = document.getElementById("root"); timeline = gsap.timeline(); scene = new THREE.Scene(); @@ -220,23 +221,19 @@ function createScene() { renderer = new THREE.WebGLRenderer(); renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(window.innerWidth, window.innerHeight); - container.appendChild(renderer.domElement); + // container.appendChild(renderer.domElement); - // if (refContainer) { - // refContainer.current && refContainer.appendChild(renderer.domElement); - // } + refContainer.current && refContainer.current.appendChild(renderer.domElement); labelRenderer = new CSS2DRenderer(); labelRenderer.setSize(window.innerWidth, window.innerHeight); labelRenderer.domElement.style.position = "absolute"; labelRenderer.domElement.style.top = "0px"; labelRenderer.domElement.style.pointerEvents = "none"; - container.appendChild(labelRenderer.domElement); + // container.appendChild(labelRenderer.domElement); - // if (refContainer) { - // refContainer.current && refContainer.appendChild(labelRenderer.domElement); - // // refContainer.current && refContainer.appendChild(renderer.domElement); - // } + refContainer.current && + refContainer.current.appendChild(labelRenderer.domElement); const controls = new OrbitControls(camera, renderer.domElement); controls.update(); @@ -252,13 +249,11 @@ function selectLocation(texture, material) { } function animateTransition(onCompleteCallback) { - console.log("currentTexture", currentTexture); timeline .to(currentTexture, { onStart: () => console.time("test"), onComplete: () => { onCompleteCallback(); - console.log("currentTexture1", currentTexture); console.timeEnd("test"); }, duration: 0.5, @@ -268,10 +263,10 @@ function animateTransition(onCompleteCallback) { }); } -function init() { - createScene(); +function init(refContainer) { + createScene(refContainer); - // Создание первой локации + // Инициализация первой локации const currentNode = nodes[0]; const texture = new THREE.TextureLoader().load(currentNode.panorama); const material = new THREE.MeshBasicMaterial({ map: texture }); @@ -291,25 +286,23 @@ function update() { labelRenderer.render(scene, camera); } -// function Three() { -// const refContainer = useRef(null); +function Three() { + const refContainer = useRef(null); -// useEffect(() => { -// if (refContainer) { -// init(refContainer); -// animate(); -// } -// }, []); + useEffect(() => { + init(refContainer); + animate(); + }); -// return
; -// } + return
; +} -// function App() { -// return ( -// <> -// -// -// ); -// } +function App() { + return ( + <> + + + ); +} export default App; diff --git a/src/index.css b/src/index.css index 2a3b6aa..65a8f07 100644 --- a/src/index.css +++ b/src/index.css @@ -4,9 +4,9 @@ font-weight: 400; color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); + /* color: rgba(255, 255, 255, 0.87); */ /* background-color: #242424; */ - background-color: #fff; + /* background-color: #fff; */ font-synthesis: none; text-rendering: optimizeLegibility; diff --git a/src/main.jsx b/src/main.jsx index 8115508..a73434f 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -5,8 +5,8 @@ import App from "./App.jsx"; import "./index.css"; ReactDOM.createRoot(document.getElementById("root")).render( - - {/* */} - {/* */} - + + // + + // );