Three-dimensional scene rendering method, device, equipment and medium
By preprocessing resources and gradual loading of the initial glTF model, gradually rendering the three-dimensional scene solves the problem that users cannot see scene changes during the model waiting for the model to be loaded, and improves the user experience.
Patent Information
- Application Number
- CN202411210033.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-08-30
AI Technical Summary
The existing three-dimensional scene rendering technology needs to wait until all map files are loaded before starting to build a complete scene, resulting in users not being able to see scene changes for a long time while waiting for model resources to download, affecting the user experience.
By preprocessing the initial glTF model resources, the target glTF model is generated, and each model is loaded according to the progressive loading strategy. As the model is loaded, it is gradually rendered to the scene tree, and progressive rendering is achieved.
This avoids the problem of users not seeing scene changes for a long time, improves the user experience, and achieves smoother three-dimensional scene presentation through incremental loading and rendering.
Smart Images

Figure CN118710795B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a three-dimensional scene rendering method, device, equipment and medium. Background Art
[0002] At present, the demand for three-dimensional scene rendering is involved in various fields such as interior design and game design. For example, in the field of interior design, various components such as tables and chairs are rendered into digital images through computer drawing.
[0003] However, existing rendering technology needs to wait until all texture files are loaded before building a complete scene for rendering. This will cause web (world wide web, global wide area network) users to not see any changes in the scene for a long time while waiting for all model resources to be downloaded. This is a very unfavorable processing method for the experience of web 3D applications. Summary of the invention
[0004] In view of the above, it is necessary to provide a three-dimensional scene rendering method, device, equipment and medium, aiming to solve the problem that scene changes cannot be seen for a long time during the three-dimensional scene rendering process.
[0005] A three-dimensional scene rendering method, the three-dimensional scene rendering method comprising:
[0006] In response to a rendering instruction for a target three-dimensional scene, performing resource preprocessing on each initial glTF model to obtain each target glTF model;
[0007] Load each target glTF model using a progressive loading strategy;
[0008] Obtaining a scene tree corresponding to the target three-dimensional scene;
[0009] When it is detected that any target glTF model has been loaded, the arbitrary target glTF model is rendered to the scene tree.
[0010] According to a preferred embodiment of the present invention, performing resource preprocessing on each initial glTF model to obtain each target glTF model includes:
[0011] For each initial glTF model, obtain all images in the textures / directory of the initial glTF model as each initial image;
[0012] Create a copy of each initial image in the textures / directory and record the disk space occupied by each copy;
[0013] Randomly generate a non-zero numeric string corresponding to each copy image, and name each copy image according to each string; wherein each string is not repeated and each string is an unsigned integer that does not exceed a preset position;
[0014] Keep the naming and format of each initial image, and replace each initial image with the single-pixel image of the preset position;
[0015] Channel filling is performed on each single-pixel image, and after the filling is completed, each currently obtained glTF model is determined as each target glTF model.
[0016] According to a preferred embodiment of the present invention, the channel filling of each single-pixel image includes:
[0017] Obtain the name of the copy image corresponding to each single-pixel image, and convert each name into binary to obtain each first data;
[0018] Fill the R channel of the corresponding single-pixel image with each first data;
[0019] Obtain the disk space occupied by the copy image corresponding to each single-pixel image, and convert each disk space occupied by the copy image into binary to obtain each second data;
[0020] Fill the G channel of the corresponding single-pixel image with each second data;
[0021] Set the B channel of each single-pixel image to 0;
[0022] Configure the A channel of each single-pixel image to be non-zero;
[0023] Among them, when the format of each initial image is JPG format, the corresponding single-pixel image does not include the A channel; when the format of each initial image is PNG format, the corresponding single-pixel image includes the A channel.
[0024] According to a preferred embodiment of the present invention, loading each target glTF model according to the progressive loading strategy includes:
[0025] For each target glTF model, create a first loading task and a second loading task; wherein the first loading task is used to load the .gltf file, .bin file, and all single-pixel images in the textures / directory corresponding to the target glTF model, and the second loading task is used to load all copy images in the textures / directory;
[0026] Execute the first loading task;
[0027] When it is detected that all single-pixel images in the textures / directory have been loaded, the second loading task is executed;
[0028] When it is detected that the first loading task is completed before the second loading task, a target scene object is created according to the .gltf file and .bin file corresponding to the target glTF model and all the single-pixel images in the textures / directory, and an object reference of the target scene object is saved; whether the second loading task is completed is detected, and when it is detected that the second loading task is completed, a target texture object is created according to all the copy images in the textures / directory, and an object reference of the target texture object is saved; the target scene object is referenced according to the object reference of the target scene object, and the single-pixel image in the target scene object is replaced with the corresponding copy image according to the object reference of the target texture object; or
[0029] When it is detected that the second loading task is completed before the first loading task, the target map object is created according to all the copy images in the textures / directory, and the object reference of the target map object is saved; whether the first loading task is completed is detected. When it is detected that the first loading task is completed, the target scene object is created according to the .gltf file and .bin file corresponding to the target glTF model and all the single-pixel images in the textures / directory, and the object reference of the target scene object is saved; the target scene object is referenced according to the object reference of the target scene object, and the single-pixel image in the target scene object is replaced with the corresponding copy image according to the object reference of the target map object.
[0030] According to a preferred embodiment of the present invention, executing the second loading task includes:
[0031] Parse the channel value of the R channel of each loaded single-pixel image, splice the download address according to the channel value of the R channel of each single-pixel image, and locate the copy image corresponding to each single-pixel image in the textures / directory according to each download address; or
[0032] Obtain the pre-recorded correspondence between each single-pixel image and each copy image, and locate the copy image corresponding to each single-pixel image in the textures / directory according to the correspondence;
[0033] Load each located replica image.
[0034] According to a preferred embodiment of the present invention, the method further comprises:
[0035] In response to a structure rendering instruction for the target three-dimensional scene, only the first loading task is executed for each target glTF model to load each target glTF model.
[0036] According to a preferred embodiment of the present invention, rendering the arbitrary target glTF model to the scene tree comprises:
[0037] Obtaining a pre-configured description file; wherein the description file is used to record the corresponding relationship between each target glTF model and each node in the scene tree;
[0038] Using the arbitrary target glTF model to traverse the description file, obtaining a target node corresponding to the arbitrary target glTF model in the scene tree;
[0039] Render the arbitrary target glTF model to the target node.
[0040] A three-dimensional scene rendering device, the three-dimensional scene rendering device comprising:
[0041] A resource preprocessing unit, configured to perform resource preprocessing on each initial glTF model in response to a rendering instruction for a target three-dimensional scene, to obtain each target glTF model;
[0042] A loading unit, used to load each target glTF model according to the progressive loading strategy;
[0043] An acquisition unit, used for acquiring a scene tree corresponding to the target three-dimensional scene;
[0044] The rendering unit is used to render the arbitrary target glTF model to the scene tree when it is detected that any target glTF model has been loaded.
[0045] A computer device, comprising:
[0046] a memory storing at least one instruction; and
[0047] A processor executes the instructions stored in the memory to implement the three-dimensional scene rendering method.
[0048] A computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in a computer device to implement the three-dimensional scene rendering method.
[0049] It can be seen from the above technical scheme that the present invention can perform resource preprocessing on each initial glTF model to obtain each target glTF model, and load each target glTF model according to the progressive loading strategy. When it is detected that any target glTF model has been loaded, any target glTF model is rendered to the scene tree corresponding to the target three-dimensional scene, thereby realizing progressive rendering of the target three-dimensional scene by progressively loading each target glTF model, making the picture show progressive changes, avoiding the user not being able to see the scene changes for a long time and affecting the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 It is a flow chart of a preferred embodiment of the three-dimensional scene rendering method of the present invention;
[0051] Figure 2 This is a schematic diagram of the rendering effect corresponding to the conventional glTF model loading method;
[0052] Figure 3 It is a schematic diagram of the progressive rendering effect of the three-dimensional scene rendering method of the present invention;
[0053] Figure 4 It is a functional module diagram of a preferred embodiment of the three-dimensional scene rendering device of the present invention;
[0054] Figure 5 It is a structural schematic diagram of a computer device of a preferred embodiment of the present invention for implementing a three-dimensional scene rendering method. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0056] like Figure 1 FIG. 1 is a flow chart of a preferred embodiment of the three-dimensional scene rendering method of the present invention. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted.
[0057] The three-dimensional scene rendering method is applied to one or more computer devices, which are devices that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and their hardware includes but is not limited to microprocessors, application specific integrated circuits (ASICs), programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0058] The computer device may be any electronic product that can perform human-computer interaction with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.
[0059] The computer device may also include a network device and / or a user device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud consisting of a large number of hosts or network servers based on cloud computing.
[0060] The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.
[0061] Among them, Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0062] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0063] The network where the computer device is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.
[0064] S10 , in response to a rendering instruction for a target three-dimensional scene, performing resource preprocessing on each initial glTF (GL Transmission Format) model to obtain each target glTF model.
[0065] In this embodiment, the target three-dimensional scene may include an interior decoration design scene, a game design scene, etc. The present invention does not limit the scene type of the target three-dimensional scene.
[0066] In this embodiment, the rendering instruction may be triggered by a user. For example, the rendering instruction may be triggered by a designer to perform interior design.
[0067] In this embodiment, the glTF model is a 3D model file format used for efficiently transmitting and loading 3D scenes and models.
[0068] Specifically, each initial glTF model can correspond to a component or a component group. For example, the initial glTF model can represent a table or a set of tables and chairs.
[0069] In this embodiment, the resource preprocessing of each initial glTF model to obtain each target glTF model includes:
[0070] For each initial glTF model, obtain all images in the textures / directory of the initial glTF model as each initial image;
[0071] Create a copy of each initial image in the textures / directory and record the disk space occupied by each copy;
[0072] Randomly generate a non-zero numeric string corresponding to each copy image, and name each copy image according to each string; wherein each string is not repeated and each string is an unsigned integer that does not exceed a preset position;
[0073] Keep the naming and format of each initial image, and replace each initial image with the single-pixel image of the preset position;
[0074] Channel filling is performed on each single-pixel image, and after the filling is completed, each currently obtained glTF model is determined as each target glTF model.
[0075] The unit of the disk occupied space may be kilobytes, namely KB.
[0076] The preset bits may be 32 bits.
[0077] In this embodiment, performing channel filling on each single-pixel image includes:
[0078] Obtain the name of the copy image corresponding to each single-pixel image, and convert each name into binary to obtain each first data;
[0079] Fill the R channel of the corresponding single-pixel image with each first data;
[0080] Obtain the disk space occupied by the copy image corresponding to each single-pixel image, and convert each disk space occupied by the copy image into binary to obtain each second data;
[0081] Fill the G channel of the corresponding single-pixel image with each second data;
[0082] Set the B channel of each single-pixel image to 0;
[0083] Configure the A channel of each single-pixel image to be non-zero;
[0084] Among them, when the format of each initial image is JPG format, the corresponding single-pixel image does not include the A channel; when the format of each initial image is PNG format, the corresponding single-pixel image includes the A channel.
[0085] It is understandable that each target glTF model includes a .gtlf file, a .bin file, and a textures / directory. Among them, textures / is used to store all types of maps for json reference in the .gltf file. The .gtlf file specifies the extraction location and extraction method (i.e., byte array view) of the vertex data of all meshes in the model in the .bin file, and specifies the directory and name of the map image file required for the mesh material (i.e., the name of each initial image, which is later used on the corresponding single-pixel image). After renaming each initial image with a random string, each initial image loses its association with the mesh of the model. Therefore, a strategy is needed to continue to maintain this corresponding association relationship on the basis of improving the loading process. In this embodiment, the name of each initial image is recorded for downloading in subsequent processes, and the name must be associated with the single-pixel image. Therefore, using a part of the channels (such as the R channel) of the single-pixel image to record the name of each copy image can not only record data without using additional storage means and occupying additional storage space, but also realize the need to correspond the data to the single-pixel image one by one. In addition, using a non-zero random value as the color value of a single-pixel image is also helpful in distinguishing the visual boundaries of different grids during progressive loading and rendering.
[0086] Similarly, the G channel can be used to record the actual disk space occupied by each copy image (equivalent to the actual disk space occupied by each initial image) for subsequent reference. In addition, the brightness of the G channel is related to the size of the disk space occupied. The larger the disk space occupied, the brighter the green of the G channel. Therefore, in the 3D scene window of the corresponding editor, the user can roughly compare the disk space occupied by the original map files of different components by observing the green highlight of each component in the scene with the naked eye, so as to assist in the optimization of scene construction.
[0087] Furthermore, setting channel B to 0 can be used as a spare information storage space.
[0088] Furthermore, configuring the A channel to not be all zeros can avoid the image not being displayed due to transparency issues.
[0089] S11, load each target glTF model according to the progressive loading strategy.
[0090] In this embodiment, each target glTF model may be asynchronously loaded from a remote server to a JS (JavaScript) web page on the client.
[0091] In this embodiment, loading each target glTF model according to the progressive loading strategy includes:
[0092] For each target glTF model, create a first loading task and a second loading task; wherein the first loading task is used to load the .gltf file, .bin file, and all single-pixel images in the textures / directory corresponding to the target glTF model, and the second loading task is used to load all copy images in the textures / directory;
[0093] Execute the first loading task;
[0094] When it is detected that all single-pixel images in the textures / directory have been loaded, the second loading task is executed;
[0095] When it is detected that the first loading task is completed before the second loading task, a target scene object is created according to the .gltf file and .bin file corresponding to the target glTF model and all the single-pixel images in the textures / directory, and an object reference of the target scene object is saved; whether the second loading task is completed is detected, and when it is detected that the second loading task is completed, a target texture object is created according to all the copy images in the textures / directory, and an object reference of the target texture object is saved; the target scene object is referenced according to the object reference of the target scene object, and the single-pixel image in the target scene object is replaced with the corresponding copy image according to the object reference of the target texture object; or
[0096] When it is detected that the second loading task is completed before the first loading task, the target map object is created according to all the copy images in the textures / directory, and the object reference of the target map object is saved; whether the first loading task is completed is detected. When it is detected that the first loading task is completed, the target scene object is created according to the .gltf file and .bin file corresponding to the target glTF model and all the single-pixel images in the textures / directory, and the object reference of the target scene object is saved; the target scene object is referenced according to the object reference of the target scene object, and the single-pixel image in the target scene object is replaced with the corresponding copy image according to the object reference of the target map object.
[0097] In the above embodiment, it is equivalent to initializing two loading tasks, and configuring completion flags of the two loading tasks respectively to detect whether the corresponding loading tasks are completed.
[0098] Specifically, a single-pixel image is loaded first, that is, a single-pixel image is used to participate in the loading, parsing and rendering process of the model resources. Since the single-pixel image occupies a small amount of resources, the loading speed is very fast. At the same time, a copy of the original texture and the possibility of referencing the copy are retained, which can achieve a significant improvement in the progressive loading and rendering experience at a negligible resource consumption cost. In addition, as long as the target scene object and the target texture object are created, the single-pixel image is replaced with the corresponding copy image to achieve timely update of the scene object. The continuously running rendering loop can apply the new scene data to the rendering to achieve the update and transformation of the three-dimensional visual effect.
[0099] The progressive loading strategy in this embodiment realizes the progressive loading rendering effect of the final rendering scene of a single model in terms of texture, but does not change any rules of the gltf model specification. Therefore, it can greatly enhance the user experience while maintaining full compatibility with existing relevant technical specifications.
[0100] In this embodiment, executing the second loading task includes:
[0101] Parse the channel value of the R channel of each loaded single-pixel image, splice the download address according to the channel value of the R channel of each single-pixel image, and locate the copy image corresponding to each single-pixel image in the textures / directory according to each download address; or
[0102] Obtain the pre-recorded correspondence between each single-pixel image and each copy image, and locate the copy image corresponding to each single-pixel image in the textures / directory according to the correspondence;
[0103] Load each replica image located.
[0104] The correspondence between each single-pixel image and each copy image may be recorded in a plain text file, a json file, a yaml file, etc. The present invention does not limit the recording method.
[0105] In the above embodiment, the duplicate image may be located by channel parsing, and the duplicate image corresponding to each single-pixel image may be pre-recorded so as to obtain the corresponding duplicate image for loading.
[0106] In this embodiment, the method further includes:
[0107] In response to a structure rendering instruction for the target three-dimensional scene, only the first loading task is executed for each target glTF model to load each target glTF model.
[0108] In the above embodiment, for task scenarios that focus mainly on model structure and not on details, only single-pixel images can be loaded for rendering, which can greatly reduce the loading and three-dimensional preview and rendering time of the model referenced by the component, thereby effectively improving the efficiency of model loading and rendering without affecting the normal task execution of the user.
[0109] Of course, you can also configure a switch to switch between different loading modes. Specifically, when you need to focus on details, load the single-pixel image first and then the copy image; when you only need to focus on the structure and not the details, you can only load the single-pixel image for rendering. In this way, you can switch the loading mode arbitrarily according to different needs, which is conducive to stripping non-core data, so as to focus on the main goal, so that the user interface presents an effect of enabling or disabling the original material.
[0110] S12: Obtain a scene tree corresponding to the target three-dimensional scene.
[0111] In this embodiment, the scene tree corresponds to a blank scene, and each target glTF model needs to be merged into the corresponding tree node to complete the final scene rendering.
[0112] S13: When it is detected that any target glTF model has been loaded, the arbitrary target glTF model is rendered to the scene tree.
[0113] In this embodiment, rendering the arbitrary target glTF model to the scene tree includes:
[0114] Obtaining a pre-configured description file; wherein the description file is used to record the corresponding relationship between each target glTF model and each node in the scene tree;
[0115] Using the arbitrary target glTF model to traverse the description file, obtaining a target node corresponding to the arbitrary target glTF model in the scene tree;
[0116] Render the arbitrary target glTF model to the target node.
[0117] For example, each node may have a corresponding node ID, and each target glTF model may also have a corresponding model ID. The corresponding relationship between the node ID and the model ID is recorded in the description file.
[0118] In the above embodiment, the target glTF models corresponding to various components can be merged and rendered into the same scene to achieve progressive three-dimensional scene rendering.
[0119] For example: you can refer to Figure 2 , is a schematic diagram of the rendering effect corresponding to the conventional glTF model loading method. Figure 2 It can be seen that during the rendering process, users cannot see the transition effect and directly enter the complete scene from the blank scene. Since it is necessary to wait until all the texture files in the tetures directory are loaded before starting to synchronously build the complete scene for rendering, the rendering takes a long time and users cannot see any changes in the scene for a long time. Please refer to Figure 3 , is a schematic diagram of the progressive rendering effect of the three-dimensional scene rendering method of the present invention. Figure 3 It can be seen that users can see a progressive, more fine-grained, and smoother rendering process, which will not make users feel that there is a strong sense of "stuttering" when the scene is loaded, and effectively eliminate the white screen phenomenon. Instead, users will feel that it does not take long to see the scene picture changing little by little, and can promptly feedback the results of loading changes to users, without the abrupt feeling brought by waiting for a long time and suddenly presenting the entire scene, which is more conducive to improving the site user conversion rate.
[0120] Let's take the rendering of a city scene as an example. The conventional method may be that after the webpage is opened, a complete building A suddenly appears after waiting for x seconds, and then the picture stagnates, and then a complete building B suddenly appears after waiting for y seconds... Each waiting process will be accompanied by a fixed period of no change in the three-dimensional scene picture on the page, which gives the user a certain "stuttering" feeling. After adopting the three-dimensional scene rendering method in this embodiment, on the one hand, the decoupling of the loading of geometric data and texture data in the model resources can be achieved, that is, the geometric structure of building A (that is, the white model or solid color corresponding to the single-pixel picture) and the geometric structure of building B can be rendered in advance. When the complete textures of building A and building B are loaded, the texture materials of building A and building B will be applied, and the delayed rendering of the original texture can be achieved at this time. On the other hand, the decoupling of the loading of multiple grid overall data (that is, geometric structure and texture) in the same three-dimensional scene can also be achieved. Decompose the scene into fine-grained resources, and then load these fine-grained resources progressively. Each time a new part of the resources is loaded, it is updated or merged into the scene object in a timely manner. Whenever the scene object is updated, the rendering loop can apply these updates in time and render the next frame of the picture that is different from the previous frame. In this way, a progressive user experience of 3D rendering is achieved, which will not make users feel that there is a strong sense of lag in scene loading. Instead, users will feel that they can see the scene picture changing little by little in a short time.
[0121] In actual web 3D applications, the sub-models of a scene may have different data sources. Therefore, using the above mechanism, the web browser can realize the progressive loading and rendering of the entire scene according to the size of each glTF model, geometry or material priority, multi-threaded loading and other optimization methods, and ultimately improve the user experience of web 3D applications.
[0122] It can be seen from the above technical scheme that the present invention can perform resource preprocessing on each initial glTF model to obtain each target glTF model, and load each target glTF model according to the progressive loading strategy. When it is detected that any target glTF model has been loaded, any target glTF model is rendered to the scene tree corresponding to the target three-dimensional scene, thereby realizing progressive rendering of the target three-dimensional scene by progressively loading each target glTF model, making the picture show progressive changes, avoiding the user not being able to see the scene changes for a long time and affecting the user experience.
[0123] like Figure 4, which is a functional module diagram of a preferred embodiment of the three-dimensional scene rendering device of the present invention. The three-dimensional scene rendering device 11 includes a resource preprocessing unit 110, a loading unit 111, an acquisition unit 112, and a rendering unit 113. The module / unit referred to in the present invention refers to a series of computer program segments that can be executed by a processor and can complete fixed functions, which are stored in a memory. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.
[0124] The resource preprocessing unit 110 is used to perform resource preprocessing on each initial glTF model in response to a rendering instruction for a target three-dimensional scene to obtain each target glTF model;
[0125] The loading unit 111 is used to load each target glTF model according to a progressive loading strategy;
[0126] The acquisition unit 112 is used to acquire a scene tree corresponding to the target three-dimensional scene;
[0127] The rendering unit 113 is used to render the arbitrary target glTF model to the scene tree when it is detected that any target glTF model has been loaded.
[0128] It can be seen from the above technical scheme that the present invention can perform resource preprocessing on each initial glTF model to obtain each target glTF model, and load each target glTF model according to the progressive loading strategy. When it is detected that any target glTF model has been loaded, any target glTF model is rendered to the scene tree corresponding to the target three-dimensional scene, thereby realizing progressive rendering of the target three-dimensional scene by progressively loading each target glTF model, making the picture show progressive changes, avoiding the user not being able to see the scene changes for a long time and affecting the user experience.
[0129] like Figure 5 FIG. 1 is a schematic diagram of the structure of a computer device of a preferred embodiment of the method for implementing three-dimensional scene rendering of the present invention.
[0130] The computer device 1 may include a memory 12 , a processor 13 , and a bus, and may also include a computer program stored in the memory 12 and executable on the processor 13 , such as a three-dimensional scene rendering program.
[0131] Those skilled in the art will appreciate that the schematic diagram is merely an example of the computer device 1 and does not constitute a limitation on the computer device 1. The computer device 1 may be a bus-type structure or a star-type structure. The computer device 1 may also include more or less other hardware or software than shown in the diagram, or a different arrangement of components. For example, the computer device 1 may also include input and output devices, network access devices, etc.
[0132] It should be noted that the computer device 1 is only an example, and other existing or future electronic products that are suitable for the present invention should also be included in the protection scope of the present invention and included here by reference.
[0133] Among them, the memory 12 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 12 can be an internal storage unit of the computer device 1, such as a mobile hard disk of the computer device 1. In other embodiments, the memory 12 can also be an external storage device of the computer device 1, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the computer device 1. Further, the memory 12 can also include both an internal storage unit of the computer device 1 and an external storage device. The memory 12 can not only be used to store application software and various types of data installed in the computer device 1, such as the code of the three-dimensional scene rendering program, etc., but also can be used to temporarily store data that has been output or is to be output.
[0134] In some embodiments, the processor 13 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 13 is the control core (Control Unit) of the computer device 1, and uses various interfaces and lines to connect various components of the entire computer device 1, and executes various functions and processes data of the computer device 1 by running or executing programs or modules stored in the memory 12 (for example, executing a three-dimensional scene rendering program, etc.), and calling data stored in the memory 12.
[0135] The processor 13 executes the operating system of the computer device 1 and various installed applications. The processor 13 executes the applications to implement the steps in the above-mentioned three-dimensional scene rendering method embodiments, for example Figure 1 Steps shown.
[0136] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present invention. The one or more modules / units may be a series of computer-readable instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the computer device 1. For example, the computer program may be divided into a resource preprocessing unit 110, a loading unit 111, an acquisition unit 112, and a rendering unit 113.
[0137] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, and includes a number of instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute a part of the three-dimensional scene rendering method described in each embodiment of the present invention.
[0138] If the module / unit integrated in the computer device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware devices through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of each of the above-mentioned method embodiments can be implemented.
[0139] The computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory, etc.
[0140] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0141] The blockchain referred to in this invention is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the blockchain underlying platform, platform product service layer, and application service layer.
[0142] The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 The bus is represented by only one straight line, but it does not mean that there is only one bus or one type of bus. The bus is configured to realize the connection and communication between the memory 12 and at least one processor 13, etc.
[0143] Although not shown, the computer device 1 may also include a power source (such as a battery) for supplying power to various components. Preferably, the power source may be logically connected to the at least one processor 13 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, and power status indicators. The computer device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0144] Furthermore, the computer device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used to establish a communication connection between the computer device 1 and other computer devices.
[0145] Optionally, the computer device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the computer device 1 and to display a visual user interface.
[0146] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0147] It can be understood by those skilled in the art that Figure 5 The structure shown does not constitute a limitation on the computer device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0148] Combination Figure 1 , the memory 12 in the computer device 1 stores a plurality of instructions to implement a three-dimensional scene rendering method, and the processor 13 can execute the plurality of instructions to implement:
[0149] In response to a rendering instruction for a target three-dimensional scene, performing resource preprocessing on each initial glTF model to obtain each target glTF model;
[0150] Load each target glTF model using a progressive loading strategy;
[0151] Obtaining a scene tree corresponding to the target three-dimensional scene;
[0152] When it is detected that any target glTF model has been loaded, the arbitrary target glTF model is rendered to the scene tree.
[0153] Specifically, the specific implementation method of the processor 13 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0154] It should be noted that the data involved in this case were all obtained legally.
[0155] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0156] The present invention can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0157] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0158] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0159] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0160] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0161] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the present invention can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0162] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A three-dimensional scene rendering method, characterized in that: The three-dimensional scene rendering method comprises: In response to a rendering instruction for a target three-dimensional scene, resource preprocessing is performed on each initial glTF model to obtain each target glTF model, including: for each initial glTF model, all images in the textures / directory of the initial glTF model are obtained as each initial image; a copy image of each initial image is created in the textures / directory, and the disk space occupied by each copy image is recorded; a non-zero numeric string corresponding to each copy image is randomly generated, and each copy image is named according to each string; wherein each string is not repeated, and each string is an unsigned integer that does not exceed a preset position; the naming and format of each initial image are maintained, and each initial image is replaced by a single-pixel image of the preset position; channel filling is performed on each single-pixel image, and after the filling is completed, each currently obtained glTF model is determined as each target glTF model; Load each target glTF model using a progressive loading strategy; Obtaining a scene tree corresponding to the target three-dimensional scene; When it is detected that any target glTF model has been loaded, the arbitrary target glTF model is rendered to the scene tree.
2. The three-dimensional scene rendering method according to claim 1, characterized in that: The channel filling of each single-pixel image includes: Obtain the name of the copy image corresponding to each single-pixel image, and convert each name into binary to obtain each first data; Fill the R channel of the corresponding single-pixel image with each first data; Obtain the disk space occupied by the copy image corresponding to each single-pixel image, and convert each disk space occupied by the copy image into binary to obtain each second data; Fill the G channel of the corresponding single-pixel image with each second data; Set the B channel of each single-pixel image to 0; Configure the A channel of each single-pixel image to be non-zero; Among them, when the format of each initial image is JPG format, the corresponding single-pixel image does not include the A channel; when the format of each initial image is PNG format, the corresponding single-pixel image includes the A channel.
3. The three-dimensional scene rendering method according to claim 1, characterized in that: The step of loading each target glTF model according to the progressive loading strategy includes: For each target glTF model, create a first loading task and a second loading task; wherein the first loading task is used to load the .gltf file, .bin file, and all single-pixel images in the textures / directory corresponding to the target glTF model, and the second loading task is used to load all copy images in the textures / directory; Execute the first loading task; When it is detected that all single-pixel images in the textures / directory have been loaded, the second loading task is executed; When it is detected that the first loading task is completed before the second loading task, a target scene object is created according to the .gltf file and .bin file corresponding to the target glTF model and all the single-pixel images in the textures / directory, and an object reference of the target scene object is saved; whether the second loading task is completed is detected, and when it is detected that the second loading task is completed, a target texture object is created according to all the copy images in the textures / directory, and an object reference of the target texture object is saved; the target scene object is referenced according to the object reference of the target scene object, and the single-pixel image in the target scene object is replaced with the corresponding copy image according to the object reference of the target texture object; or When it is detected that the second loading task is completed before the first loading task, the target map object is created according to all the copy images in the textures / directory, and the object reference of the target map object is saved; whether the first loading task is completed is detected. When it is detected that the first loading task is completed, the target scene object is created according to the .gltf file and .bin file corresponding to the target glTF model and all the single-pixel images in the textures / directory, and the object reference of the target scene object is saved; the target scene object is referenced according to the object reference of the target scene object, and the single-pixel image in the target scene object is replaced with the corresponding copy image according to the object reference of the target map object.
4. The three-dimensional scene rendering method according to claim 3, characterized in that: The executing the second loading task comprises: Parse the channel value of the R channel of each loaded single-pixel image, splice the download address according to the channel value of the R channel of each single-pixel image, and locate the copy image corresponding to each single-pixel image in the textures / directory according to each download address; or Obtain the pre-recorded correspondence between each single-pixel image and each copy image, and locate the copy image corresponding to each single-pixel image in the textures / directory according to the correspondence; Load each replica image located.
5. The three-dimensional scene rendering method according to claim 3, characterized in that: The method further comprises: In response to a structure rendering instruction for the target three-dimensional scene, only the first loading task is executed for each target glTF model to load each target glTF model.
6. The three-dimensional scene rendering method according to claim 1, characterized in that: The rendering of the arbitrary target glTF model to the scene tree comprises: Obtaining a pre-configured description file; wherein the description file is used to record the corresponding relationship between each target glTF model and each node in the scene tree; Using the arbitrary target glTF model to traverse the description file, obtaining a target node corresponding to the arbitrary target glTF model in the scene tree; Render the arbitrary target glTF model to the target node.
7. A three-dimensional scene rendering device, characterized in that: The three-dimensional scene rendering device comprises: A resource preprocessing unit, for responding to a rendering instruction for a target three-dimensional scene, performing resource preprocessing on each initial glTF model to obtain each target glTF model, including: for each initial glTF model, obtaining all images in the textures / directory of the initial glTF model as each initial image; creating a copy image of each initial image in the textures / directory, and recording the disk space occupied by each copy image; randomly generating a non-zero numeric string corresponding to each copy image, and naming each copy image according to each string; wherein each string is not repeated, and each string is an unsigned integer that does not exceed a preset position; maintaining the naming and format of each initial image, and replacing each initial image with a single-pixel image of the preset position; performing channel filling on each single-pixel image, and determining each currently obtained glTF model as each target glTF model after the filling is completed; A loading unit, used to load each target glTF model according to the progressive loading strategy; An acquisition unit, used for acquiring a scene tree corresponding to the target three-dimensional scene; The rendering unit is used to render the arbitrary target glTF model to the scene tree when it is detected that any target glTF model has been loaded.
8. A computer device, characterized in that: The computer device comprises: a memory storing at least one instruction; and A processor executes instructions stored in the memory to implement the three-dimensional scene rendering method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in a computer device to implement the three-dimensional scene rendering method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Building information model lightweight processing method, system and equipment and storage medium
CN115601523A
Web end application-oriented three-dimensional model multi-scale data reorganization, progressive transmission and rendering method
CN117496071A
