diff options
author | Aki <please@ignore.pl> | 2021-03-31 02:25:18 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-03-31 02:25:18 +0200 |
commit | c5ec77fe999fdb9bbc1d768ac3d17bc44e31b7b7 (patch) | |
tree | 7a3cd4d4ff174043c3fb578b450ecf04f387689c | |
parent | cfc3873cdc41179b114e2342bfbe00629a145a50 (diff) | |
download | derelict-prototype-c5ec77fe999fdb9bbc1d768ac3d17bc44e31b7b7.zip derelict-prototype-c5ec77fe999fdb9bbc1d768ac3d17bc44e31b7b7.tar.gz derelict-prototype-c5ec77fe999fdb9bbc1d768ac3d17bc44e31b7b7.tar.bz2 |
Added resize event and adjusted overall scalling
-rw-r--r-- | derelict.js | 9 | ||||
-rw-r--r-- | index.html | 5 |
2 files changed, 13 insertions, 1 deletions
diff --git a/derelict.js b/derelict.js index 609fd01..d32d269 100644 --- a/derelict.js +++ b/derelict.js @@ -43,6 +43,15 @@ function init() { const controls = new OrbitControls(camera, renderer2d.domElement) controls.minDistance = 0.5 controls.maxDistance = 8 + + window.addEventListener('resize', onWindowResize) +} + +function onWindowResize() { + camera.aspect = window.innerWidth / window.innerHeight + camera.updateProjectionMatrix() + renderer.setSize(window.innerWidth, window.innerHeight) + renderer2d.setSize(window.innerWidth, window.innerHeight) } function animate() { @@ -1,5 +1,8 @@ <!doctype html> <html lang="en"> -<title>Derelict</title> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> <link rel="stylesheet" type="text/css" href="style.css"> +<title>Derelict</title> +<body> <script type="module" src="derelict.js"></script> |