For the last two months, there was no time to develop the editor, as I was invited as a developer by the Perm Wooden Toy company https://dolodom.com/, which is engaged in the manufacture of various products from plywood. To build and render layouts, they develop their own editor based on the standard three.js editor. The assembly of the layout went something like this video https://www.youtube.com/watch?v=yTAZi-5-EfA. There is a snap on the mesh vertices, which is convenient.
I suggested improving the build process and making it easier for the user. In the beginning, I wanted to do a simple alignment of the cleat plane with the groove plane (and implemented this). But we decided that this was also not so convenient and decided to try to make an instrument that was as close to reality as possible. But in reality, our thorn is inserted into the groove. That is, we need to determine what is a groove and what is a thorn. Taking into account the fact that the geometry is formed in Blender on the server side from curves imported from vector editors, as the initial data we have a mesh with two types of material – front side and butt. That is, there is no information about what is a thorn or a groove, only a set of points and triangles. To implement the tool, I wrote a mesh analysis algorithm.
First, it was necessary to simplify the models for calculations. To do this, all the facets of the end face (the front part is discarded, since it does not take part in the calculations) are divided into two parts – internal and external. All faces that have co-directional normals are combined into one. All internal faces are combined into separate groups, forming a closed contour (hole). Since the hole can be of any shape, framing parallelepipeds are built on the basis of the groups obtained. The orientation of the box is determined based on the direction of the major axes of symmetry. The main axes of symmetry are found according to the formulas of Strength of materials to the vertices of the contour, taking them as separate material points, that is, with a uniform distribution of points, it works correctly, which is sufficient for the case with grooves – they are symmetrical.
The groove is defined by finding the planes perpendicular to the selected face, if they face the normal of the selected face.
When you select a tenon or groove on a second part while holding down the shift key, the second part is cloned.
When installing a part, there are cases when two or more parts can be inserted into one groove, that is, the groove is larger than the spike. The case is also possible when several parts are put on the thorn. Rotation of a part, such as a cover, is possible. To handle all such cases, a detail fitting mode has been worked out. For this I have developed a custom gizmo, the elements of which are displayed depending on the directions in which movement is possible. Movements occur no more than possible, that is, the restrictions are worked out.
How the assembly is now going on can be seen in the video.