I can\'t get the following to draw the scene into the shape created as a stencil mask. Instead the code just seems to render the stencil itself as a black object.
ht
Accepted answer don't work on latest threejs. If anyone interested, here's an up-to-date version that works (using r111):
gl.enable(gl.STENCIL_TEST);
gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);
//renderer.clear(); <-- works without this too
gl.stencilFunc(gl.ALWAYS, 1, 0xFF);
gl.stencilMask(0xFF);
renderer.render(maskScene, camera);
gl.stencilFunc(gl.EQUAL, 1, 0xFF);
gl.stencilMask(0x00);
renderer.render(scene, camera);
gl.stencilMask(0xFF);
gl.disable(gl.STENCIL_TEST);
Also in my case I didn't disable auto-clear and it still works.