scrolls faster now
This commit is contained in:
parent
a7cb1d8fa4
commit
c7991d350d
14
main.js
14
main.js
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user