0

Is it possible to dynamically switch antialiasing on/off with three.js? I tried the following which doesn't work at all:

`
var rendererAA = new THREE.WebGLRenderer({{ antialias: true }});
rendererAA.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( rendererAA.domElement );

var rendererNA = new THREE.WebGLRenderer({{ antialias: false }});
rendererNA.setSize( window.innerWidth, window.innerHeight );
rendererNA.domElement = rendererAA.domElement;

var renderer = rendererAA;

function render() {

if (somePredicate) {
    renderer = rendererAA;
}else {
    renderer = rendererNA;
}

requestAnimationFrame( render );
renderer.render( scene, camera );
}`

If the active renderer is rendererNA (somePredicate = false), the scene just freezes and no change in antialiasing.

I also tried to set the inactive renderers domElement to null, which didn't help. I was inspired by this question:

Dynamically turn on/off antialiasing and shadows in WebGLRenderer

But there was no definite answer.

Community
  • 1
  • 1
Amadeo
  • 41
  • 1
  • 3
  • possible duplicate of [Dynamically turn on/off antialiasing and shadows in WebGLRenderer](http://stackoverflow.com/questions/27554969/dynamically-turn-on-off-antialiasing-and-shadows-in-webglrenderer) – Mouloud85 Sep 29 '15 at 16:43

1 Answers1

1

This is not possible currently with Three.js.

You need to recreate the entire context to allow for AA to be on and off and cannot just switch between this. I suggest you have boolean vars that determine if AA is on and off prior to execution client side. E.h. HD/SD, if HD boolean AA = true, use WebGLRenderer to allow for AA and reverse. But you cannot dynamically change this at runtime.

Komsomol
  • 698
  • 10
  • 27