我可以在 Three.js 中使用 stencilFunc 和 stencilOp 函数吗?我试图实现模板测试的代码,但没有奏效。
var scene = new THREE.Scene();
var renderer = new THREE.WebGLRenderer({
antialias: true,
stencil: true
});
function render() {
var context = renderer.context;
context.enable(context.STENCIL_TEST);
context.stencilFunc(context.ALWAYS, 0, 0xffffffff);
context.stencilOp(context.REPLACE, context.REPLACE, context.REPLACE);
context.clearStencil(0);
context.clear(context.COLOR_BUFFER_BIT, context.DEPTH_BUFFER_BIT, context.STENCIL_BUFFER_BIT);
renderer.render(scene, camera);
context.stencilFunc(context.EQUAL, 1, 0xffffffff);
context.stencilOp(context.KEEP, context.KEEP, context.KEEP);
context.disable(context.STENCIL_TEST);
context.flush();
}