I’m using a stencil mask in Three.js to create a portal effect. It works correctly on meshes when I can control the material. However, when I load a gltf model with the model’s material I cannot get it to hide outside the stencil mask.
See this example screenshot here with the desired effect with a cube mesh
Screenshot of GLTF model unable to hide outside the stencil mask
material.stencilWrite = true;
material.stencilFunc = THREE.EqualStencilFunc;
material.stencilRef = 1;
material.stencilFuncMask = 0xFF;
material.stencilFail = THREE.KeepStencilOp;
material.stencilZFail = THREE.KeepStencilOp;
material.stencilZPass = THREE.ReplaceStencilOp;
type or paste code here
Here is a codepen with both the mesh and the gltf model: https://codepen.io/jattfield/pen/GRMzRjw
Thanks for any guidance.