scrolls faster now

This commit is contained in:
Daniel Jones 2024-05-06 15:35:29 -05:00
parent a7cb1d8fa4
commit c7991d350d
2 changed files with 15 additions and 4 deletions

14
main.js
View File

@ -42,16 +42,17 @@ scene.add(ambientLight, pointLight);
pointLight.position.set(10, 10, 10); pointLight.position.set(10, 10, 10);
const lightHelper = new THREE.PointLightHelper(pointLight);
//turning off orbit controls, not needed. Kept in code in case if I want to use it again.
//turning off orbit controls and lighthelper. Not needed. Kept in code in case if I want to use it again.
//const lightHelper = new THREE.PointLightHelper(pointLight);
//const controls = new OrbitControls(camera, renderer.domElement); //const controls = new OrbitControls(camera, renderer.domElement);
//beggining of creating floor //floor object that appears in the background
const floorTexture = new THREE.TextureLoader().load("marble.jpg"); const floorTexture = new THREE.TextureLoader().load("marble.jpg");
floorTexture.wrapT = THREE.RepeatWrapping; floorTexture.wrapT = THREE.RepeatWrapping;
floorTexture.wrapS = THREE.RepeatWrapping; floorTexture.wrapS = THREE.RepeatWrapping;
@ -65,11 +66,16 @@ floor.rotateX(Math.PI * -0.5);
scene.add(floor); scene.add(floor);
//when the user scrolls, walk down the hallway.
function updateCamera(ev){ function updateCamera(ev){
let div1 = document.getElementById("div1"); let div1 = document.getElementById("div1");
camera.position.z = 10 - window.scrollY / 500.0; camera.position.z = 10 - window.scrollY;
} }
window.addEventListener("scroll", updateCamera); window.addEventListener("scroll", updateCamera);
//animation loop every cycle.
function animate(){ function animate(){
requestAnimationFrame(animate); requestAnimationFrame(animate);
renderer.render(scene, camera); renderer.render(scene, camera);

View File

@ -28,3 +28,8 @@ body {
width: calc(100% - 2*48px); width: calc(100% - 2*48px);
word-wrap: break-word; word-wrap: break-word;
} }
.div1 {
background-color: black;
}