Model data processing method and apparatus, device, and storage medium

By receiving and parsing lightweight model data files, utilizing the main thread and child threads in collaborative processing, and combining lightweight technology to generate target format data, the problem of high-complexity model loading efficiency is solved, achieving faster network transmission and browser rendering efficiency.

CN115391696BActive Publication Date: 2026-04-10ZHEJIANG SUPCON INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG SUPCON INFORMATION TECH CO LTD
Filing Date
2022-08-26
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

In existing technologies, models with high complexity have low loading efficiency in browsers, and the existing compression ratio is low and the decompression time is long, resulting in slow loading speed.

Method used

The lightweight model data file sent by the receiving end device is parsed and converted into data in the target format, including type record segment, index and length record segment, and data record segment. The main thread and sub-thread work together to improve parsing efficiency, and lightweight processing techniques such as shared geometry data deletion, material deduplication, geometry data merging, and vertex deletion are used to generate a lightweight model data file.

Benefits of technology

It effectively reduces the size of model data files, improves network transmission speed and the loading and parsing speed of models in browsers, especially the loading efficiency of large scene models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115391696B_ABST
    Figure CN115391696B_ABST
Patent Text Reader

Abstract

The present application provides a model data processing method and device, equipment and storage medium, wherein the method comprises: receiving the lightweight model data file sent by the sending end equipment, the lightweight model data file comprising: file type and at least one model data, each model data comprising: type record segment, index and length record segment and data record segment in turn; the lightweight model data file is analyzed and converted to obtain data in the target format; according to the data in the target format, rendering is carried out to display the target model. By processing the model data file into the lightweight model data file and transmitting, the memory size of the model data in the storage space can be saved, and when data transmission, the lightweight model data file with smaller memory can also obtain higher transmission speed.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of model data processing, in particular to a model data processing method and device, equipment and a storage medium. BACKGROUND

[0002] It has become a general trend to perform virtual simulation based on real data on the browser side, which also puts forward higher requirements on the diversified display form of the scene and the carrying capacity of the model data. In order to solve the problems of slow loading speed, long request time and low rendering frame rate of large scenes and massive data, model lightweight technology has emerged as the times require.

[0003] In the current model lightweight technology, in order to reduce the loading time of the model in the browser, the general method for high complexity models is to compress the model at the sending end and transmit it to the browser end, and then perform analysis and rendering by the browser end.

[0004] However, for high complexity models, the compression rate of the existing method is low, and when the model is large, the decompression time is also long, so how to improve the loading efficiency of the model in the browser has become a problem to be solved. SUMMARY

[0005] The purpose of the present application is to provide a model data processing method, device, equipment and storage medium to solve the problem of low loading efficiency of the model in the browser in the prior art.

[0006] To achieve the above purpose, the technical scheme adopted by the embodiments of the present application is as follows:

[0007] In a first aspect, an embodiment of the present application provides a model data processing method, which comprises:

[0008] receiving a lightweight model data file sent by a sending end device, the lightweight model data file comprising: a file type and at least one model data, each model data comprising in turn: a type record segment, an index and length record segment and a data record segment, wherein the type record segment is used to record a plurality of data types, the index and length record segment is used to record the byte code starting index and byte code length of the data of each data type, and the data record segment is used to record the data of each data type;

[0009] performing analysis and conversion processing on the lightweight model data file to obtain data in a target format, wherein the target format comprises: a key-value pair format;

[0010] performing rendering according to the data in the target format to display a target model.

[0011] Optionally, the parsing and conversion processing of the lightweight model data file to obtain the model data in the target format comprises:

[0012] Whether to perform lightweight parsing is determined according to the file type in the lightweight model data file by the main thread;

[0013] If yes, a parsing sub-thread is created from the main thread, each model data is sent to the sub-thread by the main thread, and each model data is parsed and converted by the sub-thread to obtain the model data in the target format, and the model data in the target format is sent to the main thread.

[0014] Optionally, the parsing and conversion processing of the lightweight model data file to obtain the model data in the target format comprises:

[0015] According to the preset order and type length, a plurality of data types are read from the type record segment of the model data;

[0016] According to the byte code starting index and byte code length of each data type recorded in the index and length record segment of the model data, the data of each data type is sequentially read from the data record segment of the model data;

[0017] The plurality of data types and the data of each data type are sequentially combined into key-value pairs, the key of the key-value pair is the data type, and the value is the data of the data type;

[0018] Each key-value pair is combined into the model data in the target format.

[0019] Optionally, the lightweight model data file is generated by the sending end device through the following steps:

[0020] A plurality of data types and data of each data type are extracted from the original model data file, and the plurality of data types and data of each data type are presented in the form of key-value pairs;

[0021] The data of each data type extracted is subjected to lightweight processing to obtain lightweight data;

[0022] The lightweight data is subjected to recombination processing to obtain recombined model data, and the recombined model data is saved into the lightweight model data file.

[0023] Optionally, the lightweight processing comprises at least one of the following:

[0024] If the current grid shares geometry data with other grids, the current grid is deleted;

[0025] Add the materials corresponding to each mesh in the model to the same set for deduplication, and delete the materials not referenced by any mesh from the set;

[0026] For static models, merge the geometry data of meshes with the same material;

[0027] If the distance between the current vertex and other vertices is less than a preset threshold, delete the current vertex;

[0028] Convert the map data to a format;

[0029] Thinning processing is performed on the animation data;

[0030] Low-precision processing is performed on the geometry data.

[0031] Optionally, the reorganization processing includes:

[0032] Iterate through the plurality of data types and the key-value pairs corresponding to the data of each data type to extract the plurality of data types and the data of each data type;

[0033] Arrange the data of each data type according to a preset order to obtain arranged data;

[0034] Arrange the plurality of data types according to a preset order and type length to obtain arranged data types;

[0035] According to the arranged data, determine the byte code start index and byte code length of the data of each data type;

[0036] Concatenate the arranged data types, the byte code start index and byte code length of the data of each data type, and the arranged data in sequence to obtain reorganized model data.

[0037] In a second aspect, another embodiment of the present application provides a model data processing apparatus, which includes:

[0038] A receiving module configured to receive a lightweight model data file sent by a sending end device, the lightweight model data file including a file type and at least one model data, each model data including in sequence a type record segment, an index and length record segment, and a data record segment, wherein the type record segment is configured to record a plurality of data types, the index and length record segment is configured to record the byte code start index and byte code length of the data of each data type, and the data record segment is configured to record the data of each data type;

[0039] A parsing module configured to parse and convert the lightweight model data file to obtain data in a target format, the target format including a key-value pair format;

[0040] a display module configured to render the data in the target format to display a target model.

[0041] Optionally, the parsing module is further configured to:

[0042] determine, by the main thread, whether to perform lightweight parsing according to a file type in the lightweight model data file;

[0043] if yes, create a parsing sub-thread from the main thread, send each of the model data from the main thread to the sub-thread, and perform parsing and conversion processing on each of the model data by the sub-thread to obtain model data in the target format and send the model data in the target format to the main thread.

[0044] Optionally, the parsing module is further configured to:

[0045] read a plurality of data types from a type record segment of the model data according to a preset order and type length;

[0046] read data of each of the data types from a data record segment of the model data according to a byte code start index and byte code length of the data of each of the data types recorded in an index and length record segment of the model data;

[0047] compose a plurality of key-value pairs by sequentially combining the plurality of data types and the data of each of the data types, wherein a key of each of the key-value pairs is a data type and a value of each of the key-value pairs is data of the data type;

[0048] combine each of the key-value pairs into model data in the target format.

[0049] Optionally, the receiving module is further configured to:

[0050] create a request sub-thread from the main thread, and send a model data acquisition request to the sending end device by the request sub-thread to trigger the sending end device to send the lightweight model data file.

[0051] In a third aspect, another embodiment of the present application provides an electronic device, including a processor, a storage medium, and a bus, the storage medium stores machine readable instructions executable by the processor, when the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the machine readable instructions to perform the steps of the model data processing method as described above.

[0052] In a fourth aspect, another embodiment of the present application provides a computer readable storage medium, the computer readable storage medium stores a computer program, and the computer program is executed by a processor to perform the steps of the model data processing method as described above.

[0053] The beneficial effects of the present application are:

[0054] The lightweight model data file sent by the sending terminal device is received, the lightweight model data file includes: a file type and at least one model data, each model data includes: a type record segment, an index and length record segment, and a data record segment in sequence; the lightweight model data file is parsed and converted to obtain data in a target format; and the target model is displayed by rendering according to the data in the target format. By processing the model data file into a lightweight model data file and transmitting the lightweight model data file, the memory size of the model data in the storage space can be saved, and when data is transmitted, the lightweight model data file with smaller memory can also obtain higher transmission speed, thereby improving the loading and parsing speed of the model data in the browser. BRIEF DESCRIPTION OF DRAWINGS

[0055] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced as follows. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.

[0056] Figure 1 A schematic diagram of the architecture of a service system provided by an embodiment of the present application is shown;

[0057] Figure 2 A flowchart of a model data processing method provided by an embodiment of the present application is shown;

[0058] Figure 3 A flowchart of a lightweight parsing method provided by an embodiment of the present application is shown;

[0059] Figure 4 A flowchart of a model data parsing method provided by an embodiment of the present application is shown;

[0060] Figure 5 A flowchart of a model data lightweight method provided by an embodiment of the present application is shown;

[0061] Figure 6 A flowchart of a model data reorganization method provided by an embodiment of the present application is shown;

[0062] Figure 7 A schematic diagram of the structure of a model data processing device provided by an embodiment of the present application is shown;

[0063] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present application is shown. DETAILED DESCRIPTION

[0064] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of illustration and description, and do not serve to limit the protection scope of the present application. In addition, it should be understood that the schematic drawings are not drawn according to the actual proportions. The flowcharts used in the present application show the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowcharts can not be implemented in sequence, and the steps without logical context relationship can be reversed in sequence or implemented simultaneously. In addition, one or more other operations can be added to the flowcharts or one or more operations can be removed from the flowcharts under the guidance of the content of the present application.

[0065] In addition, the described embodiments are only some of the embodiments of the present application, not all the embodiments. The components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0066] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.

[0067] In the current model lightweight technology, for a model with high complexity, such as a large scene model, in order to reduce the loading time of the model in the browser, the general method is to compress the model by the sending end or the server, and then transmit the compressed model to the browser, and the browser performs model data analysis and rendering.

[0068] However, the existing model compression method has a low compression rate for large scene models, and the sending end or the server compresses the model, and then transmits the compressed model to the browser, and the browser loading and parsing time is also relatively long, so how to improve the loading efficiency of the model in the browser has become a problem to be solved.

[0069] Based on the above problems, the present application proposes a model data processing method, which is applied to Figure 1 The model data transceiving and rendering scene shown in FIG. 1 includes a sending end 10, a server 20, a browser 30 and a receiving end 40. Figure 1As shown, first, the sending end device can compress the model data into a lightweight model data file, and then the sending end device sends the lightweight model data file to the receiving end device in response to a file request of the receiving end device. After receiving the lightweight model data file, the receiving end device can parse the model data file to obtain the model data, and create a scene and render a model according to the model data, thereby realizing fast loading of large scene model data. The sending end device can be a terminal device or a server, and the receiving end device can be a terminal device. The terminal device can be, for example, a desktop computer, a notebook computer, a mobile phone, a tablet computer, etc.

[0070] Next, the model data processing method of the present application is described, which can be applied to the receiving end device described above. As shown, the method comprises: Figure 2

[0071] S201: receiving a lightweight model data file sent by a sending end device, wherein the lightweight model data file comprises a file type and at least one model data, and each model data comprises a type record segment, an index and length record segment, and a data record segment in sequence, wherein the type record segment is used to record a plurality of data types, the index and length record segment is used to record a byte code starting index and a byte code length of the data of each data type, and the data record segment is used to record the data of each data type.

[0072] Optionally, the sending end device can be an electronic device or a server for saving model data of a user. If the sending end device is an electronic device for saving model data of a user, the electronic device can process the model data into a lightweight model data file. If the sending end device is a server, in a possible implementation, a person skilled in the art can upload the model data to the server through a browser, and the server processes the model data into a lightweight model data file.

[0073] Optionally, the file type can be a unique type identifier of the lightweight model data file.

[0074] Optionally, the lightweight model data file can comprise model data of a plurality of models in a scene. For example, in a scene A comprising five models, namely model 1, model 2, model 3, model 4, and model 5, the lightweight model data file of the scene A received by the user can comprise a file type identifier and model data of the model 1, the model 2, the model 3, the model 4, and the model 5.

[0075] ​Optionally, the lightweight model data file can include at least one model data, each model data including in sequence: a type record segment, an index and length record segment, and a data record segment, wherein the type record segment is used to record a plurality of data types, the data types can be, for example, node data type, mesh data type, material data type, map data type, and animation data type, etc., the index and length record segment is used to record the byte code starting index and byte code length of the data of each data type, and the data record segment is used to record the data of each data type.

[0076] For example, the data record segment of the model A can include: values of binary data, node data, mesh data, material data, map data, and animation data, etc. The binary data includes geometric coordinate data such as vertex, vertex index, normal, UV, texture map data, and frame animation data; the node data is a description of the overall structure of the model, which is organized in a tree structure and divided into Mesh grid nodes and non-Mesh grid nodes; the mesh data is a description of the binary geometric data index corresponding to each mesh and the material index information corresponding thereto; the material data is a description of the texture information of the mesh, such as color, map, metal degree, roughness, and highlight reflection; the map data includes a description of the texture map used in the material and the binary data index information corresponding thereto; and the animation data includes a description of the animation type, the node index of the animation subject, the interpolation method, and the binary data index corresponding to the frame animation.

[0077] S202: performing parsing and conversion processing on the lightweight model data file to obtain data in a target format, the target format including: a key-value pair format.

[0078] Optionally, after receiving the lightweight model data file, the receiving end device can first perform format conversion on the lightweight model data file to convert it into a format that can be parsed by the browser, for example, converting binary data into a type array, and then performing parsing and conversion processing on the lightweight model data file to obtain data in a target format.

[0079] Optionally, the data in the target format can be data of each model in a key-value pair format. For example, the data in the target format can include node data, mesh data, material data, map data, and animation data converted into a JSON (JavaScript Object Notation) object.

[0080] S203: rendering according to the data in the target format to display the target model.

[0081] Optionally, the target model can be a plurality of models included in a scene corresponding to the lightweight model data file requested by the receiving end device.

[0082] Optionally, rendering according to the data in the target format can be creating a scene and rendering using three.js based on a loader in the browser.

[0083] Exemplarily, the manner of rendering according to the data in the target format can be as follows:

[0084] For each map data in the data in the target format, the binary data corresponding to the current map can be decompressed and converted using the loader to construct a texture object;

[0085] For each material data in the data in the target format, a standard mesh material object can be constructed according to the color, metallicity, roughness and other attributes of the material, and if there is a map, the map object is associated;

[0086] For each mesh data in the data in the target format, a geometry object can be generated using the binary geometry data corresponding to each mesh, and then a material object is obtained according to the material index corresponding to the mesh to jointly construct a group object;

[0087] For each animation data in the data in the target format, a keyframe tracking object is constructed according to the type, interpolation method, frame animation data and other attributes of the animation, and then the object is used to construct an animation clip object, and the animation clip object is put into an animation collection;

[0088] For each node data in the data in the target format, if the current node is a Mesh mesh node, the mesh object is associated, otherwise a group object is created, and then all objects are organized in a tree structure as the value of the child node attribute field of the three-dimensional object;

[0089] The animation collection is used as the value of the animation attribute field of the three-dimensional object, and finally the three-dimensional object is added to the scene and rendered using three.js.

[0090] In the embodiments of the present application, the lightweight model data file sent by the sending end device is received, and the model data sequentially includes a type record segment, an index and length record segment and a data record segment, and the lightweight model data file is parsed and converted to obtain data in a target format, and finally rendering is performed according to the data in the target format to display the target model. By storing the model data in the format of the lightweight model data file and transmitting it to the receiving end device, the file size of the model data can be effectively reduced. In network transmission, the lightweight model data file format is used for transmission, and for transmission of large scene models, the network transmission speed can be effectively improved. Correspondingly, fast rendering can be realized at the receiving end device.

[0091] Next, the step of parsing and converting the lightweight model data file to obtain the model data in the target format is described, as shown in Figure 3 The S202 step includes:

[0092] S301: determining, by the main thread, whether to perform lightweight parsing according to the file type in the lightweight model data file.

[0093] Optionally, the main thread of the receiving end device can first identify the file type of the lightweight model data file. If the file type identifier of the lightweight model data file is identified, the next step of parsing can be performed. If the file type identifier is not identified, the next step of parsing is not performed.

[0094] S302: if yes, creating a parsing sub-thread from the main thread, sending each model data from the main thread to the sub-thread, and performing parsing and conversion processing on each model data by the sub-thread to obtain the model data in the target format and sending the model data in the target format to the main thread.

[0095] Optionally, after the main thread identifies the file type identifier of the lightweight model data file, the main thread can create a sub-thread and send the plurality of model data in the lightweight model data file to the sub-thread for parsing and processing by the sub-thread.

[0096] Optionally, the main thread can create a preset number of sub-threads to parse and process the model data, or can create a number of sub-threads equal to the number of models in the lightweight model data file to parse and process each model data respectively to obtain the model data in the target format and send the model data in the target format to the main thread.

[0097] Optionally, the sub-thread can convert the model data into data in the target format, i.e., key-value pair format data. For example, the sub-thread can convert node data, mesh data, material data, map data, and animation data into a JSON object and send the converted data to the main thread.

[0098] In the embodiments of the present application, the main thread creates a sub-thread, the sub-thread parses and converts each model data to obtain the model data in the target format, and the model data in the target format is sent to the main thread. The pressure of the main thread on parsing the model data can be distributed to multiple sub-threads, and the loading efficiency of the receiving end device on the model data in the received model file can be improved.

[0099] Next, the step of parsing and converting the lightweight model data file to obtain the model data in the target format is described, as shown in Figure 4 The S302 step includes:

[0100] S401: Read multiple data types from the type record section of the model data according to a preset order and type occupation length.

[0101] Optionally, the preset order can be an arrangement order of data types of the type record section agreed by the receiving end device and the sending end device.

[0102] Optionally, the receiving end device and the sending end device can also agree on a type occupation length, so that the receiving end device can read multiple data types from the type record section of the model data according to the preset order according to the type occupation length.

[0103] For example, assuming that the preset order is node type, mesh type, material type, map type, and animation type, the receiving end device can read the node type, mesh type, material type, map type, and animation type of the model from the type record section of the model data in this order.

[0104] S402: Read data of each data type from the data record section of the model data in order according to the byte code start index and byte code length of the data of each data type recorded in the index and length record section of the model data.

[0105] Optionally, the index and length record section of the model data can record the byte code start index and byte code length of the data of each data type, for example, the byte code start index and byte code length can indicate that the 124-159 bits are mesh type data, and the sub-thread can read the mesh data from the 124-159 bits.

[0106] S403: Group multiple data types and data of each data type into key-value pairs in order, with the key of the key-value pair being the data type and the value being the data of the data type.

[0107] Optionally, after the sub-thread reads the data of each type, it can group multiple data types and data of each data type into key-value pairs in order, for example, {node type: node data} as a group of key-value pairs, wherein the key of the key-value pair is the node type and the value of the key-value pair is the node data.

[0108] S404: Combine each key-value pair into model data in a target format.

[0109] Optionally, after the sub-thread obtains multiple data types and data of each data type to form key-value pairs, it can combine each key-value pair to obtain model data in a target format, for example, each key-value pair can be combined into a JSON object.

[0110] In the embodiment of the present application, after receiving the lightweight model data file, the receiving end device can parse the model data through the created sub-thread, and finally obtain the model data in the target format. Through the sub-thread, the parsing of multiple model data can be realized at the same time, and the efficiency of model parsing is improved.

[0111] Next, the step of generating the lightweight model data file by the sending end device is described. As shown in the following figure, the step includes: Figure 5

[0112] S501: Extract multiple data types and data of each data type from the original model data file. The multiple data types and data of each data type are in the form of key-value pairs.

[0113] Optionally, the original model data file can include multiple original model data in the scene obtained by the receiving end device. Each original model data can include multiple data types and data of each data type.

[0114] For example, the receiving end device obtains the original model data file of scene A, which includes model 1, model 2, model 3, model 4, etc. Therefore, the original model data file can include the original model data of model 1, model 2, model 3, model 4, etc.

[0115] For example, the data types of the model and the data of each data type are in the form of key-value pairs, such as {model 1: {node type: node data}, {mesh type: mesh data}, {texture type: texture data}, {material type: material data}, {animation type: animation data}}. It indicates that the data types of model 1 include node type, mesh type, texture type, material type, and animation type.

[0116] S502: Perform lightweight processing on the extracted data of each data type to obtain lightweight data.

[0117] Optionally, the lightweight processing on the extracted data of each data type can be data lightweight processing on each data type. The lightweight data can have a lower memory occupancy rate than the original data.

[0118] Optionally, the lightweight data and the data types of the original model data can be the same, and only the data of each data type is lightweight processed.

[0119] S503: Recombination processing is performed on the lightweight data to obtain recombined model data, and the recombined model data is saved to the lightweight model data file.

[0120] ​Optionally, the lightweight data is reorganized into a preset format with the data type corresponding to the lightweight data, to obtain reorganized model data.

[0121] Optionally, the reorganized model data is a byte array after the original model data is lightweighted and reorganized.

[0122] It is worth noting that the above lightweighting and reorganizing are only for the model data of one model, the original model data file includes model data of multiple models, and the above lightweighting and reorganizing can be performed on each model data to obtain a lightweight model data file. In the original model data, the model data of each model is stored separately, and after the model data of the model object is lightweighted and reorganized, the reorganized model data can also be reorganized model data for each model object.

[0123] In the embodiments of the present application, the sending end device can perform the above lightweighting and reorganizing on all model data of the scene indicated in the request as the original model data file after receiving the sending request of the receiving end device, to obtain a lightweight model data file, and send the file to the receiving end device. Alternatively, the sending end device can upload all model data of the scene stored to the server, and the server can perform the above lightweighting and reorganizing. After receiving the sending request of the receiving end device, the server directly sends the lightweight model data file corresponding to the scene indicated in the request to the receiving end device, and the receiving end device performs the above analysis and loading process of S201-S203.

[0124] Through the lightweighting and reorganizing of the original model data, the memory size of the model file can be greatly reduced, and higher transmission speed can be obtained in the transmission process.

[0125] Next, the above lightweighting is described in detail. The above lightweighting at least includes the following:

[0126] If the current mesh shares geometry data with other meshes, the current mesh is deleted.

[0127] Optionally, if the current mesh shares geometry data with other meshes, the current mesh is deleted. Specifically, the mesh data in the model data is traversed, and it is sequentially determined whether the current mesh shares the same binary geometry data with other meshes. If yes, the current mesh data is deleted, and the data index referring to the mesh is updated.

[0128] The materials corresponding to the meshes in the model are added to the same set for deduplication, and the materials not referenced by any mesh are deleted from the set.

[0129] Optionally, the materials corresponding to each mesh in the model are added to the same set for deduplication, and the materials not referenced by any mesh are deleted from the set. Specifically, the mesh data in the model data is traversed, the material index corresponding to the mesh is put into a set and deduplicated, and then the material data in the model data is traversed. If the index of a material is not in the set, it means that the material is a redundant material that is not referenced by any mesh, and is directly deleted.

[0130] For a static model, the geometry data of meshes with the same material is merged.

[0131] Optionally, for a static model, the geometry data of meshes with the same material is merged. Specifically, it can be determined whether the current model is a static model according to the parameters provided in the model. If the current model is a static model, the mesh data in the model data is traversed, the mesh data is classified according to the material index, and then the geometry data of meshes with the same material is merged and the original node data is replaced with the merged mesh node data. If the model before merging has a large number of components, the model after merging can greatly reduce the rendering call times and improve the rendering efficiency.

[0132] If the distance between the current vertex and other vertices is less than a preset threshold, the current vertex is deleted.

[0133] Optionally, if the distance between the current vertex and other vertices is less than a preset threshold, the current vertex is deleted. Specifically, the node data in the model data is traversed. If the current node is a Mesh mesh node, the mesh data corresponding to the node is found, the binary vertex data is extracted, and whether the distance between each vertex and other vertices is less than the threshold is judged according to the given vertex welding threshold. If it is less than the threshold, the data of the vertex is deleted, otherwise the next vertex is looped.

[0134] The map data is converted in format.

[0135] Optionally, the map data is converted in format. Specifically, the map data in the model data is traversed, the binary data corresponding to each map is obtained, and then Basis Universal is used to convert it into the map format of KTX2. This format can be directly used by GPU without transcoding, and the file is generally smaller than the general format such as JPG and PNG.

[0136] The animation data is thinned out.

[0137] Optionally, the animation data is thinned out, specifically, animation data in the model data is traversed, binary animation data is extracted according to a binary data index corresponding to frame animation, data that continuously and repeatedly appears is divided into different sets and is thinned out, then the data before thinning out is replaced with the data after thinning out, to form new binary animation data.

[0138] The geometry data is low-precisionized.

[0139] Optionally, the geometry data is low-precisionized, specifically, integer data of low precision or fewer bits is used to replace floating-point type data such as vertices and normals, although precision loss is caused, the method can greatly reduce the storage space of the model while keeping the original shape of the model as much as possible, to balance the precision and size of the model.

[0140] In the embodiments of the present application, the mesh data, material data, node data, map data, animation data and geometry data in the model data are respectively lightweighted, to reduce the memory size of the model data, and compared with the original compressed model data, the method reduces the model storage ratio while retaining the precision of the model to the greatest extent.

[0141] The following is a step description of the reorganization processing in S503, as shown in the following table. Figure 6 As shown in the following table, S503 includes the following steps.

[0142] S601: Traverse multiple data types and key-value pairs corresponding to data of each data type, to extract the multiple data types and the data of each data type.

[0143] Optionally, the multiple data types and the data of each data type can be in the form of key-value pairs, and when reorganization processing is performed, the multiple data types and the data of each data type can be extracted by extracting the keys and values in each key-value pair respectively.

[0144] If the model data is directly serialized into a string form, a lot of storage space will be wasted, therefore, the present application extracts field attribute values from key-value pairs, to greatly save storage space.

[0145] S602: Arrange the data of each data type according to a preset order, to obtain arranged data.

[0146] Optionally, the preset order can be an arrangement order of the data of each data type agreed by the receiving end device and the sending end device, after the arranged data is obtained, the arranged data can be converted into a byte array, and the byte array corresponds to model data of a model object.

[0147] S603: arrange the plurality of data types according to the preset order and type occupation length, to obtain arranged data types.

[0148] Optionally, after arranging the data of each data type according to the preset order, each data type can also be arranged according to the same order, and the type occupation length of each data type can be agreed in advance by the sending end device and the receiving end device.

[0149] S604: determine the byte code starting index and byte code length of the data of each data type according to the arranged data.

[0150] Optionally, after arranging the data of each data type, the length of the arranged data can be used to determine the length of the data of each data type as the byte code length, and the starting position of the arranged data can be determined as the byte code starting index of the data of each data type.

[0151] For example, assuming that the position of the node data in the arranged data is 124-134 bits, the starting index of the node type data can indicate that the position of the node data in the arranged data is 124-134 bits, and the byte code length can indicate that the length of the node data includes 10 bits.

[0152] S605: sequentially concatenate the arranged data types, the byte code starting index and byte code length of the data of each data type, and the arranged data, to obtain reorganized model data.

[0153] Optionally, the arranged data types, the byte code starting index and byte code length of the data of each data type, and the arranged data can be sequentially concatenated, for example, the data of the byte code starting index and the byte code length of each data type can be newly added before the arranged data.

[0154] Optionally, the reorganized model data can be model data obtained by converting the concatenated data into a byte array.

[0155] It is worth noting that the above lightweight processing and reorganization processing can be performed on each model in the original model data file, and a file type identifier can be added to the lightweight model data file formed by all the reorganized model data. The receiving end device will only perform further parsing and loading processing after identifying the file type identifier.

[0156] In the embodiments of the present application, by reorganizing the lightweight model data in the agreed manner, on the one hand, the storage space can be saved, and on the other hand, the receiving end device can also quickly realize data parsing according to the agreed manner, greatly improving the loading efficiency of data in the receiving end device.

[0157] Based on the same inventive concept, the embodiment of the present application also provides a model data processing device corresponding to the model data processing method. Since the principle of the device in the embodiment of the present application solves the problem is similar to the above-mentioned model data processing method of the embodiment of the present application, the implementation of the device can be referred to the implementation of the method, and the repeated parts will not be described here.

[0158] Referring to Figure 7 Fig. 1 is a schematic diagram of a model data processing device provided by the embodiment of the present application, and the device comprises a receiving module 701, an analyzing module 702 and a display module 703, wherein:

[0159] The receiving module 701 is configured to receive a lightweight model data file sent by a sending end device, wherein the lightweight model data file comprises a file type and at least one model data, and each model data comprises a type record segment, an index and length record segment and a data record segment in sequence, wherein the type record segment is configured to record a plurality of data types, the index and length record segment is configured to record a byte code starting index and a byte code length of the data of each data type, and the data record segment is configured to record the data of each data type.

[0160] The analyzing module 702 is configured to analyze and convert the lightweight model data file to obtain data in a target format, wherein the target format comprises a key-value pair format.

[0161] The display module 703 is configured to render the data in the target format to display a target model.

[0162] Optionally, the analyzing module 702 is further configured to:

[0163] determine whether to perform lightweight analysis according to the file type in the lightweight model data file by the main thread;

[0164] if yes, create an analysis sub-thread from the main thread, send each model data to the sub-thread by the main thread, and analyze and convert each model data by the sub-thread to obtain model data in the target format, and send the model data in the target format to the main thread.

[0165] Optionally, the analyzing module 702 is further configured to:

[0166] read a plurality of data types from the type record segment of the model data according to a preset order and type length;

[0167] read the data of each data type from the data record segment of the model data according to the byte code starting index and the byte code length of the data of each data type recorded in the index and length record segment of the model data;

[0168] Multiple data types and their corresponding data are sequentially combined into key-value pairs, where the key of each key-value pair is the data type and the value is the data type itself.

[0169] Combine the key-value pairs into model data in the target format.

[0170] Optionally, the receiving module 701 is also used for:

[0171] A request sub-thread is created from the main thread, and this sub-thread sends a model data acquisition request to the sending device to trigger the sending device to send the lightweight model data file. The processing flow of each module in the device and the interaction flow between them can be found in the relevant descriptions in the above method embodiments, and will not be detailed here.

[0172] This application embodiment saves storage space occupied by model data by using lightweight model data files. At the same time, multiple child threads are created by the main thread to parse the received lightweight model data files, and the child threads return the parsed model data to the main thread for rendering. This can improve the efficiency of model parsing and loading in the browser, and the model loading effect is particularly significant for large scenes.

[0173] This application also provides an electronic device, such as... Figure 8 The diagram shown is a schematic representation of an electronic device structure provided in an embodiment of this application, including: a processor 81, a memory 82, and a bus. The memory 82 stores machine-readable instructions executable by the processor 81 (e.g., ...). Figure 7 The device includes a receiving module 701, a parsing module 702, and a display module 703 (corresponding to execution instructions, etc.). When the computer device is running, the processor 81 communicates with the memory 82 via a bus. When the machine-readable instructions are executed by the processor 81, the above-mentioned model data processing method is performed.

[0174] This application also provides a computer-readable storage medium storing a computer program, which, when run by a processor, executes the steps of the above-described model data processing method.

[0175] Those skilled in the art can clearly understand the specific working process of the system and the device described above for the convenience and brevity of description, which can refer to the corresponding process in the method embodiment, and will not be repeated in the present application. In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented by other ways. The device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and actual implementation can have another division manner, for example, a plurality of modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be indirect coupling or communication connection through some communication interface, device or module, which can be electrical, mechanical or other forms.

[0176] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. When the functions are realized in the form of software functional units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or say the part of the prior art or the part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various program code storage media.

[0177] The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application.

Claims

1. A model data processing method characterized by, The method comprises the following steps: receiving a lightweight model data file sent by a sending terminal device, the lightweight model data file comprising a file type and at least one model data, each model data comprising a type record segment, an index and length record segment and a data record segment in sequence, wherein the type record segment is used for recording a plurality of data types, the index and length record segment is used for recording a byte code starting index and a byte code length of data of each data type, and the data record segment is used for recording data of each data type; determining whether to perform lightweight analysis according to the file type in the lightweight model data file by a main thread; if yes, creating a preset number of sub-threads for analyzing model data from the main thread, sending each model data to the sub-threads by the main thread, and performing analysis and conversion processing on each model data by the sub-threads to obtain model data in a target format, and sending the model data in the target format to the main thread, wherein the target format comprises a key-value pair format; performing rendering according to the data in the target format to display a target model; the lightweight model data file is generated by the sending terminal device through the following steps: extracting a plurality of data types and data of each data type from an original model data file, wherein the plurality of data types and data of each data type are in the form of key-value pairs; performing lightweight processing on the extracted data of each data type to obtain lightweight data; performing reorganization processing on the lightweight data to obtain reorganized model data, and saving the reorganized model data to the lightweight model data file; the reorganization processing comprises: traversing the key-value pairs corresponding to the plurality of data types and data of each data type to extract the plurality of data types and data of each data type; arranging the data of each data type in a preset order to obtain arranged data; arranging the plurality of data types in a preset order and type length to obtain arranged data types; determining the byte code starting index and the byte code length of the data of each data type according to the arranged data; concatenating the arranged data types, the byte code starting index and the byte code length of the data of each data type, and the arranged data in sequence to obtain the reorganized model data.

2. The method of claim 1, wherein, The analysis and conversion processing of each model data by the sub-threads to obtain model data in a target format comprises: reading a plurality of data types from the type record segment of the model data according to a preset order and type length; reading data of each data type from the data record segment of the model data according to the byte code starting index and the byte code length of the data of each data type recorded in the index and length record segment of the model data; composing key-value pairs in sequence from the plurality of data types and the data of each data type, wherein the key of the key-value pair is the data type, and the value is the data of the data type; combining each key-value pair into model data in the target format.

3. The method of claim 1, wherein, The lightweight processing comprises at least one of the following: if the current grid shares geometry data with other grids, deleting the current grid; Add the materials corresponding to each mesh in the model to the same set for deduplication, and delete the materials not referenced by any mesh from the set; For static models, merge the geometry data of meshes with the same material; If the distance between the current vertex and other vertices is less than a preset threshold, delete the current vertex; Format conversion is performed on the map data; The animation data is thinned out; The geometry data is low-precision.

4. A model data processing apparatus characterized by comprising: The method comprises the following steps: receiving a lightweight model data file sent by a sending end device, wherein the lightweight model data file comprises a file type and at least one model data, each model data comprises a type record segment, an index and length record segment and a data record segment in sequence, the type record segment is used for recording a plurality of data types, the index and length record segment is used for recording the byte code starting index and byte code length of the data of each data type, and the data record segment is used for recording the data of each data type; determining whether to perform lightweight analysis according to the file type in the lightweight model data file by a main thread; if yes, creating an analysis sub-thread from the main thread, sending each model data to the sub-thread by the main thread, and performing analysis and conversion processing on each model data by the sub-thread to obtain model data in a target format, and sending the model data in the target format to the main thread, wherein the target format comprises a key-value pair format; displaying a target model according to the data in the target format; The lightweight model data file is generated by the sending end device through the following steps: extracting a plurality of data types and data of each data type from an original model data file, wherein the plurality of data types and data of each data type are in the form of a key-value pair; performing lightweight processing on the extracted data of each data type to obtain lightweight data; performing reorganization processing on the lightweight data to obtain reorganized model data, and saving the reorganized model data to the lightweight model data file; the reorganization processing comprises: traversing the key-value pairs corresponding to the plurality of data types and data of each data type, and extracting the plurality of data types and data of each data type; arranging the data of each data type in a preset order to obtain arranged data; arranging the plurality of data types in a preset order and type length to obtain arranged data types; determining the byte code starting index and byte code length of the data of each data type according to the arranged data; concatenating the arranged data types, the byte code starting index and byte code length of the data of each data type, and the arranged data in sequence to obtain the reorganized model data.

5. An electronic device, comprising: The method comprises the following steps: a processor, a storage medium and a bus, the storage medium stores program instructions executable by the processor, when the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the program instructions to execute the steps of the model data processing method in any one of claims 1 to 3.

6. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is run by the processor to execute the steps of the model data processing method in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Lightweight application method and system based on FBX model

    CN114638121A