Skip to content
Snippets Groups Projects
Commit 79970095 authored by Greg Fodor's avatar Greg Fodor
Browse files

Support window resizing

parent d393d092
No related branches found
No related tags found
No related merge requests found
import { paths } from "./userinput/paths";
AFRAME.registerSystem("camera-mirror", {
init() {
this._onWindowResize = this._onWindowResize.bind(this);
window.addEventListener("resize", this._onWindowResize, false);
},
tick() {
const userinput = this.el.systems.userinput;
......@@ -37,6 +42,13 @@ AFRAME.registerSystem("camera-mirror", {
this.mirrorCamera = null;
},
_onWindowResize() {
if (!this.mirrorCamera) return;
this.mirrorCamera.aspect = window.innerWidth / window.innerHeight;
this.mirrorCamera.updateProjectionMatrix();
this.el.sceneEl.renderer.setSize(window.innerWidth, window.innerHeight);
},
_patchRenderFunc() {
const headEl = document.getElementById("player-head");
const hudEl = document.getElementById("player-hud");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment