Web-side 3D effect synchronization method, device, equipment and medium based on Unity3D
By rendering the three-dimensional model in the Unity3D engine and uploading the scene files, real-time preview and secondary development on the web without installation are achieved, and the packaging and compilation problem of previewing on the web by Unity3D side is solved, and the development process is simplified.
Patent Information
- Application Number
- CN202210506240.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-10
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2042-05-10
AI Technical Summary
When using Unity3D software, directly previewing the 3D effect on the web side requires packaging and compilation, which is redundant and time-consuming, and cannot be secondary development, which makes it difficult to find problems.
By importing the three-dimensional model of the target object into the Unity3D engine for rendering, the scene information is determined according to the 3D program attribute information on the web side, and the scene information is encapsulated into a file and uploaded to the server for display, so that real-time preview and secondary development can be achieved on the web side without installation.
It solves the packaging and compilation defects of real-time preview of Unity3D end on the web side, provides convenient secondary development capabilities on the web side, and simplifies the development process.
Smart Images

Figure CN114820903B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and medium for synchronizing 3D effects on a Web side based on Unity3D. Background Art
[0002] Developed by Unity Technologies, Unity3D is a comprehensive, multi-platform game development tool that allows players to easily create interactive content such as 3D video games, architectural visualizations, and real-time 3D animations. It is a fully integrated professional game engine. Unity is similar to Director, the Blender game engine, Virtools, or Torque Game Builder, which primarily utilize an interactive graphical development environment.
[0003] Currently, when using Unity3D software, when you need to preview and view the effects on the web, Unity3D software officially provides a way to compile and generate WebGL. This method packages the content of the scene into a package structure that cannot be redeveloped. The packaging time is very long, the packaged content is redundant, and the effects are significantly different from the editor preview, making it very difficult to find problems. Summary of the Invention
[0004] The present invention provides a method, device, equipment and medium for synchronizing 3D effects on a Web side based on Unity3D. The method can import files into a Unity3D directory for direct use without installation, thus resolving the defect that Unity3D needs to package and compile for real-time preview on a Web side. The method also enables secondary development on the Web side, providing convenience for users.
[0005] According to one aspect of the present invention, a method for synchronizing 3D effects on a Web client based on Unity3D is provided. The method comprises: a publishing client connected to a server configured with a Unity3D engine; the publishing client connected to a server connected to a Web client; and the method comprising:
[0006] Importing the 3D model of the target object into the Unity3D engine to render the 3D model;
[0007] Determining scene information for rendering the three-dimensional model according to attribute information compatible with the 3D program on the web side;
[0008] Encapsulating the scene information to obtain a scene file;
[0009] The scene file is uploaded to the server, so that the server responds to the access operation of the Web end and transmits it to the Web end for 3D effect display.
[0010] Optionally, determining scene information for rendering the three-dimensional model according to attribute information compatible with a 3D program on the web side includes:
[0011] Reading attribute information of the 3D program on the Web side, and generating target attribute information based on the attribute information;
[0012] Rendering the three-dimensional model according to the target attribute information to obtain scene information;
[0013] The scene information is encapsulated to obtain a scene file.
[0014] Optionally, the scene information includes: one or more information of a camera, lighting, ambient light, shadow, reflection, and camera focus in the scene.
[0015] Optionally, reading attribute information of the 3D program on the Web side and generating target attribute information based on the attribute information includes:
[0016] Reading attribute information of the 3D program on the Web side, and identifying whether the attribute information is rendering information included in the Unity3D engine;
[0017] If so, generating target attribute information based on the attribute information;
[0018] If not, a new attribute corresponding to the 3D program on the Web side is created, and attribute values are assigned to the new attribute to generate target attribute information.
[0019] Optionally, the method further includes:
[0020] The material information of all target objects is encapsulated to obtain a resource file; and the texture information of all target objects is encapsulated to obtain a texture file.
[0021] Optionally, encapsulate the material information of all target objects to obtain a resource file, including:
[0022] Identify whether the material information of all target objects has been uploaded;
[0023] If there is uploaded material information, then construct material reference information between the uploaded material information;
[0024] The material information that has not been uploaded and the material reference information are packaged to obtain a resource file.
[0025] Optionally, encapsulate the texture information of all target objects to obtain a texture file, including:
[0026] Identify whether the texture information of all target objects has been uploaded;
[0027] If there is already uploaded image information, then construct image reference information between the uploaded image information and the image information;
[0028] The unuploaded texture information and the texture reference information are packaged to obtain a texture file.
[0029] According to another aspect of the present invention, a device for synchronizing 3D effects on a Web side based on Unity3D is provided. The device is configured on a publishing side, which is configured with a Unity3D engine; the publishing side is connected to a server side, which is connected to a Web side; and comprises:
[0030] A model import module, used to import the 3D model of the target object into the Unity3D engine to render the 3D model;
[0031] A scene information determination module, configured to determine scene information for rendering the three-dimensional model according to attribute information adapted to the 3D program on the web side;
[0032] A scene file obtaining module, used for encapsulating the scene information to obtain a scene file;
[0033] The scene file uploading module is used to upload the scene file to the server, so that the server can respond to the access operation of the Web terminal and transmit it to the Web terminal for 3D effect display.
[0034] According to another aspect of the present invention, an electronic device is provided, comprising:
[0035] at least one processor; and
[0036] a memory communicatively connected to the at least one processor; wherein,
[0037] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the Unity3D-based Web-side 3D effect synchronization method described in any embodiment of the present invention.
[0038] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the Web-side 3D effect synchronization method based on Unity3D as described in any embodiment of the present invention when executed.
[0039] The technical solution of the embodiment of the present invention is to render the three-dimensional model of the target object by importing it into the Unity3D engine; determine the scene information for rendering the three-dimensional model according to the attribute information compatible with the 3D program on the Web side; encapsulate the scene information to obtain a scene file; and upload the scene file to the server side, so that the server side can respond to the access operation of the Web side and transmit it to the Web side for 3D effect display. This technical solution can import files into the Unity3D directory for direct use without installation, solving the defect that Unity3D needs to package and compile for real-time preview on the Web side. It can also be used for secondary development on the Web side, providing convenience for users.
[0040] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0042] Figure 1 This is a flowchart of a method for synchronizing 3D effects on a Web side based on Unity3D according to the first embodiment of the present invention;
[0043] Figure 2 This is a flowchart of a method for synchronizing 3D effects on a Web device based on Unity3D according to a second embodiment of the present invention;
[0044] Figure 3 3D effect synchronization device based on Unity3D on a Web side according to the third embodiment of the present invention;
[0045] Figure 4 It is a structural diagram of an electronic device provided according to the fourth embodiment of the present invention. DETAILED DESCRIPTION
[0046] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0047] It should be noted that the terms "first", "second", "target", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0048] Example 1
[0049] Figure 1 This is a flowchart of a method for synchronizing 3D effects on a Web-side based on Unity3D according to a first embodiment of the present invention. This embodiment is applicable to situations where 3D effects are synchronized on a Web-side based on Unity3D. This method can be executed by a 3D effects synchronization device on a Web-side based on Unity3D. The 3D effects synchronization device on a Web-side based on Unity3D can be implemented in the form of hardware and / or software. The 3D effects synchronization device on a Web-side based on Unity3D can be configured in an electronic device with data processing capabilities. Figure 1 As shown, the method includes:
[0050] S110 , importing the three-dimensional model of the target object into the Unity3D engine to render the three-dimensional model.
[0051] The technical solution of this embodiment can be executed by the publishing end, which is equipped with a Unity3D engine; the publishing end is connected to the server end, and the server end is connected to the Web end. In this embodiment, the three-dimensional model of the target object is rendered by the Unity3D engine, and the scene information of the three-dimensional model is determined according to the attribute information adapted to the 3D program on the Web end, and the scene information is encapsulated to obtain a scene file. The file is uploaded to the server end, and the 3D effect can be displayed synchronously. The technical solution of this embodiment can import files into the Unity3D directory for direct use without installation, which solves the defect that the Unity3D end needs to be packaged and compiled for real-time preview on the web end, and can be secondary developed on the web end, providing convenience for users.
[0052] The Unity3D engine, developed by Unity Technologies, is a comprehensive multi-platform game development tool that allows players to easily create interactive content such as 3D video games, architectural visualizations, and real-time 3D animations. It is a fully integrated professional game engine. Its editor runs on Windows and Mac OS X, and games can be published for Windows, Mac, Wii, iPhone, WebGL (requires HTML5), Windows Phone 8, and Android platforms. Web games can also be published using the Unity web player plugin, which supports web browsing on both Mac and Windows. The web player is also supported on Mac.
[0053] Among them, the target object can be a building object or other objects. The three-dimensional model is a polygonal representation of the target object. In this embodiment, 3dsmax can be used to perform equivalent modeling on the target object, obtain an equivalent three-dimensional object in the virtual world, and output it as a file in fbx format. The Unity3D engine can render the three-dimensional model of the target object. In this embodiment, the rendering mode can be set to linear rendering; in this embodiment, the effect of the three-dimensional model can be adjusted by using PBR material balls, lights, cameras, textures (adding pictures to the wooden table), ambient light and sky reflections. Among them, the PBR material ball can be understood as a material ball rendered by a set of physical materials summarized based on the natural laws in the real world. Physical properties such as metal, roughness and other properties can be simulated in the interface to simulate the authenticity of the building. For example, for a wooden table, this material ball can be used to obtain the effect of a painted table.
[0054] In this embodiment, the publishing end imports the 3D model of the target object into the Unity3D engine to render the 3D model.
[0055] S120: Determine scene information for rendering the three-dimensional model according to attribute information compatible with the 3D program on the Web side.
[0056] Among them, 3D programs can be obtained through ThreeJS. ThreeJS can use JavaScript to write 3D programs. On the browser side, WebGL is an underlying standard. After these standards were defined, browsers such as Chrome and Firefox implemented these standards. Then, three-dimensional graphics rendering can be achieved on the web page through JavaScript code. ThreeJS encapsulates the underlying graphics interface, making it easier to implement 3D programs. Attribute information can include information such as shadows, lights, cameras, and camera focus. Scene information can include one or more of the following information: cameras, lights, ambient light, shadows, reflections, and camera focus in the scene.
[0057] In this embodiment, the publishing end can determine one or more information of the camera, light, ambient light, shadow, reflection and camera focus in the scene of rendering the three-dimensional model according to the attribute information adapted to the 3D program on the Web end, such as shadow, light, camera and camera focus.
[0058] S130: Encapsulate the scene information to obtain a scene file.
[0059] The scene file can be obtained by encapsulating scene information. The encapsulated scene information may include, but is not limited to, models, model hierarchies, model tags, material balls, textures, lights, cameras, ambient lights, reflection maps, particle systems, and animation modules. The scene file can be in JSON format.
[0060] For example, in this embodiment, the camera, light, ambient light, shadow, sky box, reflection, material ball, model reference, hierarchy, label, map reference, particle system, growth animation, UV animation and cutting animation information in the scene can be encapsulated into a Json file.
[0061] Specifically, in this embodiment, by traversing all elements in the scene, recording the hierarchical relationship and labels of the model, recording the material ball reference of the grid, recording the map reference of the material ball, recording the parameters of the material ball, recording the animation parameters, recording the particle parameters, recording the sky box parameters, recording the reflection information parameters and recording the ambient light information parameters and other elements, and saving them into a Json file library, thereby obtaining a scene file.
[0062] In this embodiment, the publishing end may encapsulate the scene information to obtain a scene file.
[0063] S140: Upload the scene file to the server, so that the server can respond to the access operation of the Web terminal and transmit it to the Web terminal for 3D effect display.
[0064] The server can be a CDN server. The access operation can be performed by a user through a web client. In this embodiment, the publisher can upload the packaged scene file to the server, so that the server responds to the access operation from the web client and transmits the scene file to the web client for 3D effect display. In this embodiment, external viewing on the web client is more convenient, and the Unity3D client can easily adjust the effect.
[0065] For example, in this embodiment, when uploading scene information, the current scene name is displayed, and model and texture options are provided. If the scene file has already been uploaded, a preview can be displayed in the browser in the status bar on the right. In this embodiment, you can also click Preview to view the previously uploaded scene directly in the browser.
[0066] The technical solution of the embodiment of the present invention is to render the three-dimensional model of the target object by importing it into the Unity3D engine; determine the scene information for rendering the three-dimensional model according to the attribute information compatible with the 3D program on the Web side; encapsulate the scene information to obtain a scene file; and upload the scene file to the server side, so that the server side can respond to the access operation of the Web side and transmit it to the Web side for 3D effect display. This technical solution can import files into the Unity3D directory for direct use without installation, solving the defect that Unity3D needs to package and compile for real-time preview on the Web side. It can also be used for secondary development on the Web side, providing convenience for users.
[0067] Example 2
[0068] Figure 2 This is a flowchart of a method for synchronizing 3D effects on a Web-based system based on Unity3D according to the second embodiment of the present invention. This embodiment is optimized based on the above embodiment. The specific optimization is as follows: according to the attribute information adapted to the 3D program on the Web-side, the scene information for rendering the three-dimensional model is determined, including: reading the attribute information of the 3D program on the Web-side, and generating target attribute information based on the attribute information; rendering the three-dimensional model according to the target attribute information to obtain scene information; and encapsulating the scene information to obtain a scene file. Figure 2 As shown, the method of this embodiment specifically includes the following steps:
[0069] S210: Import the three-dimensional model of the target object into the Unity3D engine to render the three-dimensional model.
[0070] S220 , reading attribute information of the 3D program on the Web side, and generating target attribute information based on the attribute information.
[0071] The 3D program can be obtained through ThreeJS. Attribute information may include information such as shadows, lights, cameras, skyboxes, animation systems, and camera focus. Target attribute information can be generated based on the attribute information of the 3D program on the web side and matched with the 3D program.
[0072] In this embodiment, the publishing end reads the attribute information of the 3D program on the Web end, such as shadows, lights, cameras, skyboxes, animation systems, and camera focus, and generates target attribute information such as shadow range, shadow map size, cameras, lights, skyboxes, and animation systems that match the 3D program based on the read attribute information.
[0073] S230: Render the three-dimensional model according to the target attribute information to obtain scene information.
[0074] The scene information can be obtained by rendering the three-dimensional model according to the target attribute information using the ThreeJs technology. In this embodiment, the publishing end renders the three-dimensional model according to the target attribute information to obtain the scene information.
[0075] Specifically, in this embodiment, a program can be written according to the ThreeJS parameter requirements to input parameters for up, down, left, right, front, and back. The Unity3D end generates a grid indicating the range of the shadow area to be generated, and input parameters for the length and width of the map to indicate the size of the generated shadow map. A program can be written according to the ThreeJS parameter requirements to input parameters for the camera's focus point. The Unity3D end automatically generates a focus point and records the position information, automatically focusing on the focus point. A program can be written according to the ThreeJS parameter requirements to input parameters for the light's focus point. The Unity3D end automatically generates a focus point and records the position information, automatically focusing on the focus point. A spherical model can be generated according to the ThreeJS parameter requirements, and a skybox material can be attached, discarding Unity3D's own skybox. A cutting animation can be written according to the ThreeJS parameter requirements to input parameters such as whether to loop, animation type, color information and transparency of the cutting piece, delay, initial height, end height, duration, and the targeted grid rendering object. An explosion animation can be written according to the ThreeJS parameter requirements to input parameters such as the grid rendering object, delay, explosion type, whether to loop, number of loops, loop delay, whether to reverse, reverse duration, and reverse delay.
[0076] In addition, in this embodiment, images in cubmap and texture2d scenes can be grouped by type, and in texture2d, images can be grouped by usage type. Based on the group, the Unity3D client can customize whether to use webp compression and select the quality from 0 to 100. The compressed image will be replaced with the new image path when it is subsequently uploaded to the server.
[0077] S240: Encapsulate the scene information to obtain a scene file.
[0078] In this embodiment, the publishing end renders the three-dimensional model according to the target attribute information to obtain scene information, and encapsulates the obtained scene information to obtain a scene file.
[0079] S250: Upload the scene file to the server, so that the server can respond to the access operation of the Web terminal and transmit it to the Web terminal for 3D effect display.
[0080] The technical solution of the embodiment of the present invention is to render the three-dimensional model of the target object by importing it into the Unity3D engine; read the attribute information of the 3D program on the Web side, and generate target attribute information based on the attribute information; render the three-dimensional model according to the target attribute information to obtain scene information; encapsulate the scene information to obtain a scene file; upload the scene file to the server side, so that the server side can respond to the access operation of the Web side and transmit it to the Web side for 3D effect display. This technical solution can import files into the Unity3D directory for direct use without installation, which solves the defect that the Unity3D side needs to be packaged and compiled for real-time preview on the Web side, and can be used for secondary development on the Web side, providing convenience for users.
[0081] In this embodiment, optionally, the scene information includes: one or more information of a camera, light, ambient light, shadow, reflection, and camera focus in the scene.
[0082] The scene information in this embodiment may include one or more information of the camera, light, ambient light, shadow, reflection, and camera focus in the scene.
[0083] For example, in this embodiment, the scene information may include: all types of basic information in the scene including position, rotation and scale; lighting information in the scene including but not limited to light type, color, intensity, range, shadow type, focus point, shadow map range, map size, halo map, size and distance, etc.; camera information of the scene including but not limited to projection type, near clipping, far clipping, viewing angle and focus point, etc.; rendering information in the scene including but not limited to skybox map, background color, rendering color, whether fog effect is enabled, fog effect color, fog effect type, ambient light type, ambient light color, ambient light intensity, resolution size of the game view panel, reflection map map and intensity, etc.; model of the scene Information includes, but is not limited to, the model's name, unique code, group structure, and hierarchy. Scene mesh rendering information includes, but is not limited to, the path relative to the model's root node, whether it is displayed, baked texture code, UV information, whether it accepts shadows, whether it casts shadows, labels, scale and offset, and material ball code list. Scene particle system information includes, but is not limited to, texture, duration, looping, start time, start speed, start angle, maximum number of particles, radius, scale, linear force, rendering mode, color, and self-illumination color. Scene streamer animation information includes, but is not limited to, texture code, offset, scale, width, looping, world coordinates, color, and self-illumination color. Scene cut animation includes, but is not limited to, looping, animation type, cut color and transparency, delay, initial height, end height, duration, and the targeted mesh renderer. Scene explosion animation includes, but is not limited to, the targeted mesh renderer, delay, explosion type, looping, number of loops, loop delay, reverse capability, reverse duration, and reverse delay.
[0084] Through such a setting, this solution can encapsulate all elements in the scene and obtain the scene file, so that the Web side can display the 3D effect synchronously, making the display effect better.
[0085] In this embodiment, optionally, the attribute information of the 3D program on the Web side is read, and target attribute information is generated based on the attribute information, including: reading the attribute information of the 3D program on the Web side, and identifying whether the attribute information is rendering information included in the Unity3D engine; if so, generating target attribute information based on the attribute information; if not, creating new attributes corresponding to the 3D program on the Web side, and assigning attributes to the new attributes to generate target attribute information.
[0086] The 3D program may be obtained through ThreeJS. The rendering information may be the rendering information included in the Unity3D engine. The newly added attribute may be attribute information not included in the rendering information included in the Unity3D engine. The attribute assignment may be the assignment of a parameter of the newly created attribute.
[0087] For example, in this embodiment, the attribute information of the 3D program on the Web side can be read, and it is recognized that there is a target point information in the attribute information of the 3D program on the Web side, while the rendering information included in the Unity3D engine does not have this target point information. It is necessary to construct the target point information corresponding to the 3D program on the Web side, so that the effect you want to express is the same as the effect displayed on the web side.
[0088] In this embodiment, the publishing end can read the attribute information of the 3D program on the Web end and identify whether the attribute information is the rendering information included in the Unity3D engine; if the identified attribute information is the rendering information included in the Unity3D engine, target attribute information is generated based on the attribute information; if the identified attribute information is not the rendering information included in the Unity3D engine, new attributes corresponding to the 3D program on the Web end are created, and attribute values are assigned to the new attributes to generate target attribute information.
[0089] Through such a setting, this solution identifies whether the attribute information is the rendering information included in the Unity3D engine, and reconstructs the attribute information that is not included, so that the scene rendering on both ends is consistent, making the desired effect and the effect displayed on the web end the same.
[0090] In this embodiment, optionally, the method further includes: encapsulating material information of all target objects to obtain a resource file; and encapsulating texture information of all target objects to obtain a texture file.
[0091] Material information can be understood as material ball information, which can be the material information of all target objects referenced in the scene. Each target object has material ball information. For example, the target object is a building, which can be divided into many layers. Each device on each layer is a separate model, and each model requires its own material ball. The resource file can be understood as a Json file that encapsulates the material information of all target objects. The texture information can be the texture information of all target objects referenced in the scene. The texture file can be understood as a Json file that encapsulates the texture information of all target objects.
[0092] In this embodiment, based on the scene element information being read, the texture files can be packaged into a JSON file library, with the textures having unique codes; the material ball files can be packaged into a JSON file library, with the material balls having unique codes. References to models in the scene can be packaged into a list and stored in the basic information. The model's referenced material ball and the texture referenced by the material ball both have unique codes for the material ball or the texture.
[0093] In this embodiment, the publishing end may encapsulate the material information of all target objects to obtain a resource file; and encapsulate the texture information of all target objects to obtain a texture file.
[0094] This solution ensures the uniqueness of materials and textures by obtaining resource files and texture files through such settings.
[0095] In this embodiment, the material information of all target objects is optionally encapsulated to obtain a resource file, including: identifying whether the material information of all target objects includes uploaded material information; if uploaded material information exists, constructing material reference information between the uploaded material information and the uploaded material information; and encapsulating the non-uploaded material information and the material reference information to obtain a resource file.
[0096] Uploaded material information can be understood as the material information of the target object that has been uploaded to the server. Material reference information can be obtained by constructing a reference between the target object's material information and the uploaded material information. The resource file can be understood as a JSON file that encapsulates the unuploaded material information and the material reference information.
[0097] In this embodiment, the publishing end can identify whether the material information of all target objects has uploaded material information; if uploaded material information exists, material reference information between the target object and the uploaded material information is constructed; the material information that has not been uploaded and the material reference information are encapsulated to obtain a resource file.
[0098] Through such a setting, this solution can effectively avoid a large number of file duplications, reduce file size, and upload them to the server quickly, saving time and being convenient and fast.
[0099] In this embodiment, optionally, the texture information of all target objects is encapsulated to obtain a texture file, including: identifying whether the texture information of all target objects has uploaded texture information; if uploaded texture information exists, constructing texture reference information between the texture information and the uploaded texture information; and encapsulating the texture information that has not been uploaded and the texture reference information to obtain a texture file.
[0100] The uploaded texture information can be understood as the texture information of the target object that has been uploaded to the server. Texture reference information can be constructed by constructing reference information between the target object and the uploaded texture information. The texture file can be understood as a JSON file that encapsulates the unuploaded material information and material reference information. In addition, in this embodiment, the texture files in the scene can also be encoded in the webp format.
[0101] In this embodiment, the publishing end can identify whether there is uploaded texture information for all target objects; if there is uploaded texture information, texture reference information between the target object and the uploaded texture information is constructed, and the unuploaded texture information and the texture reference information are encapsulated to obtain a texture file.
[0102] Through such a setting, this solution can effectively avoid a large number of file duplications, reduce file size, and upload them to the server quickly, saving time and being convenient and fast.
[0103] In this embodiment, when uploading scene files, you can check the options of model and texture, click Upload to CDN server, and the texture files in the scene can be automatically encoded into webp format. The upload panel will display the progress of each resource file. After all resource files are uploaded, the upload success panel will pop up. You can click Browser Preview in the status bar on the right to view it in the browser.
[0104] Example 3
[0105] Figure 3 This is a schematic diagram of the structure of a Web-side 3D effect synchronization device based on Unity3D according to the third embodiment of the present invention. The device can execute the Web-side 3D effect synchronization method based on Unity3D provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. The device is configured at the publishing end, which is configured with a Unity3D engine; the publishing end is connected to the server end, which is connected to the Web end; Figure 3 As shown, the device includes:
[0106] The model importing module 310 is used to import the 3D model of the target object into the Unity3D engine to render the 3D model.
[0107] The scene information determination module 320 is used to determine the scene information for rendering the three-dimensional model according to the attribute information adapted to the 3D program on the Web side.
[0108] The scene file obtaining module 330 is configured to encapsulate the scene information to obtain a scene file.
[0109] The scene file uploading module 340 is used to upload the scene file to the server, so that the server can respond to the access operation of the Web terminal and transmit the scene file to the Web terminal for 3D effect display.
[0110] Optionally, the scene information determination module 320 includes:
[0111] a target attribute information generating unit, configured to read attribute information of a 3D program on a Web side and generate target attribute information based on the attribute information;
[0112] a scene information obtaining unit, configured to render the three-dimensional model according to the target attribute information to obtain scene information;
[0113] Optionally, the scene information includes: one or more information of a camera, lighting, ambient light, shadow, reflection, and camera focus in the scene.
[0114] Optionally, the target attribute information generating unit is specifically configured to:
[0115] Reading attribute information of the 3D program on the Web side, and identifying whether the attribute information is rendering information included in the Unity3D engine;
[0116] If so, generating target attribute information based on the attribute information;
[0117] If not, a new attribute corresponding to the 3D program on the Web side is created, and attribute values are assigned to the new attribute to generate target attribute information.
[0118] Optionally, the device further includes:
[0119] The encapsulation module is used to encapsulate the material information of all target objects to obtain a resource file; and to encapsulate the texture information of all target objects to obtain a texture file.
[0120] Optionally, the encapsulation module is specifically used to:
[0121] Identify whether the material information of all target objects has been uploaded;
[0122] If there is uploaded material information, then construct material reference information between the uploaded material information;
[0123] The material information that has not been uploaded and the material reference information are packaged to obtain a resource file.
[0124] Optionally, the encapsulation module is specifically used to:
[0125] Identify whether the texture information of all target objects has been uploaded;
[0126] If there is already uploaded image information, then construct image reference information between the uploaded image information and the image information;
[0127] The unuploaded texture information and the texture reference information are packaged to obtain a texture file.
[0128] A Web-side 3D effect synchronization device based on Unity3D provided in an embodiment of the present invention can execute a Web-side 3D effect synchronization method based on Unity3D provided in any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
[0129] Example 4
[0130] Figure 4 is a structural diagram of an electronic device provided according to embodiment four of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0131] like Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0132] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0133] The processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors that run machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the web-side 3D effect synchronization method based on Unity3D.
[0134] In some embodiments, the Web-side 3D effect synchronization method based on Unity3D can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the Web-side 3D effect synchronization method based on Unity3D described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to execute the Web-side 3D effect synchronization method based on Unity3D by any other appropriate means (for example, by means of firmware).
[0135] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0136] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0137] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0138] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0139] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0140] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0141] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.
[0142] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A method for synchronizing 3D effects on a Web device based on Unity3D, characterized in that: The method is executed by a publishing end, which is configured with a Unity3D engine; the publishing end is connected to a server, which is connected to a Web end; the method includes: Importing the 3D model of the target object into the Unity3D engine to render the 3D model; Determining scene information for rendering the three-dimensional model based on attribute information compatible with a 3D program on the web side, wherein the attribute information includes shadow, light, camera, and camera focus information; and the scene information includes one or more of the following: camera, light, ambient light, shadow, reflection, and camera focus in the scene; Encapsulating the scene information to obtain a scene file; Uploading the scene file to the server, so that the server responds to the access operation of the Web terminal and transmits it to the Web terminal for 3D effect display; The material information of all target objects is encapsulated to obtain a resource file; and the texture information of all target objects is encapsulated to obtain a texture file.
2. The method according to claim 1, characterized in that Determining scene information for rendering the three-dimensional model according to attribute information compatible with the 3D program on the web side includes: Reading attribute information of the 3D program on the Web side, and generating target attribute information based on the attribute information; Rendering the three-dimensional model according to the target attribute information to obtain scene information; The scene information is encapsulated to obtain a scene file.
3. The method according to claim 2, characterized in that The scene information includes: one or more information of the camera, light, ambient light, shadow, reflection and camera focus in the scene.
4. The method according to claim 2, characterized in that Reading the attribute information of the 3D program on the Web side and generating target attribute information based on the attribute information includes: Reading attribute information of the 3D program on the Web side, and identifying whether the attribute information is rendering information included in the Unity3D engine; If so, generating target attribute information based on the attribute information; If not, a new attribute corresponding to the 3D program on the Web side is created, and attribute values are assigned to the new attribute to generate target attribute information.
5. The method according to claim 1, wherein Encapsulate the material information of all target objects to obtain resource files, including: Identify whether the material information of all target objects has been uploaded; If there is uploaded material information, then construct material reference information between the uploaded material information; The material information that has not been uploaded and the material reference information are packaged to obtain a resource file.
6. The method according to claim 1, characterized in that Encapsulate the texture information of all target objects to obtain the texture file, including: Identify whether the texture information of all target objects has been uploaded; If there is already uploaded image information, then construct image reference information between the uploaded image information and the image information; The unuploaded texture information and the texture reference information are packaged to obtain a texture file.
7. A Web-side 3D effect synchronization device based on Unity3D, characterized in that: The device is configured at a publishing end, and the publishing end is configured with a Unity3D engine; The publishing end is connected to the server end, and the server end is connected to the Web end; the device includes: A model import module, used to import the 3D model of the target object into the Unity3D engine to render the 3D model; A scene information determination module, configured to determine scene information for rendering the three-dimensional model according to attribute information adapted to the 3D program on the web side; A scene file obtaining module, configured to encapsulate the scene information to obtain a scene file; wherein the attribute information includes shadow, light, camera, and camera focus information; and the scene information includes one or more information of the camera, light, ambient light, shadow, reflection, and camera focus in the scene; A scene file uploading module is used to upload the scene file to the server, so that the server can respond to the access operation of the Web terminal and transmit it to the Web terminal for 3D effect display; The encapsulation module is used to encapsulate the material information of all target objects to obtain a resource file; and to encapsulate the texture information of all target objects to obtain a texture file.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the Unity3D-based Web-side 3D effect synchronization method described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the Web-side 3D effect synchronization method based on Unity3D according to any one of claims 1 to 6 when executed.
Citation Information
Patent Citations
Rendering method, device and equipment for model shadow in WebGL, equipment and medium
CN114022647A
Water gate three-dimensional simulation system construction method based on Unity and WebRTC components
CN114386249A