Без рубрики – Dragon3DGraff_Blog

Category: Без рубрики

Mesh editing: Faces

0 Implemented editing the mesh of the object by moving the face. But this solution is very resource-intensive. It can be seen when there are a lot of triangles in the object. The reason for this is that I create an auxiliary triangle for each triangle of the object, and when the triangle moves, I delete them all and create them again. As a solution, I decided to make an auxiliary triangle only for the triangle that I am going to move. Now for this I realized the creation of such a triangle with the movement of the mouse. This will highlight the triangle that you can select 0

Continue reading

Mesh editing: Vertices

0 Today has made, perhaps, the most significant functional for me. I was very interested in making the ability to edit the mesh of the object. So far, only moving vertices one at a time has been implemented. It took me 2 days to implement, and even more to ponder and theoretical preparation. Editing is implemented for BufferGeometry. First, I place small spheres to the vertices positions: Since the coordinates of the vertices are stored in a buffer, which is an array of values in increments of 3: [x1, y1, z1, x2, y2, z2 … xn, yn, zn], we need to get the coordinates of the points in the form of vectors But the points are repeated. For example, for a cube (8 vertices) – 24 points, 3 points per vertex (one point for one face) We get an array of vertex coordinates: At each vertex we put a sphere I did the editing of the geometry using the static method. I pass in it an object, the number of the vertex, which will change and its position Now we need to do the reverse procedure. We find in what positions of the points array the coordinates of the vertices

Continue reading

Select multiple objects, clone

0 Implemented the selection of several objects. In this case, the center of selection is set in the geometric center of mass, the so-called barycenter, which is defined as follows The barycenter is determined by the addition of the position vectors of the points included in the group and is divided by the number of points. To implement multiple selection, a group was created in the currentselection object and the moment of scene initialization was added to the scene To initialize multiple selection, hold down the Ctrl key. First, check if any object is selected. If selected, then add it to the multiselection group. We create an array of objects included in the multiselection group and check if there is a selected object in this group. If not, then add it to the group, if so, then remove it from the selection: We return all the objects from the group to the scene in order to establish the new position of the group by moving it to the geometric center of mass. To do this, determine the position of all objects selection We return all objects from the scene to the group We use the .attach method, which, unlike .add,

Continue reading

Saving, Loading and Manipulating.

0 Improved the function of saving the scene. The scene file created in the TertiusAxis editor has the extension “.trxs”. Now it is a text file with data in the form of an array with elements in the JSON format, which are scene objects. Only objects created by the user are saved. To do this, the elements of the children array of the scene are checked in which userData = true. By the same principle, the scene was cleared in the TA_Scene module: Saving a file is a separate function Added function “Merge with scene from disk”, which adds objects from another scene to an existing scene. When loading a scene, only the “.trsx” file extension is checked, but in the future, when the file format changes, the file structure will be checked. The whole scene can be exported to GLtf format Implemented the functionality of the object manipulation buttons: move, rotate, scale and drag, by connecting the appropriate modules of the three.js library.Cloning of an object is implemented by pressing the “c” key, as well as by selecting the corresponding menu item on the Edit tab. At the same time, the geometry of the clones is independent, and the

Continue reading

Save/Load Scene

0 I made a draft of the function of saving the scene to disk and opening the scene from the file. Now only objects created by the user are loaded. To do this, I added the UserData to the object:this.currentEntity.userData = {createdByUser: true, selectable: true}; TODO: There are errors in the console and many questions need to be worked out, such as clearing the scene before loading, loading cameras and setting the camera position, light sources, deselecting before saving … 0

Continue reading

Refactoring

0 Added digital display of color component values. Their changes are interconnected. Spent a lot of code refactoring. Made the code modules. Moved most of the code from TertiusAxis.js to TA_UI.js. Now it only has a start () function I split the TA_UI.js file into several modules and moved them to the UI folder. The formation of each section of the menu is now in a separate function in a separate file. Now the menu forming and filling functions look like this: A bug was detected in FireFox with the display input, it ran away when scrolling (fixed). I found that in Edge input it does not scroll and there are no arrows to change the value. I need to study cross-browser compatibility. Todo. Refactoring TA_Entities.js, creating functionality for all buttons for creating primitives. 0

Continue reading

Work with the interface

0 Added buttons for creating primitives from the threejs library, the creation of which I plan to implement. To do this, I created an array of objects with a description of my buttons, containing the text for the button, the type of geometry being created for transmission to TA_Enteties and a link to the icon: Through forEach I add them all to the buttonsDiv: Added a display of material parameters in the options menu. I made the Main menu hidden when I click on the arrow: Implemented the creation of a circle. At the same time, I ran into a problem. Threejs issued a warning in the console with each render: three.js: 2533 THREE.Matrix3: .getInverse () can’t invert matrix, determinant is 0. It turned out that it is impossible for the object to have a zero value (for example, height) or scale. In my case, the warning worked on creating a BoundingBox, since the circle is a flat object and the height is 0. I had to add a check: 0

Continue reading