WebGPU-based three-dimensional model loading method and system

Through the webGPU -based 3D model loading method, we build a webgpu loader and analyzes the three -dimensional model files, solving the problem that traditional technologies cannot load three -dimensional graphics in the browser, and realize high -performance and flexible three -dimensional model loading.

CN119359884AActive Publication Date: 2025-01-24SHANDONG ZHIHECHUANG INFORMATION TECH CO LTD

Patent Information

Application Number
CN202411936126.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-01-24
Estimated Expiration
2044-12-26

AI Technical Summary

Technical Problem

The traditional three-dimensional model loading method cannot directly load three-dimensional graphics in the browser, and cannot meet the needs of modern applications for high performance and flexibility.

Method used

The three -dimensional model loading method based on the WebGPU is used to build a webGPU loader, read the three -dimensional model file, analyze and extract vertex data and index data, and convert it into a target data format, create buffer and bind it to the GPU rendering pipeline.

Benefits of technology

Realize the three -dimensional model files in the web environment, improve data compatibility and rendering performance, and meet the needs of modern applications for high performance and flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119359884A_ABST
    Figure CN119359884A_ABST
Patent Text Reader

Abstract

The invention provides a WebGPU-based three-dimensional model loading method and system, and relates to the technical field of three-dimensional model processing, and the method comprises the steps: obtaining a to-be-loaded three-dimensional model file, obtaining a path of the file, reading a target file through the path by using a loader constructed by a WebGPU technology, and analyzing the read target file by using the loader, extracting vertex data and index data from an analysis result, converting formats of the vertex data and the index data into a target data format, creating a first buffer area, storing the vertex data and the index data subjected to format conversion in the first buffer area, binding the first buffer area to a rendering pipeline of the GPU, and storing the rendering pipeline of the GPU in the second buffer area. According to the method and the device, the three-dimensional model file can be directly loaded into the Web environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of three-dimensional model processing, and in particular to a three-dimensional model loading method and system based on WebGPU. Background Art

[0002] 3D model loading is an important part in the field of computer graphics and virtual reality. With the rapid development of modern technology, 3D models are increasingly used in various fields, including game development, architectural design, urban planning, geographic information systems (GIS), etc.

[0003] Traditional 3D model loading methods often rely on old graphics APIs, such as OpenGL or DirectX. Although these APIs are powerful, they can no longer meet the needs of modern applications for high performance and flexibility. In particular, with the continuous advancement of Web technology, more and more applications need to run 3D graphics in browsers, but traditional 3D model loading methods cannot directly load 3D models into the Web environment. Summary of the invention

[0004] In order to load a three-dimensional model in a Web environment, the present application provides a three-dimensional model loading method and system based on WebGPU.

[0005] In the first aspect, the present application provides a 3D model loading method based on WebGPU, which adopts the following technical solution: The 3D model loading method based on WebGPU includes the following steps: Model acquisition: Get the 3D model file to be loaded and record it as the target file; Model loading: including path acquisition, first build, file parsing, format conversion and second build; Get path: Get the path of the target file; First build: use WebGPU technology to build a loader, and the loader reads the target file through the path; File parsing: Use the loader to parse the read target file, obtain the parsing result, and extract the vertex data and index data from the parsing result; Format conversion: converting the format of the vertex data and the format of the index data into a target data format, recording the vertex data after the conversion as first data, and recording the index data after the conversion as second data; Second construction: creating a first buffer storing the first data and the second data, and binding the first buffer to the rendering pipeline of the GPU.

[0006] By adopting the above technical solution, this application uses WebGPU technology to build a loader. The loader reads the target file through a specified path, and parses the target file after reading the target file. The vertex data and index data are extracted from the parsing result, and then the vertex data and index data are converted into the target data format (obtaining the first data and the second data). Then, a first buffer storing the first data and the second data is created and bound to the GPU rendering pipeline. In this process, this application uses WebGPU technology. WebGPU can be developed and debugged on mainstream browsers such as Chromium, Chrome, and Firefox. These browsers provide APIs based on the WebGPU standard and corresponding debugging tools and performance analyzers, which realize the function of loading three-dimensional model files in a Web environment. In addition, format conversion improves the compatibility of data, so that the relevant data can be correctly processed by the GPU, and the first buffer is created and bound to the GPU rendering pipeline, which can realize the function of correctly rendering the three-dimensional model.

[0007] Optionally, after executing the file parsing step and before executing the format conversion step, the method further includes: The third construction: take any vertex data in the target file as the origin to construct the spatial coordinate system; First judgment: judging whether the current hexagram contains multiple vertex data, if so, taking the three-dimensional model file of the current hexagram as a new target file and executing the third construction step; if not, executing the first calculation step; First calculation: use Jaccard similarity to calculate the similarity of vertex data in adjacent hexagrams; Second judgment: judging whether the similarity is greater than a preset threshold, if so, executing the merging step; if not, executing the first retaining step; Merge: merge the two hexagrams corresponding to the similarity into a new hexagram, delete any vertex data corresponding to the similarity, and execute the first calculation step; First reservation: retaining the vertex data in the two hexagrams corresponding to the similarity; Data update: Use the remaining vertex data in the merging step, the vertex data retained in the first retained step, the vertex data on the coordinate axis corresponding to the new hexagram in the merging step, and the vertex data on the coordinate axis corresponding to the two hexagrams in the first retained step as new vertex data, and establish new index data based on the new vertex data.

[0008] By adopting the above technical scheme, the present application uses any vertex data as the origin and constructs a spatial coordinate system in any direction, and can determine the spatial position relationship between the vertex data and the remaining vertex data. If the current hexagram (a spatial division area) contains multiple vertex data, the three-dimensional model file of the current hexagram is used as a new target file, and the spatial coordinate system is rebuilt until a hexagram includes only one vertex data or no vertex data. Then, the similarity of the vertex data in adjacent hexagrams is calculated, and two hexagrams with similarity greater than a preset threshold are merged to obtain a new hexagram. Any vertex data is deleted in the new hexagram, and the first calculation step is re-executed. If the similarity of adjacent hexagrams is lower than the preset threshold, the two hexagrams and the internal vertex data are retained. Finally, the remaining vertex data in the merging step, the vertex data retained in the first retained step, the vertex data on the coordinate axis corresponding to the new hexagram in the merging step, and the vertex data on the coordinate axis corresponding to the two hexagrams in the first retained step are used as new vertex data, and new index data are established for these new vertex data, thereby reducing redundant data and optimizing the data structure.

[0009] Optionally, after executing the third construction step and before executing the first judgment step, the method further includes: Determine the direction: Take the direction from the origin to the camera as the positive direction of the x-axis, perform cross multiplication of the normal vector of the vertex data and the unit vector of the x-axis to determine the positive direction of the y-axis, use the right-hand rule to determine the positive direction of the z-axis, and construct a spatial coordinate system based on the x-axis, y-axis, and z-axis; Determine the coordinates: determine the horizontal coordinate of the far plane of the viewing frustum, recorded as the first coordinate; Delete file: Get the coordinate point whose horizontal coordinate is less than the first coordinate, record it as the second coordinate, and delete the target file corresponding to the second coordinate.

[0010] By adopting the above technical solution, the present application defines the direction of each coordinate axis, deletes the three-dimensional model file after the far plane of the viewing frustum, reduces the amount of vertex data, improves loading efficiency, and reduces resource consumption.

[0011] Optionally, after executing the first retention step and before executing the data update step, the method further includes: Second calculation: count the number of vertex data with the same ordinate and vertical coordinate, and record it as the third data; Third judgment: judging whether the third data is one, if so, executing the step of data updating; if not, executing the second reserved step; Second retention: retain the vertex data with the largest horizontal coordinate among the vertex data with the same vertical coordinate and vertical coordinate, and execute the data update step.

[0012] By adopting the above technical solution, the present application simplifies the vertex data with the same vertical and horizontal coordinates. When the vertical and horizontal coordinates of multiple vertex data are the same, these vertex data must have an occlusion or being occluded relationship. The present application retains the vertex data with the largest horizontal coordinate among the vertex data with the same vertical and horizontal coordinates, that is, deletes the occluded vertex data, further reduces the amount of vertex data that needs to be loaded, and improves the loading speed.

[0013] Optionally, after executing the first building step and before executing the file parsing step, the method further includes: Fourth judgment: judging whether the loader successfully reads the target file, if so, executing the file parsing step; if not, executing the clearing process step; Clear process: Clear the loading process in the loader and issue an alarm signal.

[0014] When the path of the target file is correct, the present application first checks whether the loader has successfully read the target file, so that the loader will be used to parse the target file only when the target file is successfully read, thereby reducing the probability of errors in subsequent steps. When the target file is not successfully read, the present application will clear the loading process in the loader and issue an alarm signal to prompt the operation and maintenance personnel that there is a problem with the current loading queue. By adopting the above-mentioned technical solution, the present application will only perform file parsing when the loader successfully reads the file, thereby improving the stability and accuracy of the loading process.

[0015] Optionally, in the first construction step, the loader includes a plurality of loading queues, a HOOK function is provided at the end of each code line of each loading queue, and after executing the fourth judgment step and before executing the clearing process step, the following steps are further included: Collect logs: collect the running logs of the loader, and obtain error information based on the running logs; Collection location: locate the error code based on the error information; Jump: Use the HOOK function at the end of the previous line of code of the error code to jump to the new loading queue and continue loading the target file.

[0016] This application obtains detailed error information by collecting operation logs, and further locates the code that causes the error based on the collected error information. When building the loader, this application sets a HOOK function at the end of each load queue code line. The HOOK function of each line of code points to the end of the same code line of another load queue, and the HOOK function at the end of the code line is only triggered when an error occurs in the code, so that when the code of the current load queue runs incorrectly, the HOOK function is used to jump to the new load queue, thereby bypassing the current error code. This application uses a new load queue to reload the target file, so that when a problem occurs in a certain load queue of the loader, it will not affect the loading of the entire target file. By collecting logs, locating error locations and setting jumps, this application can more accurately diagnose and solve problems encountered by the loader when reading target files.

[0017] Optionally, after executing the merging step and before executing the data updating step, the method further includes: First acquisition: integrate the vertex data deleted in the merging step into a data set; The third calculation: use Jaccard similarity to calculate the similarity of any two vertex data in the data set, recorded as the fourth data; Fifth judgment: judging whether the fourth data is greater than a preset threshold, if so, executing a step of eliminating; if not, executing a step of format conversion; Eliminate: Eliminate any vertex data corresponding to the fourth data in the data set, and execute the third calculation step until the calculation stop condition is met; Third reservation: retain the vertex data corresponding to the fourth data.

[0018] This application collects deleted vertex data and integrates it into a data set. It also calculates the similarity of any two vertex data in the data set and determines the similarity. If the similarity is greater than a preset threshold, it means that there is redundancy in the vertex data in the data set. Then, one of the vertex data is deleted from the data set and the third calculation step is re-executed. Otherwise, it means that the two vertex data have different characteristics or information and need to be retained. By adopting the above technical solution, this application further filters the deleted vertex data and selects vertex data with different characteristics or information.

[0019] Optionally, after executing the step of updating the data and before executing the step of converting the format, the method further includes: First setting: the vertex corresponding to the vertex data in the data update step is used as the main control point; Second setting: taking the vertex corresponding to the vertex data retained in the third retaining step as a secondary control point, and establishing index data of the secondary control point; The format conversion step further includes: converting the format of the vertex data corresponding to the secondary control point into the target data format, recorded as fourth data; converting the format of the index data corresponding to the secondary control point into the target data format, recorded as fifth data; The second construction step also includes: creating a second buffer storing the fourth data and the fifth data, and binding the second buffer to the rendering pipeline of the GPU.

[0020] By adopting the above-mentioned technical solution, the present application sets main control points and secondary control points, and in the format conversion step, converts the formats of vertex data and index data corresponding to the secondary control points into the target data format, creates a second buffer storing the converted vertex data and index data, and binds it to the rendering pipeline of the GPU, so that the secondary control points can also be loaded, thereby improving the loading accuracy of the three-dimensional model.

[0021] Optionally, after performing the second construction step, the method further includes: First rendering: the rendering pipeline renders the data in the first buffer to the user interface to obtain a first rendering effect; Second rendering: the rendering pipeline renders the data in the second buffer to the user interface to obtain a second rendering effect; Rendering Merge: Use the GPU to merge the first rendering effect with the second rendering effect.

[0022] The present application first renders the data corresponding to the primary control point (stored in the first buffer) to provide the user with basic or preliminary visual feedback, and then renders the secondary control point (stored in the second buffer) to provide higher quality or more refined visual effects. This layered rendering strategy helps to gradually build and present complex scenes. Through two renderings, the user interface can present richer and more delicate visual effects, thereby enhancing the user's visual experience.

[0023] In the second aspect, the present application provides a 3D model loading system based on WebGPU, which adopts the following technical solutions: WebGPU-based 3D model loading system, including: The model acquisition module is used to obtain the 3D model file to be loaded, which is recorded as the target file; A model loading module, comprising a path acquisition unit, a first construction unit, a file parsing unit, a format conversion unit, and a second construction unit; A path acquisition unit is connected to the model acquisition module for acquiring the path of the target file; A first construction unit is communicatively connected with the path acquisition unit and is used to construct a loader using WebGPU technology, and the loader reads the target file through the path; A file parsing unit, which is in communication connection with the first building unit, and is used to parse the read target file using a loader, obtain a parsing result, and extract vertex data and index data from the parsing result; A format conversion unit, connected to the file parsing unit for communication, for converting the format of the vertex data and the format of the index data into a target data format, recording the vertex data after the format conversion as first data, and recording the index data after the format conversion as second data; The second construction unit is communicatively connected to the format conversion unit, and is used to create a first buffer storing the first data and the second data, and bind the first buffer to the rendering pipeline of the GPU.

[0024] By adopting the above-mentioned technical solution, the present application obtains the three-dimensional model file to be loaded through the model acquisition module, and uses the acquisition path, first construction, file parsing, format conversion and second construction units in the model loading module to convert the vertex data and index data of the target file into a format recognizable by the GPU, and stores it in the first buffer bound to the rendering pipeline. The present application adopts WebGPU technology to build a loader, which can directly load the three-dimensional model into the Web environment.

[0025] In summary, the present application includes at least one of the following beneficial technical effects: 1. This application uses WebGPU technology to build a loader, which reads the target file through a specified path, parses the target file after reading the target file, extracts vertex data and index data from the parsing results, and then converts the vertex data and index data into a target data format (obtaining first data and second data), and then creates a first buffer storing the first data and the second data and binds it to the GPU rendering pipeline. In this process, this application uses WebGPU technology, which can be developed and debugged on mainstream browsers such as Chromium, Chrome, and Firefox. These browsers provide APIs based on the WebGPU standard and corresponding debugging tools and performance analyzers, realizing the function of loading three-dimensional model files in a Web environment.

[0026] 2. The present application simplifies the vertex data with the same vertical and horizontal coordinates. When the vertical and horizontal coordinates of multiple vertex data are the same, these vertex data must have an occlusion relationship. The present application retains the vertex data with the largest horizontal coordinate among the vertex data with the same vertical and horizontal coordinates, that is, the occluded vertex data is deleted, thereby reducing the amount of vertex data that needs to be loaded and improving the loading speed.

[0027] 3. This application obtains detailed error information by collecting operation logs, and further locates the code that causes the error based on the collected error information. When building the loader, this application sets a HOOK function at the end of each loading queue code line. The HOOK function of each line of code points to the end of the same code line of another loading queue, and the HOOK function at the end of the code line is only triggered when an error occurs in the code, so that when the code of the current loading queue runs incorrectly, the HOOK function is used to jump to the new loading queue, thereby bypassing the current error code. This application uses a new loading queue to reload the target file, so that when a problem occurs in a certain loading queue of the loader, it will not affect the loading of the entire target file. By collecting logs, locating error locations and setting jumps, this application can more accurately diagnose and solve problems encountered by the loader when reading target files. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 is a flow chart of Example 1 of the present application; Figure 2 It is a flowchart of data update from S31 third construction to S37 in Example 2 of the present application; Figure 3 This is a flowchart from S41 determining direction to S37 updating data in Example 2 of the present application; Figure 4 is a flow chart of Example 3 of the present application; Figure 5 This is a flow chart of Example 4 of the present application. DETAILED DESCRIPTION

[0029] The following combination Figures 1 to 5 This application is described in further detail.

[0030] Embodiment 1: This embodiment discloses a 3D model loading method based on WebGPU, referring to Figure 1 The method includes: S1 model acquisition and S2 model loading, first obtaining a 3D model file to be loaded, then obtaining the path of the file, then using a loader built with WebGPU technology to read the target file through the path, then using the loader to parse the read target file to obtain a parsing result, then extracting vertex data and index data from the parsing result, then converting the format of the vertex data and index data to the target data format, then creating a first buffer, and storing the converted vertex data and index data in the first buffer, then binding the first buffer to the rendering pipeline of the GPU. This embodiment includes the following steps: S1 model acquisition, obtain the 3D model file to be loaded, recorded as the target file.

[0031] The target file is stored in a computer and is the export result of a 3D modeling software (such as Blender, Maya, 3ds Max, etc.). The format of the target file can be OBJ, FBX, GLTF, etc.

[0032] S2 model loading, including S21 path acquisition, S22 first construction, S23 file parsing, S24 format conversion and S25 second construction.

[0033] S21 obtains a path, obtaining a path of a target file, wherein the path is a character string and can be obtained by user input, configuration file reading, or program automatic detection.

[0034] The user input refers to: the user provides the file path through a command line input or an input box of a graphical user interface (GUI).

[0035] The configuration file stores various configuration information required when the program is running, including the file path.

[0036] S22 First construction, this embodiment uses WebGPU technology to build a loader, which can read the target file through the previously obtained file path. The function of the loader is to load the file from the disk into the memory to prepare for subsequent parsing and rendering.

[0037] WebGPU is an API for high-performance graphics rendering on web pages that provides direct access to modern GPU hardware.

[0038] S23 file parsing, after the loader reads the target file, it will parse the target file. The purpose of parsing the target file is to extract the key information required to build a 3D model from the target file. The key information mainly includes vertex data (describing the location, color, texture coordinates, etc. of the model surface points) and index data (describing how vertices are connected to form polygons). These key information are stored in the target file in binary or text form.

[0039] S24 format conversion converts the parsed vertex data and index data into a unified data format suitable for GPU processing. This conversion process includes data type conversion (such as conversion from floating-point numbers to fixed-point numbers), data rearrangement (such as storing vertex coordinates, colors, texture coordinates, etc. separately), etc.

[0040] The vertex data after the format conversion is recorded as the first data, and the index data after the format conversion is recorded as the second data.

[0041] S25: second construction, creating a first buffer storing the first data and the second data, and binding the first buffer to the rendering pipeline of the GPU.

[0042] This embodiment obtains the target file to be loaded through S1 model acquisition, then obtains the path of the target file through S2 model loading, and uses WebGPU technology to build a loader to load the target file. The target file is also parsed by the loader to obtain vertex data and index data, and the vertex data and index data are bound to the GPU rendering pipeline, so that the three-dimensional model can be correctly and efficiently loaded in the Web environment.

[0043] Example 2: Reference Figure 2 The difference between this embodiment and embodiment 1 is that after executing S23 file parsing and before executing S24 format conversion, it also includes: S31 The third construction takes any vertex data in the target file as the origin, and then constructs three mutually perpendicular coordinate axes (x, y, z axes) based on the origin to construct a spatial coordinate system. The specific directions of the three coordinate axes are not limited in this step.

[0044] S32 is the first judgment, traversing the first hexagram to the eighth hexagram, and judging in turn whether the number of vertex data in each hexagram is greater than or equal to two. If so, the three-dimensional model file corresponding to the current hexagram (the three-dimensional model file includes: the unit model file in the current hexagram, and the three-dimensional model files on the three coordinate axes corresponding to the current hexagram) is used as the new target file, and S31 is executed. The third construction; if not, S33 is executed. The first calculation.

[0045] S33 first calculates, using Jaccard similarity to calculate the similarity of vertex data in adjacent hexagrams.

[0046] For example, in a three-dimensional coordinate system, vertex A and vertex B may be vertices corresponding to vertex data in adjacent hexagrams, and their adjacent vertex sets are as follows.

[0047] Vertex A (located in the first quadrant): the set of adjacent vertices is {V1, V2, V3, V4}; Vertex B (located in the hexagram adjacent to the first hexagram): the set of adjacent vertices is {V3, V4, V5, V6}; Find the common adjacent vertices of vertex A and vertex B: {V3, V4}; According to the definition of Jaccard similarity, calculate the similarity r between vertex A and vertex B: ; .

[0048] Therefore, the Jaccard similarity between vertex A and vertex B is 1 / 3, indicating that they are similar to a certain extent, but not completely similar.

[0049] S34 is a second judgment, judging whether the similarity in the first calculation in S33 is greater than a preset threshold, if so, executing S35 merging; if not, executing S36 first retaining.

[0050] S35 merges the two hexagrams corresponding to the similarity in the first calculation of S33 into a new hexagram. At this time, the new hexagram includes at least two vertex data (that is, the two vertex data corresponding to the similarity in the first calculation of S33, and may also include the vertex data on the coordinate axes corresponding to the original two hexagrams). In order to reduce data redundancy, it is necessary to delete any vertex data corresponding to the similarity and re-execute the first calculation of S33.

[0051] S36 first retains the vertex data in the two hexagrams corresponding to the similarity.

[0052] S37 data update, taking the vertex data in the first retention of S35 and the vertex data on the coordinate axis corresponding to the hexagram in the first retention of S35 and S36 as new vertex data, and establishing new index data based on the new vertex data.

[0053] This embodiment first selects the vertex corresponding to any vertex data in the target file as the origin to construct a three-dimensional space coordinate system, then determines the number of vertex data in each hexagram of the space coordinate system, and if there are multiple vertex data, reconstructs the space coordinate system until the number of vertices in each hexagram is zero or one, and then calculates the similarity between adjacent hexagram vertices, and decides whether to merge the hexagrams or retain the vertex data based on whether the similarity exceeds a preset threshold, and finally updates the vertex data and index data. This embodiment can effectively organize and manage vertex data and delete adjacent and similar vertex data.

[0054] Reference Figure 3 In other embodiments, after executing the third construction in S31 and before executing the first judgment in S32, the method further includes: S41 determines the direction, taking the direction from the origin to the camera as the positive direction of the x-axis, cross-multiplying the normal vector of the vertex data and the unit vector in the positive direction of the x-axis to determine the positive direction of the y-axis, using the right-hand rule to determine the positive direction of the z-axis, and constructing a spatial coordinate system based on the x-axis, y-axis and z-axis.

[0055] In this step, the origin and the center line of the camera are both on the x-axis. The camera can be regarded as a mass point, and a ray, namely the x-axis, is determined through the two points.

[0056] S42 determines the coordinates, determines the horizontal coordinate of the far plane of the viewing frustum, and records it as the first coordinate. Since in S41, the positive direction of the x-axis is the direction from the origin to the camera, the near plane and the far plane of the camera viewing frustum are planes perpendicular to the x-axis.

[0057] S43 deletes the file, obtains a coordinate point whose horizontal coordinate is smaller than the first coordinate, records it as the second coordinate, deletes the target file corresponding to the second coordinate, and uses the remaining target file as a new target file.

[0058] Then, the first judgment in S32 to the first retention in S36 are executed in sequence.

[0059] S44 is a second calculation, which counts the number of vertex data retained in the two steps of S35 merging and S36 first retaining, and the number of vertex data with the same ordinate and ordinate, and records it as third data.

[0060] S45 is a third judgment, judging whether the third data is one, if so, executing S37 data update; if not, executing S46 second retention.

[0061] S46 second retention, retaining the vertex data with the largest horizontal coordinate among the vertex data with the same vertical coordinate and vertical coordinate, and executing S37 data update.

[0062] This embodiment defines the directions of three coordinate axes, and deletes the target file in combination with the field of view of the camera, that is, the target file after the far plane of the viewing cone is deleted, and only the remaining three-dimensional model file is processed. The horizontal coordinates of the vertex data are then compared, and the obscured vertex data are further deleted according to the comparison results. Because the positive direction of the horizontal coordinate of the spatial coordinate system points to the camera, when the camera is facing the origin of the spatial coordinate system, only the vertex data with the largest horizontal coordinate can be seen within the field of view of the camera (specifically: the vertex data with the largest horizontal coordinate among the vertex data with the same vertical and vertical coordinates), and the remaining vertex data is deleted, which reduces the number of vertex data that need to be loaded and improves the loading speed of the three-dimensional model file.

[0063] Example 3: Reference Figure 4, the difference between this embodiment and embodiment 1 is that when there is no error in the path of the target file but the loader cannot correctly load the target file, it means that an error has occurred in the current loading queue of the loader and the loading queue needs to be replaced, and in the step of the first construction of S22, the loader includes multiple loading queues, and the code corresponding to each loading queue is basically the same (that is, all will perform the task of loading the target file), and each code line is followed by a HOOK function, and each HOOK function points to the end of the code line corresponding to the code in other loading queues, and after executing the first construction of S22 and before executing the file parsing of S23, it also includes: S51 is the fourth judgment, judging whether the loader has successfully read the target file. If so, it means that the target file has been correctly loaded into the memory and can be further processed to continue executing S23 file parsing; if not, it means that there is a problem with the current loading queue and it is necessary to execute S52 to collect logs.

[0064] S52 collects logs, obtains detailed operation logs from the log system of the loader, and obtains error information based on the operation logs.

[0065] The operation log contains various information about the loading process, including successfully loaded files, failed loading attempts, and error information that occurred during the loading process.

[0066] S53 collects the location and searches for the corresponding error code in the code library using the clues provided in the error information (such as error code, error description, file location where the error occurred, etc.).

[0067] S54 jumps, and uses the HOOK function at the end of the previous line of code of the error code to jump to the position corresponding to the new loading queue in the loader, and uses the code after the new loading queue to continue loading the target function, and then continues to execute the fourth judgment of S51 until the preset stop condition is met, and then continues to execute S55 to clear the process.

[0068] The stop condition mentioned in this step is: the execution times of S54 jump reaches the preset execution times.

[0069] The loader does not use parallel processing, so only one loading queue of the loader is in working state, and the remaining loading queues are all in idle state. Therefore, when a problem occurs in a loader, you can choose any loading queue to jump to, and indicate in the log that the current loading queue has a fault, to prompt the operation and maintenance personnel to check the program of the loading queue.

[0070] S55 clears the process, clears the original loading process in the loader, and sends out an alarm signal.

[0071] This embodiment provides a complete error handling process. When the loader cannot load the target file normally, it means that an error has occurred in the loader. This embodiment automatically jumps to the same position of the new loading queue through the HOOK function. When a problem occurs in the loading queue, it can automatically jump to the loading queue to achieve continued loading of the target file and re-execute the fourth judgment step. If the problem is still not solved, it will still return to the jump step. When the number of executions of the jump step reaches the preset threshold, it indicates that the problem cannot be solved by replacing the loading queue. At this time, it is necessary to clear the contents of the loading queue and issue an alarm signal.

[0072] Example 4: Reference Figure 5 The difference between this embodiment and embodiment 2 is that after executing S35 merging and before executing S37 data updating, it also includes: S61 first obtains and integrates the vertex data deleted in S35 into a data set.

[0073] S62 is a third calculation, traversing the data set, using Jaccard similarity to calculate the similarity between each pair of vertex data, and recording the similarity as fourth data.

[0074] S63 is a fifth judgment, determining whether the fourth data is greater than a preset threshold value, if so, executing S64 to eliminate; if not, executing S24 to convert the format.

[0075] S64: Eliminate any vertex data corresponding to the fourth data in the data set, and execute the third calculation in S62 until the calculation stop condition is met.

[0076] The conditions for stopping the calculation include: the number of executions of S64 elimination reaches the maximum number of iterations, the size of the data set reaches the expected size, etc.

[0077] S65: third retaining, retaining the vertex data corresponding to the fourth data.

[0078] Then, the S37 data update is executed, and after the S37 data update is executed and before the S24 format conversion is executed, the following steps are also included: S71 first setting, taking the vertex corresponding to the vertex data in the S37 data update as the main control point. The main control point refers to the vertex data in the S37 data update, which represents the key position, shape feature or motion trajectory of the object.

[0079] S72 is a second setting, in which the vertex corresponding to the vertex data retained in S65 is used as a secondary control point, and index data of the secondary control point is established.

[0080] In the format conversion of S24, the format of the vertex data corresponding to the secondary control point is converted into the target data format, recorded as fourth data; the format of the index data corresponding to the secondary control point is converted into the target data format, recorded as fifth data.

[0081] Format conversion is performed to make the data compatible with subsequent processing steps or target systems.

[0082] In S25 second construction, a second buffer storing the fourth data and the fifth data is created, and the second buffer is bound to the rendering pipeline of the GPU.

[0083] After executing S25 second building, the method further includes: S81: First rendering: the rendering pipeline renders the data in the first buffer to the user interface to obtain a first rendering effect.

[0084] S82: second rendering: the rendering pipeline renders the data of the second buffer to the user interface to obtain a second rendering effect.

[0085] S83 rendering combination, in the fragment shader of the GPU, can read the two rendering parts and merge the rendering effects of the first rendering of S81 and the second rendering of S82 (such as addition, mixing, etc.).

[0086] This embodiment first further screens the deleted vertex data to obtain secondary control points, then converts the format of the secondary control points and sets index data, and finally renders the main control points to provide basic or preliminary visual feedback, and then renders the secondary control points to provide higher quality or more refined visual effects.

[0087] Embodiment 5: This embodiment discloses a 3D model loading system based on WebGPU, the system comprising: Model acquisition module, this module is responsible for obtaining the 3D model file to be loaded, recorded as the target file. For example, select the file from the local file system, download the file from the network server, or retrieve the file from a specific database system. Once the target file is obtained, the model acquisition module will prepare it for subsequent processing by the model loading module.

[0088] The model loading module includes a path acquisition unit, a first construction unit, a file parsing unit, a format conversion unit and a second construction unit.

[0089] The path acquisition unit is connected to the model acquisition module for acquiring the path of the target file. The path can be an absolute path or a relative path of the file, depending on the storage location of the target file and the file structure of the system.

[0090] The first construction unit is communicatively connected with the path acquisition unit, and is used to construct a loader using the WebGPU technology, and the loader reads the target file through the path.

[0091] The file parsing unit is connected to the first building unit for parsing the read target file using the loader, and extracting vertex data and index data from the parsing result. The vertex data describes the position, color, texture coordinates and other information of each vertex in the three-dimensional model, while the index data defines how the vertices are connected to form a triangle or other polygonal geometric primitive.

[0092] The format conversion unit is in communication with the file parsing unit. Since different Web environments may use different data formats, the format conversion unit needs to appropriately convert the vertex data and the index data according to the requirements of the target data format. The vertex data after the conversion is recorded as the first data, and the index data after the conversion is recorded as the second data.

[0093] The second construction unit is connected to the format conversion unit for creating a first buffer storing the first data and the second data, and binding the first buffer to the rendering pipeline of the GPU. The rendering pipeline is a collection of a series of steps and operations used in the GPU to process graphics rendering tasks. By binding the first buffer to the rendering pipeline, the GPU can access the vertex data and index data for subsequent rendering processing.

[0094] The model acquisition module and the model loading module of this embodiment work closely together to achieve efficient loading and rendering of 3D model files. The model acquisition module is responsible for acquiring the 3D model file (target file) to be loaded, while the model loading module includes a series of sub-units including acquiring the path, building a WebGPU loader, parsing the file to extract vertex and index data, converting the data format to the target format, and finally building and binding the buffer storing these data to the GPU rendering pipeline, so that the 3D model can be smoothly loaded and ready for rendering.

[0095] The above are all preferred embodiments of the present application, and the protection scope of the present application is not limited thereto. Therefore, any equivalent changes made according to the structure, shape, and principle of the present application should be included in the protection scope of the present application.

Claims

1. A three-dimensional model loading method based on WebGPU, characterized in that: include: Model acquisition: Get the 3D model file to be loaded and record it as the target file; Model loading: including path acquisition, first build, file parsing, format conversion and second build; Get path: Get the path of the target file; First build: use WebGPU technology to build a loader, and the loader reads the target file through the path; File parsing: Use the loader to parse the read target file, obtain the parsing result, and extract the vertex data and index data from the parsing result; Format conversion: converting the format of the vertex data and the format of the index data into a target data format, recording the vertex data after the conversion as first data, and recording the index data after the conversion as second data; Second construction: creating a first buffer storing the first data and the second data, and binding the first buffer to the rendering pipeline of the GPU.

2. The WebGPU-based 3D model loading method according to claim 1, characterized in that: After executing the file parsing step and before executing the format conversion step, the method further includes: The third construction: take any vertex data in the target file as the origin to construct the spatial coordinate system; First judgment: judging whether the current hexagram contains multiple vertex data, if so, taking the three-dimensional model file of the current hexagram as a new target file and executing the third construction step; if not, executing the first calculation step; First calculation: use Jaccard similarity to calculate the similarity of vertex data in adjacent hexagrams; Second judgment: judging whether the similarity is greater than a preset threshold, if so, executing the merging step; if not, executing the first retaining step; Merge: merge the two hexagrams corresponding to the similarity into a new hexagram, delete any vertex data corresponding to the similarity, and execute the first calculation step; First reservation: retaining the vertex data in the two hexagrams corresponding to the similarity; Data update: Use the remaining vertex data in the merging step, the vertex data retained in the first retained step, the vertex data on the coordinate axis corresponding to the new hexagram in the merging step, and the vertex data on the coordinate axis corresponding to the two hexagrams in the first retained step as new vertex data, and establish new index data based on the new vertex data.

3. The WebGPU-based 3D model loading method according to claim 2, characterized in that: After executing the third construction step and before executing the first judgment step, the method further includes: Determine the direction: Take the direction from the origin to the camera as the positive direction of the x-axis, perform cross multiplication on the normal vector of the vertex data and the unit vector in the positive direction of the x-axis to determine the positive direction of the y-axis, use the right-hand rule to determine the positive direction of the z-axis, and construct a spatial coordinate system based on the x-axis, y-axis, and z-axis; Determine the coordinates: determine the horizontal coordinate of the far plane of the viewing frustum, recorded as the first coordinate; Delete file: Get the coordinate point whose horizontal coordinate is less than the first coordinate, record it as the second coordinate, and delete the target file corresponding to the second coordinate.

4. The WebGPU-based 3D model loading method according to claim 3, characterized in that: After executing the first retention step and before executing the data update step, the method further includes: Second calculation: count the number of vertex data with the same ordinate and vertical coordinate, and record it as the third data; Third judgment: judging whether the third data is one, if so, executing the step of data updating; if not, executing the second reserved step; Second retention: retain the vertex data with the largest horizontal coordinate among the vertex data with the same vertical coordinate and vertical coordinate, and execute the data update step.

5. The WebGPU-based 3D model loading method according to any one of claims 1 to 4, characterized in that: After executing the first building step and before executing the file parsing step, the method further includes: Fourth judgment: judging whether the loader successfully reads the target file, if so, executing the file parsing step; if not, executing the clearing process step; Clear process: Clear the loading process in the loader and issue an alarm signal.

6. The WebGPU-based 3D model loading method according to claim 5, characterized in that: In the first construction step, the loader includes a plurality of loading queues, and a HOOK function is provided at the end of each code line of each loading queue, and after executing the fourth judgment step and before executing the clearing process step, it also includes: Collect logs: collect the running logs of the loader, and obtain error information based on the running logs; Collection location: locate the error code based on the error information; Jump: Use the HOOK function at the end of the previous line of code of the error code to jump to the new loading queue and continue loading the target file.

7. The WebGPU-based 3D model loading method according to any one of claims 2 to 4, characterized in that: After the step of performing the merge and before the step of performing the data update, the method further includes: First acquisition: integrate the vertex data deleted in the merging step into a data set; The third calculation: use Jaccard similarity to calculate the similarity of any two vertex data in the data set, recorded as the fourth data; Fifth judgment: judging whether the fourth data is greater than a preset threshold, if so, executing a step of eliminating; if not, executing a step of format conversion; Eliminate: Eliminate any vertex data corresponding to the fourth data in the data set, and execute the third calculation step until the calculation stop condition is met; Third reservation: retain the vertex data corresponding to the fourth data.

8. The WebGPU-based 3D model loading method according to claim 7, characterized in that: After executing the step of updating the data and before executing the step of converting the format, the method further includes: First setting: the vertex corresponding to the vertex data in the data update step is used as the main control point; Second setting: taking the vertex corresponding to the vertex data retained in the third retaining step as a secondary control point, and establishing index data of the secondary control point; The format conversion step further includes: converting the format of the vertex data corresponding to the secondary control point into the target data format, recorded as fourth data; converting the format of the index data corresponding to the secondary control point into the target data format, recorded as fifth data; The second construction step also includes: creating a second buffer storing the fourth data and the fifth data, and binding the second buffer to the rendering pipeline of the GPU.

9. The WebGPU-based 3D model loading method according to claim 8, characterized in that: After performing the second building step, the method further comprises: First rendering: the rendering pipeline renders the data in the first buffer to the user interface to obtain a first rendering effect; Second rendering: the rendering pipeline renders the data in the second buffer to the user interface to obtain a second rendering effect; Rendering Merge: Use the GPU to merge the first rendering effect with the second rendering effect.

10. A three-dimensional model loading system based on WebGPU, the system being used to implement the method according to any one of claims 1 to 9, characterized in that: include: The model acquisition module is used to obtain the 3D model file to be loaded, which is recorded as the target file; A model loading module, comprising a path acquisition unit, a first construction unit, a file parsing unit, a format conversion unit, and a second construction unit; A path acquisition unit is connected to the model acquisition module for acquiring the path of the target file; A first construction unit is communicatively connected with the path acquisition unit and is used to construct a loader using WebGPU technology, and the loader reads the target file through the path; A file parsing unit, which is in communication connection with the first building unit, and is used to parse the read target file using a loader, obtain a parsing result, and extract vertex data and index data from the parsing result; A format conversion unit, connected to the file parsing unit for communication, for converting the format of the vertex data and the format of the index data into a target data format, recording the vertex data after the format conversion as first data, and recording the index data after the format conversion as second data; The second construction unit is communicatively connected to the format conversion unit, and is used to create a first buffer storing the first data and the second data, and bind the first buffer to the rendering pipeline of the GPU.

Citation Information

Patent Citations

  • Large-scale point cloud visualization method based on improved octree and adaptive reading

    CN112308974A

  • Vehicle paint spraying online simulation method adopting layered attachment and layered rendering

    CN116992673A

  • WebGPU-based geographic vector data rendering method, storage medium, equipment and computer program product

    CN119067856A

  • Three-dimensional model and material merging method, device, terminal, storage medium and rendering method

    US20220319095A1

  • Graphics rendering method and related device thereof

    WO2022089592A1

Cited By

  • Monolithic three-dimensional model streaming loading method for Web side

    CN120976391A

  • A monolithic three-dimensional model streaming loading method for a web end

    CN120976391B

  • WebGPU-based address cavity range normalization coloring method and system

    CN122473328A

  • A webgpu-based address lumen range normalization shading method and system

    CN122473328B