To stack multiple layers of objects, you’ll need to pre-determine what the rules are. Do placed objects have to align themselves in any particular way? What is a valid position for placement, and what isn’t?
The canvas objects and the filter used by @EgoMoose provide convenient rules for placement constraints. If you use them, placement is restricted to those constraints.
To stack, you’ll need to detect that the activated placement position (where the mouse or touch tap hits) is the top surface (or valid upward facing surface) of another model (or part) that is allowed to be underneath the new placement.
So, at the time placement is requested by the user, run some additional checks to figure it out. After adding in the Y axis component as described above.
Something that’s gone unmentioned is that the code uses X and Y internally to represent a plane of placement, but acts upon the X and Z world axis externally. That may be a source of confusion for you. It also means that adding stacking placement requires a bit of refactoring.
Or for a hack, you could try adding a canvas object on top of each model that is placed …