summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-03-31 02:25:18 +0200
committerAki <please@ignore.pl>2021-03-31 02:25:18 +0200
commitc5ec77fe999fdb9bbc1d768ac3d17bc44e31b7b7 (patch)
tree7a3cd4d4ff174043c3fb578b450ecf04f387689c
parentcfc3873cdc41179b114e2342bfbe00629a145a50 (diff)
downloadderelict-prototype-c5ec77fe999fdb9bbc1d768ac3d17bc44e31b7b7.zip
derelict-prototype-c5ec77fe999fdb9bbc1d768ac3d17bc44e31b7b7.tar.gz
derelict-prototype-c5ec77fe999fdb9bbc1d768ac3d17bc44e31b7b7.tar.bz2
Added resize event and adjusted overall scalling
-rw-r--r--derelict.js9
-rw-r--r--index.html5
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() {
diff --git a/index.html b/index.html
index 950d104..5c80cb2 100644
--- a/index.html
+++ b/index.html
@@ -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>