setStencil method
The stencil test for the draws that follow.
front applies to front-facing triangles and, when back is null, to
back-facing ones as well — which is what every caller in this engine
wants, and why the second is optional rather than required. A pass
starts with StencilState.disabled on both faces, whatever the previous
pass left, and a caller that turned the test on says
setStencil(StencilState.disabled) when it is done: on a backend whose
setters are global context state, the next draw inherits this one's.
Meaningful only against a depth attachment whose format
TextureFormatStencil.hasStencil says carries one. Ask
GraphicsDevice.supportsStencil before configuring it at all.
Implementation
@override
void setStencil(StencilState front, {StencilState? back}) {
_stencilFront = front;
// Null means "the same on both faces", which is what every caller in this
// engine wants. WebGPU states the two separately and has no way to say
// "as the front", so the contract's default is written out here.
_stencilBack = back ?? front;
}