如何在Three.js中使用stencilFunc函数

3

我可以使用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();
}
1个回答

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接