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();
}
4

1 に答える 1