Skip to content

Commit

Permalink
Resized viewport on window resize. Used light gray bg.
Browse files Browse the repository at this point in the history
  • Loading branch information
weaponsforge committed Mar 22, 2020
1 parent 0d5d166 commit 18972fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
overflow:hidden;
font-family:georgia;
text-align:center;
overscroll-behavior: none;
}
canvas { display: block; pointer-events:none; }
</style>
Expand Down
12 changes: 12 additions & 0 deletions public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ const init = function() {
renderer = new THREE.WebGLRenderer()
renderer.setPixelRatio(window.devicePixelRatio)
renderer.setSize(window.innerWidth, window.innerHeight)
renderer.setClearColor (0xE0E0E0, 1);
document.body.appendChild(renderer.domElement)

// Events
document.addEventListener('mousemove', onDocumentMouseMove, false)
window.addEventListener( 'resize', onWindowResize, false )
}

// Render the current frame
Expand All @@ -51,6 +53,16 @@ const onDocumentMouseMove = function(event) {
mouseY = (event.clientY - windowHalfY) / 2
}

const onWindowResize = function() {
windowHalfX = window.innerWidth / 2
windowHalfY = window.innerHeight / 2

camera.aspect = window.innerWidth / window.innerHeight
camera.updateProjectionMatrix()

renderer.setSize(window.innerWidth, window.innerHeight)
}

const app = async function() {
init()

Expand Down

0 comments on commit 18972fd

Please sign in to comment.