This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onWindowResize() { | |
windowHalfX = window.innerWidth / 2; | |
windowHalfY = window.innerHeight / 2; | |
camera.aspect = window.innerWidth / window.innerHeight; | |
camera.updateProjectionMatrix(); | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
} | |
window.addEventListener( 'resize', onWindowResize, false ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mouseMoveEls = Array.from(document.getElementsByClassName('transform__mm')); | |
document.addEventListener( 'mousemove', (e) => { | |
const width = window.outerWidth; | |
const height = window.outerHeight; | |
const offsetX = 0.5 - e.pageX / width; | |
const offsetY = 0.5 - e.pageY / height; | |
mouseMoveEls.forEach((el, i) => { | |
const dataOffset = parseInt(el.getAttribute('data-offset')); | |
const translate = `translate3d(${Math.round(offsetX * dataOffset)}px, ${Math.round(offsetY * dataOffset)}px, 0px)`; |
NewerOlder