Stencil does not work on STL model

There aren’t any file format requirements for using stencils – once a file has been loaded it’s all the same to three.js so there’s something else about the code here.

The first thing that sticks out to me is that getMesh() does not return anything and is asynchronous so this line is just setting mesh to undefined:

var mesh = getMesh();

That aside the first step is to make sure the material clipping planes are working at all and that your model is getting clipped in the ways expected, which does not look to be the case in your screenshot. After that the stencil effect is very sensitive to draw order so it’s important to make sure that all steps are drawn in the correct order. See this post where I lay out the specific order:

2 Likes