Update three.js scene on re-size

I am trying to make it so my renderer will correctly change size whenever the screen changes size.

I tried the following: https://subscription.packtpub.com/book/web-development/9781784392215/1/ch01lvl1sec15/automatically-resize-the-output-when-browser-size-changes

But this code doesn’t work anymore due to version changes.

I tried using:

    window.addEventListener("resize", this._onResize);
  _onResize() {
    this._renderer.setSize(window.innerWidth, window.innerHeight);

but setSize is not a function.

The officials example all have resize event listeners. Just use the approach from the following simple example: three.js webgl - geometry - cube

I assume there is something wrong with your app level code. It looks like this does not point to the right reference in your _onResize() method. Please verify this with a debugger.