From 0380ec5844fd6b19fc9b5e2fbe03a4519b092904 Mon Sep 17 00:00:00 2001 From: romy Date: Tue, 13 Aug 2024 21:40:36 -0700 Subject: [PATCH] works for two --- index.html | 126 ++++++++++++++++++++++------------------------------- js/main.js | 28 ++++++++++++ 2 files changed, 81 insertions(+), 73 deletions(-) diff --git a/index.html b/index.html index f2e2efd..1d43f1f 100644 --- a/index.html +++ b/index.html @@ -1,79 +1,59 @@ + - - - - - + + + + + - - + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + + \ No newline at end of file diff --git a/js/main.js b/js/main.js index 818b43a..c050927 100644 --- a/js/main.js +++ b/js/main.js @@ -1,6 +1,34 @@ // You can add any additional JavaScript here // For example, you might want to add event listeners or other functionality document.addEventListener('DOMContentLoaded', function() { + const skybox = document.querySelector('#skybox'); + const portal1 = document.querySelector('#portal1'); + const portal2 = document.querySelector('#portal2'); + const portal3 = document.querySelector('#portal3'); + + const skyboxTextures = ['#skyTexture1', '#skyTexture2', '#skyTexture3']; + let currentTextureIndex = 0; + + function changeScene(nextTextureIndex) { + currentTextureIndex = nextTextureIndex; + skybox.setAttribute('src', skyboxTextures[currentTextureIndex]); + + // Update portal visibility + portal1.setAttribute('visible', currentTextureIndex === 0); + portal2.setAttribute('visible', currentTextureIndex === 1); + portal3.setAttribute('visible', currentTextureIndex === 2); + } + + function setupPortalListener(portal, nextTextureIndex) { + portal.addEventListener('click', () => changeScene(nextTextureIndex)); + } + + // Set up portal listeners + setupPortalListener(portal1, 1); // First portal takes us to skyTexture2 + setupPortalListener(portal2, 2); // Second portal takes us to skyTexture3 + setupPortalListener(portal3, 1); // Third portal takes us back to skyTexture2 + + // Log to console when scene is loaded console.log('VR Scene loaded'); });