Model loading method and device, storage medium and electronic device
By obtaining the shrinkage cost of the edges of the 3D mesh model and iterative optimization, the problem of long loading time of the 3D mesh model was solved, a faster loading process was achieved, and the user experience was improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NEUSOFT CORP
- Filing Date
- 2022-08-16
- Publication Date
- 2026-07-21
Smart Images

Figure CN115359211B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more specifically, to a model loading method, apparatus, storage medium, and electronic device. Background Technology
[0002] With the continuous development of computer hardware and software technology and the increasing popularity of augmented reality, virtual reality, and mixed reality, the demand for 3D modeling is increasing exponentially. The structure of 3D mesh models is also becoming more and more complex, which results in a large amount of data in 3D mesh model files. When loading data for web pages containing 3D mesh models, the loading of 3D mesh model files takes a long time, so a long waiting time is often required to complete the recording of web page data, which is not conducive to improving the user experience. Summary of the Invention
[0003] The purpose of this disclosure is to provide a model loading method, apparatus, storage medium, and electronic device.
[0004] To achieve the above objectives, the first aspect of this disclosure provides a model loading method, the method comprising:
[0005] In response to receiving a loading instruction for a target webpage, if it is determined that the target webpage includes a specified three-dimensional mesh model to be loaded, then the shrinkage cost value of each edge in the specified three-dimensional mesh model is obtained to obtain an initial cost value set, wherein the shrinkage cost value is used to characterize the geometric error that shrinkage will produce.
[0006] The edges to be optimized in the specified three-dimensional mesh model are determined based on the initial set of values.
[0007] The edges to be optimized are collapsed to obtain the updated current 3D mesh model;
[0008] Determine the shrinkage cost of newly added edges in the current 3D mesh model to obtain at least one set of newly added cost values;
[0009] The current 3D mesh model is iteratively optimized based on the initial generation value set and the at least one newly added generation value set to obtain an optimized target 3D mesh model, and the target 3D mesh model is loaded as the loading data of the target webpage.
[0010] Optionally, determining the shrinkage cost of newly added edges in the current 3D mesh model to obtain at least one set of newly added cost values includes:
[0011] Get the target number of new edges;
[0012] If the target number is greater than a preset threshold, the shrinkage cost corresponding to the newly added edges of the target number is divided into multiple groups, each group corresponding to a set of newly added cost values, to obtain multiple sets of newly added cost values; or,
[0013] When the target number is less than or equal to the preset number threshold, a new generation value set is generated, and the shrinkage generation value corresponding to the new edge of the target number is an element in the new generation value set.
[0014] Optionally, the step of iteratively optimizing the current 3D mesh model based on the initial generation value set and the at least one newly added generation value set to obtain an optimized target 3D mesh model includes:
[0015] Identify the specified edges in the given 3D mesh model that are adjacent to the edge to be optimized;
[0016] Remove the shrinkage value of the specified edge from the initial value set to obtain an updated initial value set;
[0017] The current 3D mesh model is iteratively optimized based on the at least one newly added value set and the updated initial value set to obtain the target 3D mesh model.
[0018] Optionally, the step of iteratively optimizing the current 3D mesh model based on the at least one newly added set of generation values and the updated initial set of generation values to obtain the target 3D mesh model includes:
[0019] Determine the minimum shrinkage value in each of the newly added generation value sets to obtain at least one first shrinkage value, and determine the minimum shrinkage value in the updated initial generation value set to obtain a second shrinkage value.
[0020] The target shrinkage edge is determined based on at least one first shrinkage generation value and the second shrinkage generation value;
[0021] The current 3D mesh model is collapsed based on the target shrinkage edge to obtain an updated current 3D mesh model;
[0022] Determine the ratio of the number of planes in the updated current 3D mesh model to the number of planes in the specified 3D mesh model;
[0023] Determine whether the ratio is greater than a preset ratio threshold;
[0024] If the ratio is determined to be greater than the preset ratio threshold, the current initial generation value set is updated according to the target shrinkage edge, and the shrinkage generation value of the newly added edge in the updated current 3D mesh model is determined to update the current at least one new generation value set, and the step of determining the minimum shrinkage generation value in each new generation value set is performed again to obtain at least one first shrinkage generation value, until the step of determining whether the ratio is greater than the preset ratio threshold is reached.
[0025] If the ratio is determined to be less than or equal to the preset ratio threshold, the current three-dimensional mesh model is used as the target three-dimensional mesh model.
[0026] Optionally, determining the target shrinkage edge based on the at least one first shrinkage value and the second shrinkage value includes:
[0027] Determine the target shrinkage value that is the minimum of the at least one first shrinkage value and the second shrinkage value;
[0028] Determine a first target distance between the midpoint of each edge corresponding to the first shrinkage cost value and the midpoint of the edge corresponding to the target shrinkage cost value, and a second target distance between the midpoint of each edge corresponding to the second shrinkage cost value and the midpoint of the edge corresponding to the target shrinkage cost value.
[0029] The edge whose first target distance is greater than or equal to the preset side length threshold is taken as the target shrinkage edge, and when the second target distance is greater than or equal to the preset side length threshold, the edge corresponding to the second shrinkage cost value is taken as the target shrinkage edge, so as to obtain one or more target shrinkage edges.
[0030] Optionally, determining the target shrinkage edge based on the at least one first shrinkage value and the second shrinkage value includes:
[0031] The edge corresponding to the smallest specified number of shrinkage values among the at least one first shrinkage value and the second shrinkage value is taken as the target shrinkage edge.
[0032] Optionally, determining the shrinkage cost of newly added edges in the updated current 3D mesh model to update the current set of at least one set of newly added costs includes:
[0033] For each newly added edge in the updated current 3D mesh model, the following update strategy is executed to update the current set of at least one newly added edge values;
[0034] The update strategy includes:
[0035] Obtain the number of elements in each of the newly added value sets;
[0036] If it is determined that there exists a specified set of newly added value values where the number of elements is less than or equal to a preset threshold, the shrinkage value of the newly added edge is added to the specified set of newly added value values.
[0037] If it is determined that the specified set of newly added values does not exist, a target set of newly added values is generated, and the shrinkage value of the currently added edge is added to the target set of newly added values.
[0038] Optionally, the edges to be optimized are subjected to collapse processing to obtain an updated current 3D mesh model, including:
[0039] Determine the target point corresponding to the edge to be optimized, where the target point is the point on the edge to be optimized that minimizes the sum of the squared distances to the adjacent faces of the edge to be optimized;
[0040] Delete the edge to be optimized, as well as the edges connected to the edge to be optimized;
[0041] Connect the target point to the adjacent points of the endpoint of the edge to be optimized to obtain the current three-dimensional mesh model.
[0042] A second aspect of this disclosure provides a model loading apparatus, the apparatus comprising:
[0043] The first determining module is configured to, in response to receiving a loading instruction for a target webpage, if it is determined that the target webpage includes a specified three-dimensional mesh model to be loaded, obtain the shrinkage cost value of each edge in the specified three-dimensional mesh model to obtain an initial cost value set, wherein the shrinkage cost value is used to characterize the geometric error that shrinkage will produce.
[0044] The second determining module is configured to determine the edges to be optimized in the specified three-dimensional mesh model based on the initial cost set;
[0045] The third determining module is configured to perform collapse processing on the edge to be optimized in order to obtain the updated current three-dimensional mesh model;
[0046] The fourth determining module is configured to determine the shrinkage cost of newly added edges in the current three-dimensional mesh model to obtain at least one set of newly added cost values.
[0047] The fifth determining module is configured to iteratively optimize the current three-dimensional mesh model based on the initial generation value set and the at least one newly added generation value set to obtain an optimized target three-dimensional mesh model, and load the target three-dimensional mesh model as the loading data of the target webpage.
[0048] Optionally, the fourth determining module is configured to:
[0049] Get the target number of new edges;
[0050] If the target number is greater than a preset threshold, the shrinkage cost corresponding to the newly added edges of the target number is divided into multiple groups, each group corresponding to a set of newly added cost values, to obtain multiple sets of newly added cost values; or,
[0051] When the target number is less than or equal to the preset number threshold, a new generation value set is generated, and the shrinkage generation value corresponding to the new edge of the target number is an element in the new generation value set.
[0052] Optionally, the fifth determining module is configured as follows:
[0053] Identify the specified edges in the given 3D mesh model that are adjacent to the edge to be optimized;
[0054] Remove the shrinkage value of the specified edge from the initial value set to obtain an updated initial value set;
[0055] The current 3D mesh model is iteratively optimized based on the at least one newly added value set and the updated initial value set to obtain the target 3D mesh model.
[0056] Optionally, the fifth determining module is configured as follows:
[0057] Determine the minimum shrinkage value in each of the newly added generation value sets to obtain at least one first shrinkage value, and determine the minimum shrinkage value in the updated initial generation value set to obtain a second shrinkage value.
[0058] The target shrinkage edge is determined based on at least one first shrinkage generation value and the second shrinkage generation value;
[0059] The current 3D mesh model is collapsed based on the target shrinkage edge to obtain an updated current 3D mesh model;
[0060] Determine the ratio of the number of planes in the updated current 3D mesh model to the number of planes in the specified 3D mesh model;
[0061] Determine whether the ratio is greater than a preset ratio threshold;
[0062] If the ratio is determined to be greater than the preset ratio threshold, the current initial generation value set is updated according to the target shrinkage edge, and the shrinkage generation value of the newly added edge in the updated current 3D mesh model is determined to update the current at least one new generation value set, and the step of determining the minimum shrinkage generation value in each new generation value set is performed again to obtain at least one first shrinkage generation value, until the step of determining whether the ratio is greater than the preset ratio threshold is reached.
[0063] If the ratio is determined to be less than or equal to the preset ratio threshold, the current three-dimensional mesh model is used as the target three-dimensional mesh model.
[0064] Optionally, the fifth determining module is configured as follows:
[0065] Determine the target shrinkage value that is the minimum of the at least one first shrinkage value and the second shrinkage value;
[0066] Determine a first target distance between the midpoint of each edge corresponding to the first shrinkage cost value and the midpoint of the edge corresponding to the target shrinkage cost value, and a second target distance between the midpoint of each edge corresponding to the second shrinkage cost value and the midpoint of the edge corresponding to the target shrinkage cost value.
[0067] The edge whose first target distance is greater than or equal to the preset side length threshold is taken as the target shrinkage edge, and when the second target distance is greater than or equal to the preset side length threshold, the edge corresponding to the second shrinkage cost value is taken as the target shrinkage edge, so as to obtain one or more target shrinkage edges.
[0068] Optionally, the fifth determining module is configured as follows:
[0069] The edge corresponding to the smallest specified number of shrinkage values among the at least one first shrinkage value and the second shrinkage value is taken as the target shrinkage edge.
[0070] Optionally, the fifth determining module is configured as follows:
[0071] For each newly added edge in the updated current 3D mesh model, the following update strategy is executed to update the current set of at least one newly added edge values;
[0072] The update strategy includes:
[0073] Obtain the number of elements in each of the newly added value sets;
[0074] If it is determined that there exists a specified set of newly added value values where the number of elements is less than or equal to a preset threshold, the shrinkage value of the newly added edge is added to the specified set of newly added value values.
[0075] If it is determined that the specified set of newly added values does not exist, a target set of newly added values is generated, and the shrinkage value of the currently added edge is added to the target set of newly added values.
[0076] Optionally, the third determining module is configured to:
[0077] Determine the target point corresponding to the edge to be optimized, where the target point is the point on the edge to be optimized that minimizes the sum of the squared distances to the adjacent faces of the edge to be optimized;
[0078] Delete the edge to be optimized, as well as the edges connected to the edge to be optimized;
[0079] Connect the target point to the adjacent points of the endpoint of the edge to be optimized to obtain the current three-dimensional mesh model.
[0080] A third aspect of this disclosure provides a non-transitory computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of the method described in the first aspect above.
[0081] A fourth aspect of this disclosure provides an electronic device comprising:
[0082] A memory on which computer programs are stored;
[0083] A processor for executing the computer program in the memory to implement the steps of the method described in the first aspect above.
[0084] The above technical solution, in response to a received loading instruction for a target webpage, if it is determined that the target webpage includes a specified 3D mesh model to be loaded, obtains the shrinkage cost of each edge in the specified 3D mesh model to obtain an initial cost set; determines the edges to be optimized in the specified 3D mesh model based on the initial cost set; performs collapse processing on the edges to be optimized to obtain an updated current 3D mesh model; determines the shrinkage cost of newly added edges in the current 3D mesh model to obtain at least one new cost set; iteratively optimizes the current 3D mesh model based on the initial cost set and the at least one new cost set to obtain an optimized target 3D mesh model, and loads the target 3D mesh model as loading data for the target webpage. Thus, by iteratively optimizing the current 3D mesh model based on the initial cost set and the at least one new cost set, the model simplification efficiency can be effectively improved. By loading the optimized target 3D mesh model to load the specified 3D mesh model data for the target webpage, the loading time of the target webpage can be effectively shortened, thereby effectively improving the user experience.
[0085] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0086] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the following detailed description to explain the present disclosure, but do not constitute a limitation thereof. In the drawings:
[0087] Figure 1 This is a flowchart illustrating a model loading method according to an exemplary embodiment of this disclosure;
[0088] Figure 2 Based on this disclosure Figure 1 The illustrated embodiment shows a flowchart of a model loading method;
[0089] Figure 3 Based on this disclosure Figure 1 The illustrated embodiment shows a flowchart of another model loading method;
[0090] Figure 4 Based on this disclosure Figure 1 The illustrated embodiment shows a flowchart of yet another model loading method;
[0091] Figure 5 This is a block diagram of a model loading apparatus shown in an exemplary embodiment of the present disclosure;
[0092] Figure 6This is a block diagram illustrating an electronic device according to an exemplary embodiment;
[0093] Figure 7 This is a block diagram illustrating another electronic device according to an exemplary embodiment. Detailed Implementation
[0094] The specific embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit this disclosure.
[0095] Before detailing the specific implementation methods of this disclosure, the application scenarios of this disclosure are first explained as follows: This disclosure can be applied to scenarios where the 3D mesh model in a webpage is simplified to reduce the amount of 3D mesh model data to be loaded and improve the model loading speed. The simplification of 3D mesh models in related technologies typically includes: reducing the number of faces, UV unwrapping, baking, etc. The inventors have found that the optimization methods in related technologies, when the number of faces in the model reaches a certain level, cannot meet the needs of actual work, and the optimization process still takes a long time, which is not conducive to shortening the model loading time and thus not conducive to improving the user experience.
[0096] To address the aforementioned technical problems, this disclosure provides a model loading method, apparatus, storage medium, and electronic device. The model loading method, in response to receiving a loading instruction for a target webpage, if it is determined that the target webpage includes a specified 3D mesh model to be loaded, obtains the shrinkage cost value of each edge in the specified 3D mesh model to obtain an initial cost value set. By iteratively optimizing the current 3D mesh model based on the initial cost value set and at least one newly added cost value set, the model simplification efficiency can be effectively improved. By loading the optimized target 3D mesh model to load the specified 3D mesh model data from the target webpage, the loading time of the target webpage can be effectively shortened, thereby effectively improving the user experience.
[0097] Figure 1 This is a flowchart illustrating a model loading method according to an exemplary embodiment of this disclosure; as follows: Figure 1 As shown, the method may include:
[0098] Step 101: In response to receiving a loading instruction for the target webpage, if it is determined that the target webpage includes a specified three-dimensional mesh model to be loaded, then the shrinkage cost of each edge in the specified three-dimensional mesh model is obtained to obtain an initial cost set.
[0099] The shrinkage cost value is used to characterize the geometric error that shrinkage will produce. In this step, each element in the initial cost value set (i.e., the shrinkage cost value of each edge) can be stored in the storage space corresponding to variable C.
[0100] It should be noted that the calculation process for the shrinkage cost of this edge is as follows: If the two endpoints of an edge are V1 and V2, the quadratic metric error generated by shrinking V1 is QEM(V1), and the quadratic metric error generated by shrinking V2 is QEM(V2). Then the shrinkage cost of this edge is QEM(V1) + QEM(V2). QEM(V1) can be obtained by calculating the sum of squared distances from endpoint V1 to all triangular faces in its neighborhood (also called associated planes, the planes containing the endpoint); QEM(V2) can be obtained by calculating the sum of squared distances from endpoint V2 to all triangular faces in its neighborhood.
[0101] Step 102: Determine the edges to be optimized in the specified 3D mesh model based on the initial value set.
[0102] In this step, the elements (data in variable C) in the initial value set can be arranged in descending (or ascending) order to obtain ordered variable C0. The edge corresponding to the smallest preset number of cost contraction values in ordered variable C0 is taken as the edge to be optimized.
[0103] For example, if the preset quantity is 1, then the edge corresponding to the minimum shrinkage value in the initial value set is taken as the edge to be optimized in the specified 3D mesh model. If the preset quantity is 2, then the edge corresponding to the minimum shrinkage value and the edge corresponding to the second smallest shrinkage value in the initial value set are taken as the edge to be optimized in the specified 3D mesh model.
[0104] Step 103: Collapse the edge to be optimized to obtain the updated current 3D mesh model.
[0105] In this step, the target point corresponding to the edge to be optimized is determined. The target point is a point on the edge to be optimized, and the sum of the squared distances between the target point and the adjacent faces of the edge to be optimized is minimized. The edge to be optimized, as well as the edges connected to it, are deleted. The target point is connected to the adjacent points of the endpoints of the edge to be optimized to obtain the current 3D mesh model. The adjacent face is the associated plane of the endpoint of the edge to be optimized, which is the plane containing the endpoint. The adjacent point is a vertex that shares an edge or ridge with the original vertex (i.e., the endpoint of the edge to be optimized). For example, in a square with vertices ABCD, AB and AD are adjacent vertices.
[0106] Step 104: Determine the shrinkage cost of the newly added edges in the current 3D mesh model to obtain at least one set of newly added cost values.
[0107] The newly added edge is the edge added to the current 3D mesh model compared to the 3D mesh model before the edge to be optimized was collapsed; that is, the line connecting the target point and the adjacent point.
[0108] In this step, the target number of new edges can be obtained; if the target number is greater than a preset threshold, the shrinkage value corresponding to the new edge of the target number is divided into multiple groups, each group corresponding to a set of new values, so as to obtain multiple sets of new values; or, if the target number is less than or equal to the preset threshold, a set of new values is generated, and the shrinkage value corresponding to the new edge of the target number is an element in the set of new values.
[0109] For example, if the number of newly added edges in the current 3D mesh model is N, when storing the shrinkage cost of these newly added edges into multiple sets of new cost values, the shrinkage cost values corresponding to the 1st to nth edges can be stored as one set of new cost values in variable C1, the shrinkage cost values corresponding to the (n+1)th to 2nth edges can be stored as one set of new cost values in variable C2, and so on, until the shrinkage cost value corresponding to the Nth newly added edge is stored in the corresponding set of new cost values. When n is less than or equal to N, multiple sets of new cost values will be generated; when n is greater than N, only one set of new cost values will be generated.
[0110] It should be noted that this preset quantity threshold can be b. s ,Should Where t e To specify the total number of edges in a 3D mesh model, the number of sets of at least one newly added cost value set is less than or equal to b. n ,
[0111] Step 105: Iteratively optimize the current 3D mesh model based on the initial generation value set and the at least one newly added generation value set to obtain the optimized target 3D mesh model, and load the target 3D mesh model as the loading data of the target webpage.
[0112] The above technical solution, by iteratively optimizing the current 3D mesh model based on the initial generation value set and the at least one newly added generation value set, can effectively improve the model simplification efficiency. By loading the optimized target 3D mesh model, the loading time of the specified 3D mesh model data in the target webpage can be effectively shortened, thereby effectively improving the user experience.
[0113] Figure 2 Based on this disclosure Figure 1The illustrated embodiment presents a flowchart of a model loading method; as shown in the figure. Figure 2 As shown, Figure 1 The iterative optimization of the current 3D mesh model based on the initial generation value set and the at least one newly added generation value set, as described in step 105, to obtain the optimized target 3D mesh model, may include:
[0114] Step 1051: Determine the specified edge in the specified 3D mesh model that is adjacent to the edge to be optimized.
[0115] It should be noted that when the two endpoints of the edge to be optimized are points A and B, in the specified 3D mesh model, the specified edge adjacent to the edge to be optimized is an edge with either endpoint A or point B.
[0116] Step 1052: Remove the shrinkage value of the specified edge from the initial value set to obtain the updated initial value set.
[0117] During the collapse process, the specified edge will be deleted, meaning it will not be included in the current 3D mesh model. Therefore, the shrinkage cost of the specified edge needs to be deleted to obtain the initial cost set corresponding to the current 3D mesh model (i.e., to obtain the updated initial cost set).
[0118] Step 1053: Iteratively optimize the current 3D mesh model based on the at least one newly added generation value set and the updated initial generation value set to obtain the target 3D mesh model.
[0119] This step can be done through... Figure 3 Implement the steps shown in S1 to S7. Figure 3 Based on this disclosure Figure 1 The illustrated embodiment shows a flowchart of another model loading method; as shown Figure 3 As shown, step 1053 above may include:
[0120] S1, determine the minimum shrinkage value in each of the newly added generation value sets to obtain at least one first shrinkage value, and determine the minimum shrinkage value in the updated initial generation value set to obtain a second shrinkage value.
[0121] For example, each newly added cost value set is stored in the storage space corresponding to a variable. For instance, the first newly added cost value set is stored in variable C1, the second newly added cost value set is stored in variable C2, and the m-th newly added cost value set is stored in variable Cm. Then, the minimum shrinkage cost value among variables C1 to Cm is obtained to obtain m first shrinkage cost values. And the minimum shrinkage cost value is determined from the updated initial cost value set (i.e., the set of shrinkage cost values corresponding to each edge in the current 3D mesh model) to obtain the second shrinkage cost value.
[0122] S2, determine the target shrinkage edge based on the at least one first shrinkage value and the second shrinkage value.
[0123] In this step, one possible implementation is to use the edge corresponding to the smallest specified number of shrinkage values among the at least one first shrinkage value and the second shrinkage value as the target shrinkage edge.
[0124] For example, sort the m first shrinkage costs and the second shrinkage costs in ascending (or descending) order. If the specified number is 5, then the edges corresponding to the 5 smallest shrinkage costs are taken as the target shrinkage edges.
[0125] Another possible implementation is as follows Figure 4 As shown, Figure 4 Based on this disclosure Figure 1 The flowchart of another model loading method shown in the embodiment illustrates that S2 may include:
[0126] S21, determine the target shrinkage value that is the smallest of the at least one first shrinkage value and the second shrinkage value.
[0127] S22, determine the first target distance between the midpoint of each edge corresponding to the first contraction cost value and the midpoint of the edge corresponding to the target contraction cost value, and the second target distance between the midpoint of each edge corresponding to the second contraction cost value and the midpoint of the edge corresponding to the target contraction cost value.
[0128] For example, the minimum shrinkage cost among the m first shrinkage cost values and the second shrinkage cost value is taken as the target shrinkage cost value. If the edge corresponding to the target shrinkage cost value is e... min The edge corresponding to the first contraction cost value is represented by e. i Let i∈(1,m), and the edge corresponding to the second contraction cost value be represented by e. z This means that the distance to the first target can be expressed as distance(e i e min This means that the distance to the second target can be represented as distance(e). z emin ).
[0129] S23, the edge whose first target distance is greater than or equal to the preset side length threshold is taken as the target shrinkage edge, and when the second target distance is greater than or equal to the preset side length threshold, the edge corresponding to the second shrinkage cost value is taken as the target shrinkage edge, so as to obtain one or more target shrinkage edges.
[0130] The preset side length threshold can be twice the minimum side length, where the minimum side is the side corresponding to the target shrinkage cost value.
[0131] For example, if the target shrinkage edge is e set This indicates that the e set Conditions met:
[0132] {e set |distance(e x e min )≥2le min ,e x ∈e}
[0133] Where e is (e1, e2, ... e) i …e m ,e z That is, e is the set of edges with the current minimum cost.
[0134] Through the steps shown in S21 to S23 above, by setting a preset side length threshold, at least one target shrinkage edge greater than or equal to the preset side length threshold can be obtained. By collapsing the target shrinkage edge, the specified three-dimensional mesh model can be optimized. This can effectively avoid the loss of model structure due to excessively concentrated collapse of multiple edges. Thus, it can not only effectively improve the efficiency of model simplification, but also retain more model structure.
[0135] S3, based on the target shrinkage edge, perform collapse processing on the current 3D mesh model to obtain the updated current 3D mesh model.
[0136] In this step, for each target shrinkage edge, a replacement point corresponding to the target shrinkage edge can be determined, and the sum of the squared distances between the replacement point and the adjacent face of the target shrinkage edge is minimized; the target shrinkage edge and the edges connected to the target shrinkage edge are deleted; the replacement point is connected to the adjacent point of the endpoint of the target shrinkage edge to obtain the updated current 3D mesh model.
[0137] S4, determine the ratio of the number of planes in the updated current 3D mesh model to the number of planes in the specified 3D mesh model.
[0138] S5, determine whether the ratio is greater than the preset ratio threshold.
[0139] In this step, if it is determined that the ratio is greater than the preset ratio threshold, step S6 is executed; if it is determined that the ratio is less than or equal to the preset ratio threshold, step S7 is executed.
[0140] For example, if the current 3D mesh model contains t1 planes, specify the number of planes in the 3D mesh model as t. e The ratio obtained in S4 is The preset ratio threshold is greater than 0 and less than 1. The larger the preset ratio threshold, the fewer the total number of edges that need to be optimized, and the lower the simplification level of the target 3D mesh model.
[0141] S6, update the current initial generation value set according to the target shrinkage edge, and determine the shrinkage generation value of the newly added edge in the updated current 3D mesh model, so as to update the current at least one new generation value set.
[0142] In this step, the following update strategy can be executed for the shrinkage cost of each newly added edge in the updated current 3D mesh model to update the current set of at least one newly added cost;
[0143] The update strategy includes:
[0144] Get the number of elements in each of the newly added value sets;
[0145] If it is determined that there exists a set of specified new value values where the number of elements is less than or equal to a preset threshold, the shrinkage value of the newly added edge is added to the set of specified new value values.
[0146] If it is determined that the specified set of newly added values does not exist, a target set of newly added values is generated, and the shrinkage value of the currently added edge is added to this target set of newly added values. This target set of newly added values is a newly added set.
[0147] It should be noted that this preset quantity threshold can be b. s ,Should Where t e To specify the total number of edges in a 3D mesh model, the number of sets of at least one newly added cost value set is less than or equal to b. n ,
[0148] S7, use the current 3D mesh model as the target 3D mesh model.
[0149] By following the steps shown in S1 to S7, the simplification efficiency of the specified 3D mesh model can be greatly improved. By loading the optimized target 3D mesh model, the loading time of the specified 3D mesh model data in the target webpage can be effectively shortened, thereby effectively improving the user experience.
[0150] Figure 5 This is a block diagram of a model loading apparatus shown in an exemplary embodiment of this disclosure; as follows: Figure 5 As shown, the device may include:
[0151] The first determining module 501 is configured to, in response to receiving a loading instruction for a target webpage, if it is determined that the target webpage includes a specified three-dimensional mesh model to be loaded, obtain the shrinkage cost value of each edge in the specified three-dimensional mesh model to obtain an initial cost value set, wherein the shrinkage cost value is used to characterize the geometric error that shrinkage will produce.
[0152] The second determining module 502 is configured to determine the edges to be optimized in the specified three-dimensional mesh model based on the initial cost set;
[0153] The third determining module 503 is configured to perform a collapse process on the edge to be optimized in order to obtain an updated current three-dimensional mesh model;
[0154] The fourth determining module 504 is configured to determine the shrinkage cost of newly added edges in the current 3D mesh model to obtain at least one set of newly added cost values.
[0155] The fifth determining module 505 is configured to iteratively optimize the current three-dimensional mesh model based on the initial generation value set and the at least one newly added generation value set to obtain an optimized target three-dimensional mesh model, and load the target three-dimensional mesh model as the loading data of the target webpage.
[0156] The above technical solution, by iteratively optimizing the current 3D mesh model based on the initial generation value set and the at least one newly added generation value set, can effectively improve the model simplification efficiency. By loading the optimized target 3D mesh model, the loading time of the specified 3D mesh model data in the target webpage can be effectively shortened, thereby effectively improving the user experience.
[0157] Optionally, the fourth determining module 504 is configured to:
[0158] Get the target number of new edges;
[0159] If the target number exceeds a preset threshold, the shrinkage cost corresponding to the newly added edge of that target number is divided into multiple groups, each group corresponding to a set of newly added cost values, to obtain multiple sets of newly added cost values; or,
[0160] If the target quantity is less than or equal to the preset quantity threshold, a new set of generation values is generated, and the shrinkage generation value corresponding to the new edge of the target quantity is an element in the new set of generation values.
[0161] Optionally, the fifth determining module 505 is configured as follows:
[0162] Identify the specified edges in the given 3D mesh model that are adjacent to the edge to be optimized;
[0163] Remove the shrinkage value of the specified edge from the initial value set to obtain the updated initial value set;
[0164] The current 3D mesh model is iteratively optimized based on the at least one newly added set of generation values and the updated initial set of generation values to obtain the target 3D mesh model.
[0165] Optionally, the fifth determining module 505 is configured as follows:
[0166] Determine the minimum shrinkage value in each of the newly added generation value sets to obtain at least one first shrinkage value, and determine the minimum shrinkage value in the updated initial generation value set to obtain a second shrinkage value.
[0167] The target contraction edge is determined based on the at least one first contraction value and the second contraction value;
[0168] The current 3D mesh model is collapsed based on the target shrinkage edge to obtain an updated current 3D mesh model;
[0169] Determine the ratio of the number of planes in the updated current 3D mesh model to the number of planes in the specified 3D mesh model;
[0170] Determine whether the ratio is greater than the preset ratio threshold;
[0171] If the ratio is determined to be greater than the preset ratio threshold, the current initial value set is updated according to the target shrinkage edge, and the shrinkage value of the newly added edge in the updated current 3D mesh model is determined to update the current at least one set of newly added values. The step of determining the minimum shrinkage value in each set of newly added values is performed again to obtain at least one first shrinkage value until the step of determining whether the ratio is greater than the preset ratio threshold is reached.
[0172] If the ratio is determined to be less than or equal to the preset ratio threshold, the current 3D mesh model is taken as the target 3D mesh model.
[0173] Optionally, the fifth determining module 505 is configured as follows:
[0174] Determine the minimum specified number of contraction generation values among the at least one first contraction generation value and the second contraction generation value;
[0175] Determine the first target distance between the midpoint of each edge corresponding to the first contraction cost value and the midpoint of the edge corresponding to the target contraction cost value, and the second target distance between the midpoint of each edge corresponding to the second contraction cost value and the midpoint of the edge corresponding to the target contraction cost value.
[0176] The edge whose first target distance is greater than or equal to a preset side length threshold is taken as the target shrinkage edge, and when the second target distance is greater than or equal to the preset side length threshold, the edge corresponding to the second shrinkage cost value is taken as the target shrinkage edge, so as to obtain one or more target shrinkage edges.
[0177] Optionally, the fifth determining module 505 is configured as follows:
[0178] The edge corresponding to the minimum target shrinkage value among the at least one first shrinkage value and the second shrinkage value is taken as the target shrinkage edge.
[0179] Optionally, the fifth determining module 505 is configured as follows:
[0180] For each newly added edge in the updated current 3D mesh model, the following update strategy is executed to update the current set of at least one newly added edge value;
[0181] The update strategy includes:
[0182] Get the number of elements in each of the newly added value sets;
[0183] If it is determined that there exists a set of specified new value values where the number of elements is less than or equal to a preset threshold, the shrinkage value of the newly added edge is added to the set of specified new value values.
[0184] If it is determined that the specified set of newly added values does not exist, a target set of newly added values is generated, and the shrinkage value of the currently added edge is added to the target set of newly added values.
[0185] Optionally, the third determining module 503 is configured as follows:
[0186] Determine the target point corresponding to the edge to be optimized. The target point is the point on the edge to be optimized that minimizes the sum of the squared distances to the adjacent faces of the edge to be optimized.
[0187] Delete the edge to be optimized, as well as the edges connected to it;
[0188] Connect the target point to the adjacent points of the endpoint of the edge to be optimized to obtain the current 3D mesh model.
[0189] The above technical solution, by iteratively optimizing the current 3D mesh model based on the initial generation value set and the at least one newly added generation value set, can effectively improve the model simplification efficiency. By loading the optimized target 3D mesh model, the loading time of the specified 3D mesh model data in the target webpage can be effectively shortened, thereby effectively improving the user experience.
[0190] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0191] Figure 6 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Figure 6 As shown, the electronic device 700 may include a processor 701 and a memory 702. The electronic device 700 may also include one or more of a multimedia component 703, an input / output (I / O) interface 704, and a communication component 705.
[0192] The processor 701 controls the overall operation of the electronic device 700 to complete all or part of the steps in the model loading method described above. The memory 702 stores various types of data to support the operation of the electronic device 700. This data may include, for example, instructions for any application or method operating on the electronic device 700, and application-related data such as contact data, sent and received messages, pictures, audio, video, etc. The memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. Multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touchscreen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in memory 702 or transmitted via communication component 705. The audio component also includes at least one speaker for outputting audio signals. I / O interface 704 provides an interface between processor 701 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual or physical buttons. Communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IoT, eMTC, or other 5G technologies, or combinations thereof, is not limited here. Therefore, the corresponding communication component 705 may include: a Wi-Fi module, a Bluetooth module, an NFC module, etc.
[0193] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the model loading method described above.
[0194] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the model loading method described above. For example, the computer-readable storage medium may be the memory 702 including the program instructions described above, which may be executed by the processor 701 of the electronic device 700 to complete the model loading method described above.
[0195] Figure 7 This is a block diagram illustrating another electronic device according to an exemplary embodiment. For example, electronic device 1900 may be provided as a server. (Refer to...) Figure 7 The electronic device 1900 includes a processor 1922, which may be one or more, and a memory 1932 for storing computer programs executable by the processor 1922. The computer program stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processor 1922 may be configured to execute the computer program to perform the model loading method described above.
[0196] Additionally, the electronic device 1900 may also include a power supply component 1926 and a communication component 1950. The power supply component 1926 can be configured to perform power management of the electronic device 1900, and the communication component 1950 can be configured to enable communication of the electronic device 1900, such as wired or wireless communication. Furthermore, the electronic device 1900 may also include an input / output (I / O) interface 1958. The electronic device 1900 can operate on an operating system, such as Windows Server, stored in memory 1932. TM Mac OS X TM Unix TM Linux TM etc.
[0197] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the model loading method described above. For example, the non-transitory computer-readable storage medium may be the memory 1932 including the program instructions described above, which may be executed by the processor 1922 of the electronic device 1900 to complete the model loading method described above.
[0198] In another exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program executable by a programmable device, the computer program having a code portion for performing the model loading method described above when executed by the programmable device.
[0199] The preferred embodiments of this disclosure have been described in detail above with reference to the accompanying drawings. However, this disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this disclosure, various simple modifications can be made to the technical solutions of this disclosure, and these simple modifications all fall within the protection scope of this disclosure.
[0200] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, this disclosure will not describe the various possible combinations separately.
[0201] Furthermore, various different embodiments of this disclosure can be combined in any way, as long as they do not violate the spirit of this disclosure, they should also be regarded as the content disclosed in this disclosure.
Claims
1. A model loading method, characterized in that, The method includes: In response to receiving a loading instruction for a target webpage, if it is determined that the target webpage includes a specified three-dimensional mesh model to be loaded, then the shrinkage cost value of each edge in the specified three-dimensional mesh model is obtained to obtain an initial cost value set, wherein the shrinkage cost value is used to characterize the geometric error that shrinkage will produce. The edges to be optimized in the specified three-dimensional mesh model are determined based on the initial set of values. The edges to be optimized are collapsed to obtain the updated current 3D mesh model; Determine the shrinkage cost of newly added edges in the current 3D mesh model to obtain at least one set of newly added cost values; The current 3D mesh model is iteratively optimized based on the initial generation value set and the at least one newly added generation value set to obtain an optimized target 3D mesh model, and the target 3D mesh model is loaded as the loading data of the target webpage. The step of iteratively optimizing the current 3D mesh model based on the initial generation value set and the at least one newly added generation value set to obtain the optimized target 3D mesh model includes: Identify the specified edges in the given 3D mesh model that are adjacent to the edge to be optimized; Remove the shrinkage value of the specified edge from the initial value set to obtain an updated initial value set; The current 3D mesh model is iteratively optimized based on the at least one newly added value set and the updated initial value set to obtain the target 3D mesh model; The step of iteratively optimizing the current 3D mesh model based on the at least one newly added value set and the updated initial value set to obtain the target 3D mesh model includes: Determine the minimum shrinkage value in each of the newly added generation value sets to obtain at least one first shrinkage value, and determine the minimum shrinkage value in the updated initial generation value set to obtain a second shrinkage value. The target shrinkage edge is determined based on at least one first shrinkage generation value and the second shrinkage generation value; The current 3D mesh model is collapsed based on the target shrinkage edge to obtain an updated current 3D mesh model; Based on the ratio of the number of planes in the updated current 3D mesh model to the number of planes in the specified 3D mesh model, the current 3D mesh model is iteratively optimized until the ratio is less than or equal to the ratio threshold, thus obtaining the target 3D mesh model.
2. The method according to claim 1, characterized in that, Determining the shrinkage cost of newly added edges in the current 3D mesh model to obtain at least one set of newly added cost values includes: Get the target number of new edges; If the target number is greater than a preset threshold, the shrinkage cost corresponding to the newly added edges of the target number is divided into multiple groups, each group corresponding to a set of newly added cost values, to obtain multiple sets of newly added cost values; or, When the target number is less than or equal to the preset number threshold, a new generation value set is generated, and the shrinkage generation value corresponding to the new edge of the target number is an element in the new generation value set.
3. The method according to claim 1, characterized in that, The step of iteratively optimizing the current 3D mesh model based on the ratio of the number of planes in the updated current 3D mesh model to the number of planes in the specified 3D mesh model, until the ratio is less than or equal to a preset ratio threshold, to obtain the target 3D mesh model, includes: Determine the ratio of the number of planes in the updated current 3D mesh model to the number of planes in the specified 3D mesh model; Determine whether the ratio is greater than the preset ratio threshold; If the ratio is determined to be greater than the preset ratio threshold, the current initial generation value set is updated according to the target shrinkage edge, and the shrinkage generation value of the newly added edge in the updated current 3D mesh model is determined to update the current at least one new generation value set. Then, the step of determining the minimum shrinkage generation value in each new generation value set is performed again to obtain at least one first shrinkage generation value, until the step of determining whether the ratio is greater than the preset ratio threshold is reached. If the ratio is determined to be less than or equal to the preset ratio threshold, the current three-dimensional mesh model is used as the target three-dimensional mesh model.
4. The method according to claim 1, characterized in that, Determining the target shrinkage edge based on the at least one first shrinkage value and the second shrinkage value includes: Determine the target shrinkage value that is the minimum of the at least one first shrinkage value and the second shrinkage value; Determine a first target distance between the midpoint of each edge corresponding to the first shrinkage cost value and the midpoint of the edge corresponding to the target shrinkage cost value, and a second target distance between the midpoint of each edge corresponding to the second shrinkage cost value and the midpoint of the edge corresponding to the target shrinkage cost value. The edge whose first target distance is greater than or equal to the preset side length threshold is taken as the target shrinkage edge, and when the second target distance is greater than or equal to the preset side length threshold, the edge corresponding to the second shrinkage cost value is taken as the target shrinkage edge, so as to obtain one or more target shrinkage edges.
5. The method according to claim 1, characterized in that, Determining the target shrinkage edge based on the at least one first shrinkage value and the second shrinkage value includes: The edge corresponding to the smallest specified number of shrinkage values among the at least one first shrinkage value and the second shrinkage value is taken as the target shrinkage edge.
6. The method according to claim 3, characterized in that, Determining the shrinkage value of newly added edges in the updated current 3D mesh model to update the current set of at least one set of newly added values includes: For each newly added edge in the updated current 3D mesh model, the following update strategy is executed to update the current set of at least one newly added edge values; The update strategy includes: Obtain the number of elements in each of the newly added value sets; If it is determined that there exists a specified set of newly added value values where the number of elements is less than or equal to a preset threshold, the shrinkage value of the newly added edge is added to the specified set of newly added value values. If it is determined that the specified set of newly added values does not exist, a target set of newly added values is generated, and the shrinkage value of the currently added edge is added to the target set of newly added values.
7. The method according to any one of claims 1-6, characterized in that, The edges to be optimized are collapsed to obtain the updated current 3D mesh model, including: Determine the target point corresponding to the edge to be optimized, where the target point is the point on the edge to be optimized that minimizes the sum of the squared distances to the adjacent faces of the edge to be optimized; Delete the edge to be optimized, as well as the edges connected to the edge to be optimized; Connect the target point to the adjacent points of the endpoint of the edge to be optimized to obtain the current three-dimensional mesh model.
8. A model loading device, characterized in that, The device includes: The first determining module is configured to, in response to receiving a loading instruction for a target webpage, if it is determined that the target webpage includes a specified three-dimensional mesh model to be loaded, obtain the shrinkage cost value of each edge in the specified three-dimensional mesh model to obtain an initial cost value set, wherein the shrinkage cost value is used to characterize the geometric error that shrinkage will produce. The second determining module is configured to determine the edges to be optimized in the specified three-dimensional mesh model based on the initial cost set; The third determining module is configured to perform collapse processing on the edge to be optimized in order to obtain the updated current three-dimensional mesh model; The fourth determining module is configured to determine the shrinkage cost of newly added edges in the current three-dimensional mesh model to obtain at least one set of newly added cost values. The fifth determining module is configured to iteratively optimize the current three-dimensional mesh model based on the initial generation value set and the at least one newly added generation value set to obtain an optimized target three-dimensional mesh model, and load the target three-dimensional mesh model as the loading data of the target webpage. The fifth determining module is configured as follows: Identify the specified edges in the given 3D mesh model that are adjacent to the edge to be optimized; Remove the shrinkage value of the specified edge from the initial value set to obtain an updated initial value set; The current 3D mesh model is iteratively optimized based on the at least one newly added value set and the updated initial value set to obtain the target 3D mesh model; The fifth determining module is configured as follows: Determine the minimum shrinkage value in each of the newly added generation value sets to obtain at least one first shrinkage value, and determine the minimum shrinkage value in the updated initial generation value set to obtain a second shrinkage value. The target shrinkage edge is determined based on at least one first shrinkage generation value and the second shrinkage generation value; The current 3D mesh model is collapsed based on the target shrinkage edge to obtain an updated current 3D mesh model; Based on the ratio of the number of planes in the updated current 3D mesh model to the number of planes in the specified 3D mesh model, the current 3D mesh model is iteratively optimized until the ratio is less than or equal to a preset ratio threshold, thus obtaining the target 3D mesh model.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the steps of the method described in any one of claims 1-7.
10. An electronic device, characterized in that, include: A memory on which computer programs are stored; A processor for executing the computer program in the memory to implement the steps of the method according to any one of claims 1-7.