From c5ec77fe999fdb9bbc1d768ac3d17bc44e31b7b7 Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 31 Mar 2021 02:25:18 +0200 Subject: Added resize event and adjusted overall scalling --- derelict.js | 9 +++++++++ index.html | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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 @@ -Derelict + + +Derelict + -- cgit v1.1