mirror of
https://github.com/TomHodson/tomhodson.github.com.git
synced 2025-06-26 10:01:18 +02:00
Add window resize handler
This commit is contained in:
parent
343047464d
commit
4eb4b7ab7b
@ -165,6 +165,15 @@ class SphereViewer extends HTMLElement {
|
|||||||
}
|
}
|
||||||
loop();
|
loop();
|
||||||
|
|
||||||
|
window.addEventListener("resize", onWindowResize());
|
||||||
|
function onWindowResize() {
|
||||||
|
let canvas_rect = canvas.getBoundingClientRect();
|
||||||
|
console.log(canvas_rect);
|
||||||
|
camera.aspect = canvas_rect.width / canvas_rect.height;
|
||||||
|
camera.updateProjectionMatrix();
|
||||||
|
renderer.setSize(canvas_rect.width, canvas_rect.height, false);
|
||||||
|
}
|
||||||
|
|
||||||
const gui = new GUI({
|
const gui = new GUI({
|
||||||
title: "Settings",
|
title: "Settings",
|
||||||
container: container,
|
container: container,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user