1

I did this for the texture, but it doesn't work, the same texture is stretched on a larger area causing staircase artifacts (I have updated cameras, plane, quad, renderer)

I've seen this webgl solution but I don't have a clue how to do this in three.js -I tried re-defining the same texture var with a new texture but it caused webgl to freeze. webl-updating width and height of render target on the fly

var Xtexture = new THREE.WebGLRenderTarget( w, h, { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat } );


window.addEventListener('resize', onResize, false);

function onResize() {

    w = window.innerWidth;
    h = window.innerHeight;

    Xtexture.width = w;
    Xtexture.height = h;
};
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
user5515
  • 301
  • 2
  • 18

1 Answers1

2

The size of a THREE.WebGLRenderTarget can be set and changed by setSize:

var Xtexture = new THREE.WebGLRenderTarget( w, h, { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat } );

function onResize() {

    w = window.innerWidth;
    h = window.innerHeight;

    Xtexture.setSize(w, h); 
};    
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • 2
    Thanks! The problem with three.js is that it is never obvious what method is the proper one, the editor (any editor, I'm using vscode) never prevents you from using the wrong method, and there is no warning whatsoever when the wrong method is used -which I find very frustrating. – user5515 May 26 '18 at 12:12