Capping two clipped geometries using two planes which are negated to each other

I have two meshes which I clipped using two different planes. The planes normals happen to negate each other, So when I try and cap both the clipped meshes, I see atleast one model as hollow and the clipping is not proper.
The stencilbuffer code has been used from “three.js examples” it works perfectly fine If I try and cap only one model but I want it to work for both the geometries. Any suggestions
1

Currently its looking like this

The stencil and clipping operations are very order dependent so if you want to clip two objects separately you have to specify that one clipped object be fully drawn first and then the second. And because three.js’ render order fields only really work globally you’ll have to manually set the draw order for every object to correctly set the draw order:

Object 1

  • Render order 1: Draw front face / back face clipped and front face / back face not clipped (4 meshes)
  • Render order 2: Draw planar clip cap

Object 2

  • Render order 3: Draw front face / back face clipped and front face / back face not clipped (4 meshes)
  • Render order 4: Draw planar clip cap