From 2d5c52b3ea4c915511650002ca0601af3468444b Mon Sep 17 00:00:00 2001 From: root Date: Sun, 21 Aug 2022 21:55:04 +0000 Subject: [PATCH] =?UTF-8?q?Camera=20bewegung=20eingef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 5 +++++ main.js | 38 ++++++++++++++++++++++---------------- saturn/saturn.js | 5 +++-- style.css | 18 +++++++++++++++--- 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/index.html b/index.html index 1641a9d..24da96c 100644 --- a/index.html +++ b/index.html @@ -13,6 +13,11 @@

„Jedes Lebewesen ist ein Rädchen im Getriebe des Universums. Obwohl scheinbar nur seine unmittelbare Umgebung betroffen ist, erstreckt sich der Einflussbereich jedes Lebewesens über eine unendliche Distanz.“ - Nikola Tesla

+
+

Moin!

+ Texturen von https://www.solarsystemscope.com/textures/ +
+ diff --git a/main.js b/main.js index 3029b18..1c91ab7 100644 --- a/main.js +++ b/main.js @@ -26,9 +26,15 @@ const renderer = new THREE.WebGLRenderer({ renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(window.innerWidth, window.innerHeight); -camera.position.setZ(30); -camera.position.setX(-200); -camera.position.setY(30); + + + +var cameraX = 200; +var cameraY = 100; +var cameraZ = 100; +camera.position.setZ(cameraZ); +camera.position.setX(cameraX); +camera.position.setY(cameraY); // Die Sonne const sunTexture = new THREE.TextureLoader().load('sun.jpg') @@ -45,6 +51,7 @@ const pivotMARS = new THREE.Object3D(); const pivotJUPITER = new THREE.Object3D(); const pivotSATURN = new THREE.Object3D(); const pivotURANUS = new THREE.Object3D(); +const pivotCamera = new THREE.Object3D(); scene.add(pivotEARTH); scene.add(pivotVENUS); @@ -53,6 +60,7 @@ scene.add(pivotMARS); scene.add(pivotJUPITER); scene.add(pivotSATURN); scene.add(pivotURANUS); +scene.add(pivotCamera); pivotEARTH.add(EARTH.earth); pivotVENUS.add(VENUS.venus); @@ -61,9 +69,10 @@ pivotMARS.add(MARS.mars); pivotJUPITER.add(JUPITER.jupiter); pivotSATURN.add(SATURN.saturn); pivotURANUS.add(URANUS.uranus); +pivotURANUS.add(camera); -// Der Mond dreht sich sich um die erde. +// Den Mond hinzufügen EARTH.pivot.add(MOON.moon); scene.add( sun ); @@ -104,10 +113,6 @@ scene.add(pointLight); //scene.add(gridHelper); scene.add(ambientLight); -//Planeten hinzufuegen -//scene.add(EARTH.earth) -//scene.add(MOON.moon) - renderer.render( scene, camera ); @@ -118,8 +123,6 @@ function animate() { requestAnimationFrame( animate ); sun.rotation.x += 0.001; - //sun.rotation.y += 0.005; - //sun.rotation.z += 0.001; EARTH.rotation(); MERKUR.rotation(); VENUS.rotation(); @@ -131,15 +134,18 @@ function animate() { pivotEARTH.rotation.y += 0.005; pivotMERKUR.rotation.y -= 0.005; - pivotVENUS.rotation.x += 0.005; - pivotVENUS.rotation.y += 0.005; pivotVENUS.rotation.z += 0.005; - pivotMARS.rotation.x -= 0.005; pivotMARS.rotation.y -= 0.005; - pivotMARS.rotation.z -= 0.005; pivotJUPITER.rotation.z += 0.005; - pivotSATURN.rotation.z -= 0.005; - pivotURANUS.rotation.x += 0.005; + pivotSATURN.rotation.y -= 0.005; + pivotURANUS.rotation.y += 0.005; + + + cameraX += 0.000001; + cameraZ += 0.000001; + camera.position.setZ(cameraZ); + camera.position.setX(cameraX); + camera.position.setY(cameraY); controls.update(); renderer.render( scene, camera ); diff --git a/saturn/saturn.js b/saturn/saturn.js index 27c6f27..509982a 100644 --- a/saturn/saturn.js +++ b/saturn/saturn.js @@ -19,9 +19,10 @@ const saturnSphere = new THREE.Mesh( saturnPlanet, materialSaturn ); saturn.add(saturnSphere) saturn.position.x = 210; +saturn.rotation.x = 90; export function rotation(){ - saturn.rotation.x -= 0.01; + //saturn.rotation.x -= 0.01; saturn.rotation.y -= 0.01; - saturn.rotation.z -= 0.01; + //saturn.rotation.z -= 0.01; } diff --git a/style.css b/style.css index ac6a59c..1f4b0ff 100644 --- a/style.css +++ b/style.css @@ -1,5 +1,17 @@ canvas { - position:fixed; - top: 0; - left: 0; + position:fixed !important; + top: 0 !important; + left: 0 !important; +} + +main { + width: 100% !important; + height: 100% !important; + position: absolute !important; + z-index: 99 !important; + color: white !important; +} + +a { + color:white !important; }