A method and system for visual editing of 3D models based on ThreeJS

By using a 3D model visualization and editing method based on ThreeJS, combined with Vue 3 and Element-plus, we have realized the preview and editing of 3D models, which solves the problems of high development difficulty and low efficiency in traditional methods, and provides efficient 3D model display and interactive functions.

CN118331561BActive Publication Date: 2024-11-22THREE GORGES HI TECH INFORMATION TECH CO LTD

Patent Information

Application Number
CN202410472429.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-19
Publication Date
2024-11-22
Estimated Expiration
2044-04-19

AI Technical Summary

Technical Problem

Existing technologies are ineffective in achieving 3D display and interaction using traditional methods. They are difficult to develop and inefficient. Manually coding with frameworks such as Three.js is costly to learn and difficult to debug.

Method used

This paper provides a method for visual editing of 3D models based on ThreeJS. By creating a visual editing component based on Vue 3, integrating UI components from Element-plus and a rendering container from Three.js, a visual interface is built and user interaction is received. Three.js is called to respond, generate 3D rendering effects, and generate code files.

Benefits of technology

It enables previewing and editing of 3D models, reducing development difficulty and improving development efficiency. Users do not need to manually code, and it supports model uploading and real-time rendering. The generated code can be integrated into front-end projects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118331561B_ABST
    Figure CN118331561B_ABST
Patent Text Reader

Abstract

The present invention provides a method and system for visual editing of 3D models based on ThreeJS, comprising the following steps: creating a visual editing component based on Vue 3; integrating the UI component of Element-plus and the rendering container of Three.js into the visual editing component; constructing a visual interface based on the UI component library of Element-plus, wherein the visual interface is divided into a list display area, a model display area and an attribute configuration area; receiving interactive operations of users on the visual interface, and calling Three.js to respond to the interactive operations to configure the three-dimensional rendering effect of the model, and previewing the configured three-dimensional rendering effect; generating a code file of the rendered three-dimensional model according to the code generation operation of the user. The present invention is used for previewing and editing three-dimensional models, and performing real-time rendering of various configurations and operations of the three-dimensional model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of visualization technology, and in particular to a method and system for visual editing of 3D models based on ThreeJS. Background Art

[0002] As the pace of enterprise informatization gradually accelerates, we find that the demand for large-screen visualization, three-dimensional display and interaction is growing. At present, many application systems still use more traditional methods to implement these functions, such as using image stickers or chart displays. In addition, some systems use frameworks such as Three.js and manually code to implement three-dimensional display and interaction functions. Although the use of image stickers or chart displays can meet basic visualization needs, the effect is often unsatisfactory, and it is difficult to achieve a vivid, vivid, and immersive experience. The learning cost of manual coding using frameworks such as Three.js is high and the efficiency is low. At the same time, it is difficult to develop and debug.

[0003] Therefore, the present invention provides a method and system for visual editing of 3D models based on ThreeJS. Summary of the invention

[0004] The present invention provides a method for visual editing of 3D models based on ThreeJS, which is developed using vue3, Element-plus, and Three.js, and realizes the functions of user interaction and real-time visual editing. At the same time, the edited effect can be generated into code with one click and provided to developers for integration into the project, thereby improving the efficiency of development.

[0005] In one aspect, the present invention provides a method for visually editing a 3D model based on Three.js, comprising the following steps:

[0006] Create a visual editing component based on Vue 3; integrate Element-plus's UI components and Three.js's rendering container into the visual editing component;

[0007] A visualization interface is built based on the UI component library of Element-plus, and the visualization interface is divided into a list display area, a model display area, and an attribute configuration area;

[0008] Receive user interaction on the visualization interface and call Three.js to respond to the interaction to configure the 3D rendering effect of the model and preview the configured 3D rendering effect;

[0009] Generates a code file for the rendered 3D model based on the user's code generation operation.

[0010] In an practicable manner, the step of receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation specifically includes:

[0011] receiving an interactive operation of a user dragging a display model in the list display area to the model display area; wherein,

[0012] The display model is displayed in an image format and is packaged into corresponding components; the display model includes a built-in model and an uploaded model;

[0013] Determine whether the currently displayed model is a built-in model;

[0014] If the current display model is a built-in model, the object creation mode of Three.js is called to create the corresponding 3D model, and the 3D model is displayed in the model display area;

[0015] If the currently displayed model is an uploaded model, the uploaded model file is loaded based on the loader. After loading is completed, the corresponding 3D model is displayed and a controller is constructed to realize the control of the created 3D model.

[0016] In an practicable manner, the step of receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation also includes:

[0017] Receive the parameter modification operation of the user in the attribute configuration area; according to the parameter modification operation, call the corresponding scene construction tool of Three.js to render the 3D model, and display the rendering effect in real time in the model display area; wherein,

[0018] The property configuration area is provided with a plurality of interactive elements for modifying the three-dimensional model parameters.

[0019] In an practicable manner, the step of receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation also includes:

[0020] Receive the user's animation setting operation in the property configuration area;

[0021] If the current 3D model is a built-in model, the animation effect in the gsap animation library is called to create the animation effect required by the user;

[0022] If the current 3D model is an uploaded model, based on the built-in animation effect of the current 3D model, the animation playback tool of Three.js is called to play the animation in the 3D model.

[0023] In an practicable manner, the step of generating a code file of the rendered three-dimensional model according to the user's code generation operation specifically includes:

[0024] Receive the user's code generation operation in the property configuration area, call the Node.js data writing tool, write the configured code into the vue file, and generate a vue component file.

[0025] In an practicable manner, the parameter modification operation includes selection of a rendering mode;

[0026] The step of receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation also includes:

[0027] Receive the rendering scene selected by the user, and determine the selection range of each configuration parameter according to the rendering mode library of the selected rendering scene; wherein,

[0028] The rendering mode library has a plurality of rendering scenes of different styles preset, each rendering scene corresponds to a different selection range of configuration parameters;

[0029] Determine multiple sets of candidate configuration parameter sets based on historical behavior information of the current user;

[0030] Sort the candidate configuration parameter sets according to the hardware configuration data of the current user, obtain a sorting result list, and feed it back to the user;

[0031] Receive the configuration parameter set selected by the user, call the corresponding scene building tool of Three.js, and automatically render the three-dimensional module according to the selected configuration parameter set.

[0032] In an practicable manner, the step of sorting the candidate configuration parameter sets according to the hardware configuration data of the current user specifically includes:

[0033] Obtain the hardware configuration information, temperature value and power consumption value of the current user; the hardware includes CPU, GPU, RAM and memory;

[0034] The comprehensive score of the hardware is calculated based on the hardware configuration information, temperature value, and power consumption value;

[0035] Compare the performance threshold of each rendering parameter set with the comprehensive score of the hardware, and take the rendering parameter set with a value less than the comprehensive score as the target to be selected;

[0036] Sort multiple targets to be selected in descending order to obtain a sorted result list.

[0037] On the other hand, the present invention also provides a system for visual editing of 3D models based on ThreeJS, including a component creation module, an interface construction module, an interaction module and a code generation module, wherein:

[0038] The component creation module is used to create a visual editing component based on Vue 3; and integrate the UI component of Element-plus and the rendering container of Three.js into the visual editing component;

[0039] The interface construction module is used to construct a visual interface based on the UI component library of ElementElement-plus, and the visual interface is divided into a list display area, a model display area and an attribute configuration area;

[0040] The interactive module is used to receive the user's interactive operation on the display interface, and call the corresponding module of Three.js to respond to the interactive operation, so as to configure the three-dimensional effect of the model and preview the configured three-dimensional effect;

[0041] The code generation module is used to generate a code file according to the configured three-dimensional effect.

[0042] In an practicable manner, the interaction module is specifically used to:

[0043] receiving an interactive operation of a user dragging a display model in the list display area to the model display area; wherein,

[0044] The display model is displayed in an image format and is packaged into corresponding components; the display model includes a built-in model and an uploaded model;

[0045] Determine whether the currently displayed model is a built-in model;

[0046] If the current display model is a built-in model, the object creation mode of Three.js is called to create the corresponding 3D model, and the 3D model is displayed in the model display area;

[0047] If the currently displayed model is an uploaded model, the uploaded model file is loaded based on the loader. After loading is completed, the corresponding 3D model is displayed and a controller is constructed to realize the control of the created 3D model.

[0048] In an practicable manner, the interaction module is further used to: receive the user's interactive operation on the visual interface, and the step of calling Three.js to respond to the interactive operation also includes:

[0049] Receive the parameter modification operation of the user in the attribute configuration area; according to the parameter modification operation, call the corresponding scene construction tool of Three.js to render the 3D model, and display the rendering effect in real time in the model display area; wherein,

[0050] The property configuration area is provided with a plurality of interactive elements for modifying the three-dimensional model parameters.

[0051] The beneficial effects that can be achieved by the present invention are as follows: the present application realizes the preview and editing of the three-dimensional model, and various configurations and operations of the model can be rendered in real time, and the user does not need to learn Three.js to manually encode, which greatly reduces the difficulty of development and can be debugged very conveniently. In addition, the present application has the function of generating code, and can easily generate vue code files. After the generated files are integrated into the front-end project, the functions of three-dimensional model display and interaction can be obtained, which improves the efficiency of development.

[0052] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.

[0053] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0055] Figure 1 It is a flow chart of a method for visual editing of 3D models based on ThreeJS in Embodiment 1 of the present invention;

[0056] Figure 2 This is a flow chart of responding to an interactive operation in Embodiment 1 of the present invention;

[0057] Figure 3 This is a flow chart of a system for visually editing 3D models based on ThreeJS in Example 1 of the present invention. DETAILED DESCRIPTION

[0058] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0059] This embodiment 1 provides a method for visual editing of 3D models based on ThreeJS, see Figure 1 , the method comprises the following steps:

[0060] Create a visual editing component based on Vue 3; integrate Element-plus's UI components and Three.js's rendering container into the visual editing component;

[0061] A visualization interface is built based on the UI component library of Element-plus, and the visualization interface is divided into a list display area, a model display area, and an attribute configuration area;

[0062] Receive user interaction on the visualization interface and call Three.js to respond to the interaction to configure the 3D rendering effect of the model and preview the configured 3D rendering effect;

[0063] Generates a code file for the rendered 3D model based on the user's code generation operation.

[0064] The working principle of the above technical solution is:

[0065] This application uses the Vue3 framework, which is lightweight and efficient, and can easily implement various interactive functions. Then create a visual editing component that integrates the UI component of Element-plus and the rendering container of Three.js, so that users can change the shape, color and other properties of the three-dimensional model in an interactive way. Then build a visual interface based on Element-plus. In traditional technology, UI components and rendering containers, the traditional method can use UI components as a visual editing period, but for rendering containers, it is an HTML element. If the content is not an editable attribute, editable operations cannot be performed, and the present invention combines UI components and rendering containers to realize the editable function of rendering.

[0066] The visualization interface is divided into Figure 3There are three areas: list display area, model display area and property configuration area. Users can edit the model freely in these areas, such as changing the shape, size, material, etc. of the model. Vue3 is used to receive the user's interactive operations on the display interface, such as clicking, dragging, etc., and the corresponding modules are called to configure the 3D effect of the model to meet the various needs of users. After the configuration is completed, the previewed 3D model can be seen. For example, when the user operates in the visual interface composed of ElementElement-plus, such as moving the slider, the input event of the slider will be triggered, Vue 3 will capture this event, and the event processing function in the Vue component will be called. This function will receive the new value of the slider. In the event processing function, the method of the Three.js component (such as updateModel) is called to pass in the new value, so that the Three.js component knows that the scale of the model needs to be updated. After receiving the update request, the Three.js component will modify the scale property of the model and call the render method of the renderer to re-render the scene, so that the user can see the changes in the model. Finally, when the user determines the 3D effect of the model, the corresponding code file is generated according to this information. This code file can be directly applied to the model and can also be quickly reused by other users or teams. In this way, users can save a lot of programming time and focus more on product design and optimization.

[0067] Beneficial effects of the above technical solution: This application realizes the preview and editing of three-dimensional models, and various configurations and operations of the model can be rendered in real time. Users do not need to learn Three.js to manually code, which greatly reduces the difficulty of development and can be debugged very conveniently. In addition, this application has the function of generating code, which can easily generate vue code files. After the generated files are integrated into the front-end project, the functions of three-dimensional model display and interaction can be achieved, which improves the efficiency of development.

[0068] Based on Example 1, the steps of receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation specifically include:

[0069] receiving an interactive operation of a user dragging a display model in the list display area to the model display area; wherein,

[0070] The display model is displayed in image format and is encapsulated into corresponding components; the display model includes built-in models and uploaded models;

[0071] Determine whether the currently displayed model is a built-in model;

[0072] If the current display model is a built-in model, the object creation mode of Three.js is called to create the corresponding 3D model, and the 3D model is displayed in the model display area;

[0073] If the currently displayed model is an uploaded model, the uploaded model file is loaded based on the loader. After loading is completed, the corresponding 3D model is displayed and a controller is constructed to realize the control of the created 3D model.

[0074] The working principle of the above technical solution is as follows: Figure 2 and Figure 3 As shown, the list display area of ​​the present application has built-in commonly used geometric bodies, such as spheres, cubes, polygons, torus, etc. And commonly used models, such as people, animals, the earth, buildings, etc. Among them, commonly used geometric bodies and commonly used models are displayed in image format (picture and svg format) and encapsulated into corresponding components. The component draggable function is used to give the component the ability to be dragged. The list display area also supports users to upload custom model files (drawn model files), and supports common model files with suffixes such as .glb, .gltf, .obj, .fbx, etc. The model display area can display three-dimensional models and the rendering effect of three-dimensional models. When receiving the interactive operation of the user dragging the display model in the list display area to the model display area, that is, the user presses the mouse to drag the model in the list display area to the model display area, it will first determine whether the current display model is a built-in model; if the current display model is a built-in model, the new THREE method will be called to create the corresponding 3D model and display the 3D model in the model display area; for example: new THREE.BoxGeometry (cube), newTHREE.SphereGeometry (sphere), new THREE.TorusGeometry (ring), etc. If the current display model is an uploaded model, the corresponding loader will be introduced to load the uploaded model file, such as the glft model file, and the gltfLoader.load() method of newGLTFLoader() is used to load the uploaded model file. After loading, the corresponding 3D model is displayed, and the controller is created using the new OrbitControls() method, and the mouse can control the model. In the model display area, users can click on the model to interact, drag the mouse to move and rotate the model, and scroll the pulley to scale the model.

[0075] Beneficial effects of the above technical solution: This application has built-in commonly used models and supports manual uploading of models to meet the needs of different users. And when the model is manually uploaded, it will automatically load the model and set the controller to control the model. Users do not need to learn Three.js to manually code, which greatly reduces the difficulty of development.

[0076] Based on Example 1, the step of receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation also includes:

[0077] Receive the user's parameter modification operation in the property configuration area; according to the parameter modification operation, call the corresponding scene construction tool of Three.js to render the 3D model, and display the rendering effect in real time in the model display area; wherein, the property configuration area is provided with a plurality of interactive elements for modifying the 3D model parameters.

[0078] The working principle of the above technical solution is as follows: Figure 3 As shown, the property configuration area of ​​the present application is provided with a plurality of interactive elements for modifying the parameters of the 3D model. When the user clicks on an interactive element, the present application will call the corresponding scene building tool of Three.js according to the parameter modification operation received from the user in the property configuration area, render and interact with the 3D model, and display the rendering effect in real time in the model display area.

[0079] See also Figure 3 The parameter modification operations in the property configuration area of ​​this application include but are not limited to basic information configuration operations, scene camera setting operations, model material selection operations, light source setting operations, auxiliary line setting operations and model operations. The property configuration area is developed based on ElementElement-plus and calls Three.js methods to process the 3D model properties.

[0080] When receiving the basic information configuration operation, the application will configure the basic information of the three-dimensional model displayed in the model display area, including but not limited to model naming, model background setting, and model export and preview. When setting the background for the model, you can set the color as the background, or you can choose the system's built-in background image, or upload a custom background image as the background. When the user chooses to use a color as the background, the new THREE.Color() method can be used to modify the background color; when the user chooses the system's built-in background image, or uploads a custom background image as the background, the new RGBELoader().load() method can be used to introduce the background image, and then the background of the three-dimensional model can be set to the background image. When exporting the configured model file, you can choose to export .glb, .gltf, .obj, .fbx and other formats. When exporting files, call the exporter.parse() method of new GLTFExporter() to export the configured three-dimensional model into the corresponding model file.

[0081] When receiving a scene camera setting operation, this application will set the scene's camera information according to the user's selection. The camera information includes the camera type and camera properties. Camera types include but are not limited to perspective cameras, orthographic cameras, etc. When the user selects a perspective camera, this application will call new THREE.PerspectiveCamera() to create a perspective camera. When the user selects an orthographic camera, it will call new THREE.OrthographicCamera() to create an orthographic camera. When setting camera properties, you can call camera.position to set the camera's position, angle, distance and other properties.

[0082] When receiving the model material selection operation, that is, when the user selects one or more parts of the model, you can set its material information, which includes material type (such as metal material, plastic material), material properties (color and transparency), map and texture. When setting the model's map and texture, you can use built-in pictures or upload custom pictures. Since there are many materials in Three.js, for example, new THREE.MeshBasicMaterial() can create basic mesh materials, new THREE.MeshPhysicalMaterial() can create physical mesh materials, and so on. Each material can set corresponding properties, such as sheen glossiness, roughness roughness, ior refractive index, color color, opacity transparency, etc. By modifying the value of each property, the model can look like metal or plastic, etc., which is more realistic. At the same time, you can call new THREE.TextureLoader() to set the model's map texture.

[0083] When receiving the light source setting operation, this application will set the scene light source information according to the user's selection. The scene light source information includes light sources and light source properties. Light sources include but are not limited to ambient light, parallel light, point light sources, and spotlights. Each light source has corresponding properties, such as light source position, light distance, light intensity, light source color, whether to turn on shadows, etc. When the user selects ambient light, this application will use new THREE.AmbientLight() to create ambient light; when the user selects parallel light, this application will use new THREE.DirectionalLight() to create parallel light; when the user selects point light, this application will use new THREE.PointLight() to create point light; when the user selects spotlight, this application will use new THREE.SpotLight() to create spotlight. Each light source can set corresponding properties, such as: position light source position, distance light distance, intensity light intensity, color light source color, and castShadow shadow, etc. By modifying the value of each property, the lighting effect of the model can be closer to the real situation in real life.

[0084] When receiving the auxiliary line setting operation, this application will set various auxiliary lines according to the user's selection. The auxiliary line setting operation includes the selection of auxiliary line types and the setting of auxiliary line attributes. Auxiliary line types include but are not limited to X, Y, Z coordinate axis auxiliary lines, grid auxiliary lines, camera auxiliary lines, and light source auxiliary lines. Auxiliary line attributes include setting whether the auxiliary lines are displayed, length, range, color, etc. When the user selects the X, Y, Z coordinate axis auxiliary lines, this application will call new THREE.AxesHelper() to add X, Y, Z coordinate axis auxiliary lines; when the user selects the grid auxiliary lines, this application will call newTHREE.GridHelper() to add grid auxiliary lines; when the user selects the camera auxiliary lines, this application will call newTHREE.CameraHelper() to add camera auxiliary lines; when the user selects the light source auxiliary lines, this application will call newTHREE.LightHelper() to add light source auxiliary lines. Each auxiliary line can set corresponding attributes, such as length, dir direction, range, color, etc. By modifying the value of the attribute, auxiliary debugging can be facilitated during model editing.

[0085] When receiving a model operation, this application will decompose and slice the model according to the user's choice, display and hide model parts, set the extent of model decomposition, whether the decomposed parts can be displayed and dragged, the direction of model sectioning, etc. Specifically, the decomposition and sectioning of the model can be achieved by setting the position and range of each part of the model, and setting the visible property can display and hide the corresponding model. Modifying the draggable of the model can set whether the model can be dragged.

[0086] The beneficial effects of the above technical solution are as follows: the present application can preview and edit three-dimensional models, and various configurations and operations of the model can be rendered in real time according to the user's interactive operations. Users do not need to learn Three.js to manually code, which greatly reduces the difficulty of development and allows for easy debugging.

[0087] Based on Example 1, the step of receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation also includes:

[0088] Receive the user's animation setting operation in the property configuration area;

[0089] If the current 3D model is a built-in model, the animation effect in the gsap animation library is called to create the animation effect required by the user;

[0090] If the current 3D model is an uploaded model, based on the built-in animation effect of the current 3D model, the animation playback tool of Three.js is called to play the animation in the 3D model.

[0091] The working principle of the above technical solution: When receiving an animation setting operation, the present application can set the animation type and animation properties of the three-dimensional model. The animation type is to set the model to rotate around a certain axis, or move in a certain direction, etc. The animation properties are to set the animation speed, animation mode, loop mode, etc. When responding to the animation setting operation, for the built-in model, the animation effects in the gsap animation library can be called to realize the movement, rotation and scaling of the model, etc., and the duration and x, y, z coordinates in gsap.to can be set to modify the animation speed, the ease property can be set to modify the animation mode, and the yoyo and repeat can be set to modify the animation loop mode, etc. For the uploaded model, if the model file has its own animation effect, you can call new THREE.AnimationMixer(gltf.scene).clipAction(gltf.animations[0]).play() to play the animation in the model.

[0092] The beneficial effects of the above technical solution: This application can set the animation effect of the three-dimensional model according to the user's needs, and render the animation effect in real time. The user does not need to learn Three.js to manually code, which greatly reduces the difficulty of development and can be debugged very conveniently.

[0093] On the basis of Example 1, according to the user's code generation operation, the steps of generating a code file of the rendered three-dimensional model specifically include:

[0094] Receive the code generation operation in the attribute configuration area, call the Node.js data writing tool, write the configured code into the vue file, and generate the vue component file

[0095] The working principle and beneficial effects of the above technical solution: This application has the function of generating code. When the user needs to generate code, this application will first generate a vue file corresponding to the preview effect; call the fs module of Node.js, write the configured code into the vue file, and generate a vue component file. The code consists of two parts, one is the configuration data in json format, and the other is the vue file. After the vue project is running, the vue file will read the configuration parameters of json, and after displaying the three-dimensional model, the configured parameters will be loaded to render the effect of the three-dimensional model configured by the user. After integrating the generated file into the front-end project, it can have the function of three-dimensional model display and interaction, which improves the development efficiency.

[0096] Based on Embodiment 1, the parameter modification operation includes selecting a rendering mode;

[0097] The step of receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation also includes:

[0098] Receive the rendering scene selected by the user, and determine the selection range of each configuration parameter according to the rendering mode library of the selected rendering scene; wherein,

[0099] The rendering mode library has a plurality of rendering scenes of different styles preset, each rendering scene corresponds to a different selection range of configuration parameters;

[0100] Determine multiple sets of candidate configuration parameter sets according to the historical selection data set and the behavior information of the current user; the historical selection data set is a collection of configuration parameter sets selected by other users in the current rendering mode;

[0101] Sort the candidate configuration parameter sets according to the hardware configuration data of the current user, obtain a sorting result list, and feed it back to the user;

[0102] Receive the configuration parameter set selected by the user, call the corresponding scene building tool of Three.js, and automatically render the three-dimensional module according to the selected configuration parameter set.

[0103] The working principle of the above technical solution is: when the user selects a rendering scene, that is, a rendering style, this application will automatically obtain the corresponding selection range of all configuration parameters from the rendering mode library. In order to better meet the needs of users, this application will perform data analysis on all configuration parameter selections of users in the past. By analyzing the user's behavior information, such as access, collection, etc., as well as the user's operating habits in different rendering scenes, multiple groups of configuration parameter values ​​that users may be interested in, that is, alternative configuration parameter sets, can be obtained. And the alternative configuration parameter sets are sorted according to the hardware configuration data of the current user to obtain a sorted result list, and it is fed back to the user: Since each user has different hardware devices, they may be more concerned about some specific configuration parameters. For example, for a user with a high-performance graphics card, he may be more concerned about texture quality and anti-aliasing settings. The system can sort the alternative configuration parameter sets according to the hardware devices owned by the user, such as GPU model, CPU architecture, etc. After the sorting is completed, the system will generate a list containing all alternative configuration parameter sets and feed it back to the user. After the user selects a set of configuration parameters, the corresponding scene building tool will be called based on the set to render the 3D module. During this process, the user can view the rendering results in real time and adjust the rendering quality.

[0104] The above technical solution has the following beneficial effects: This application can provide users with a suitable set of configuration parameters according to their needs, preferences and hardware configurations to meet the needs of different users.

[0105] On the basis of Example 1, the step of sorting the candidate configuration parameter sets according to the hardware configuration data of the current user specifically includes:

[0106] Obtain the hardware configuration information, temperature value and power consumption value of the current user; the hardware includes CPU, GPU, RAM and memory;

[0107] The comprehensive score of the hardware is calculated based on the hardware configuration information, temperature value, and power consumption value;

[0108] Match the performance threshold of each rendering parameter set with the comprehensive score of the hardware, and use the rendering parameter set that is not greater than the comprehensive score as the target to be selected;

[0109] Sort multiple targets to be selected in descending order to obtain a sorted result list.

[0110] The working principle of the above technical solution: When sorting the alternative configuration parameter sets according to the hardware configuration data of the current user, the present application first obtains the hardware configuration information, temperature value and power consumption value of the current user; the hardware includes CPU, GPU, RAM and memory, and the configuration information includes the model, number of cores and clock frequency of the CPU; the model and memory size of the GPU; the total memory size of the RAM; the hard disk type (SSD or HDD) and the available space. Then, according to the hardware configuration information, temperature value and power consumption value, the comprehensive score of the hardware is calculated. When calculating the comprehensive score of the hardware, an initial score can be assigned to each hardware component first. The initial score can be determined according to the specifications of the hardware. For example, the CPU can be calculated by the number of cores and the clock frequency. Then set a scoring range for each scoring indicator. For example, the initial score can be from 0 to 100, and the temperature and power consumption can be from 0 to 10. Then assign a weight to each scoring indicator to reflect their importance in the overall score. The sum of the weights should be equal to 1. For each scoring indicator, a single score is calculated based on its measured value and scoring range. For example, if the basic performance score is 80 and the score range is 0-100, then the single score is 80 / 100. Finally, multiply the single score of each indicator by the corresponding weight, and then add them together to get the comprehensive score. The performance threshold of each rendering parameter set is preset in advance to determine whether the current hardware can handle the current rendering parameter set; compare the performance threshold of each rendering parameter set with the comprehensive score of the hardware, and use the rendering parameter set that is less than the comprehensive score as the target to be selected; finally, sort the multiple targets to be selected in order from large to small to obtain a sorted result list.

[0111] The above technical solution and its beneficial effects: This application can find the rendering parameter set that best suits the current hardware conditions through matching and sorting, which can avoid unnecessary calculation and waste of resources, thereby improving rendering efficiency.

[0112] This embodiment 2 provides a system for visual editing of 3D models based on ThreeJS, including a component creation module, an interface construction module, an interaction module and a code generation module, wherein:

[0113] The component creation module is used to create visual editing components based on Vue 3; and integrate the UI components of Element-plus and the rendering container of Three.js into the visual editing components;

[0114] The interface construction module is used to build a visual interface based on the UI component library of ElementElement-plus. The visual interface is divided into a list display area, a model display area and an attribute configuration area;

[0115] The interactive module is used to receive the user's interactive operations on the display interface, and call the corresponding module of Three.js to respond to the interactive operations, so as to configure the 3D effect of the model and preview the configured 3D effect;

[0116] The code generation module is used to generate code files according to the configured three-dimensional effects.

[0117] Working principle of the above technical solution: This application creates a visual editing component through the component creation module, integrating the UI component of Element-plus and the rendering container of Three.js, so that users can change the shape, color and other attributes of the 3D model through interaction. Then, the visual interface is built based on Element-plus through the interface construction module. The visual interface is divided into the following Figure 3There are three areas: list display area, model display area and property configuration area. Users can freely edit the model in these areas, such as changing the shape, size, material, etc. of the model. The interactive module receives the user's interactive operations on the display interface, such as clicking, dragging, etc., and calls the corresponding module to configure the 3D effect of the model to meet the various needs of the user. After the configuration is completed, the previewed 3D model can be seen. For example, when the user operates in the visual interface composed of ElementElement-plus, such as moving the slider, the input event of the slider will be triggered, Vue 3 will capture this event, and the event processing function in the Vue component will be called. This function will receive the new value of the slider. In the event processing function, the method of the Three.js component (such as updateModel) is called to pass in the new value, so that the Three.js component knows that the scale of the model needs to be updated. After receiving the update request, the Three.js component will modify the scale property of the model and call the render method of the renderer to re-render the scene, so that the user can see the changes in the model. Finally, when the user determines the 3D effect of the model, the code generation module generates the corresponding code file based on this information. This code file can be directly applied to the model and can also be quickly reused by other users or teams. In this way, users can save a lot of programming time and focus more on product design and optimization.

[0118] Beneficial effects of the above technical solution: This application realizes the preview and editing of three-dimensional models, and various configurations and operations of the model can be rendered in real time. Users do not need to learn Three.js to manually code, which greatly reduces the difficulty of development and can be debugged very conveniently. In addition, this application has the function of generating code, which can easily generate vue code files. After the generated files are integrated into the front-end project, the functions of three-dimensional model display and interaction can be achieved, which improves the efficiency of development.

[0119] Based on Example 2, the interaction module is specifically used to: receive an interaction operation of a user dragging a display model in the list display area to the model display area; wherein,

[0120] The display model is displayed in image format and is encapsulated into corresponding components; the display model includes built-in models and uploaded models;

[0121] Determine whether the currently displayed model is a built-in model;

[0122] If the current display model is a built-in model, the object creation mode of Three.js is called to create the corresponding 3D model, and the 3D model is displayed in the model display area;

[0123] If the currently displayed model is an uploaded model, the uploaded model file is loaded based on the loader. After loading is completed, the corresponding 3D model is displayed and a controller is constructed to realize the control of the created 3D model.

[0124] Beneficial effects of the above technical solution: This application has built-in commonly used models and supports manual uploading of models to meet the needs of different users. And when the model is manually uploaded, it will automatically load the model and set the controller to control the model. Users do not need to learn Three.js to manually code, which greatly reduces the difficulty of development.

[0125] The interactive module is also used to: receive the user's interactive operation on the visual interface, and call Three.js to respond to the interactive operation. The steps also include:

[0126] Receive the parameter modification operation of the user in the attribute configuration area; according to the parameter modification operation, call the corresponding scene construction tool of Three.js to render the 3D model, and display the rendering effect in real time in the model display area; wherein,

[0127] The property configuration area has several interactive elements for modifying 3D model parameters.

[0128] The working principle of the above technical solution: A plurality of interactive elements for modifying the parameters of the 3D model are set in the property configuration area of ​​the present application. When the user clicks on an interactive element, the present application will call the corresponding scene building tool of Three.js according to the parameter modification operation received from the user in the property configuration area, render and interact with the 3D model, and display the rendering effect in real time in the model display area.

[0129] The beneficial effects of the above technical solution are as follows: the present application can preview and edit three-dimensional models, and various configurations and operations of the model can be rendered in real time according to the user's interactive operations. Users do not need to learn Three.js to manually code, which greatly reduces the difficulty of development and allows for easy debugging.

[0130] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A method for visual editing of 3D models based on ThreeJS, characterized in that: The following steps are involved: Create a visual editing component based on Vue 3; integrate Element-plus's UI components and Three.js's rendering container into the visual editing component; A visualization interface is built based on the UI component library of Element-plus, and the visualization interface is divided into a list display area, a model display area, and an attribute configuration area; Receive user interaction on the visualization interface and call Three.js to respond to the interaction to configure the 3D rendering effect of the model and preview the configured 3D rendering effect; Generate a code file of the rendered 3D model according to the user's code generation operation; The steps of receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation specifically include: receiving an interactive operation of a user dragging a display model in the list display area to the model display area; wherein, The display model is displayed in an image format and is packaged into corresponding components; the display model includes a built-in model and an uploaded model; Determine whether the currently displayed model is a built-in model; If the current display model is a built-in model, the object creation mode of Three.js is called to create the corresponding 3D model, and the 3D model is displayed in the model display area; If the currently displayed model is an uploaded model, the uploaded model file is loaded based on the loader. After loading is completed, the corresponding 3D model is displayed and a controller is constructed to realize the control of the created 3D model. The step of receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation also includes: Receive the parameter modification operation of the user in the attribute configuration area; according to the parameter modification operation, call the corresponding scene construction tool of Three.js to render the 3D model, and display the rendering effect in real time in the model display area; wherein, The attribute configuration area is provided with a plurality of interactive elements for modifying the three-dimensional model parameters; The parameter modification operation includes selection of a rendering mode; The step of receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation also includes: Receive the rendering scene selected by the user, and determine the selection range of each configuration parameter according to the rendering mode library of the selected rendering scene; wherein, The rendering mode library has a plurality of rendering scenes of different styles preset, each rendering scene corresponds to a different selection range of configuration parameters; Determine multiple sets of candidate configuration parameter sets based on historical behavior information of the current user; Sort the candidate configuration parameter sets according to the hardware configuration data of the current user, obtain a sorting result list, and feed it back to the user; Receive the configuration parameter set selected by the user, call the corresponding scene building tool of Three.js, and automatically render the three-dimensional module according to the selected configuration parameter set.

2. The method for visual editing of 3D models based on ThreeJS according to claim 1, characterized in that: The step of receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation also includes: Receive the user's animation setting operation in the property configuration area; If the current 3D model is a built-in model, the animation effect in the gsap animation library is called to create the animation effect required by the user; If the current 3D model is an uploaded model, based on the built-in animation effect of the current 3D model, the animation playback tool of Three.js is called to play the animation in the 3D model.

3. The method for visual editing of 3D models based on ThreeJS according to claim 1, characterized in that: The step of generating a code file of the rendered three-dimensional model according to the user's code generation operation specifically includes: Receive the user's code generation operation in the property configuration area, call the Node.js data writing tool, write the configured code into the vue file, and generate a vue component file.

4. The method for visual editing of 3D models based on ThreeJS as described in claim 1, characterized in that: The step of sorting the candidate configuration parameter sets according to the hardware configuration data of the current user specifically includes: Obtain the hardware configuration information, temperature value and power consumption value of the current user; the hardware includes CPU, GPU, RAM and memory; The comprehensive score of the hardware is calculated based on the hardware configuration information, temperature value, and power consumption value; Compare the performance thresholds of multiple sets of candidate configuration parameter sets with the comprehensive scores of the hardware, and use the candidate configuration parameter sets with a score smaller than the comprehensive score as targets to be selected; Sort multiple targets to be selected in descending order to obtain a sorted result list.

5. A 3D model visual editing system based on ThreeJS, characterized in that: It includes component creation module, interface construction module, interaction module and code generation module, among which: The component creation module is used to create a visual editing component based on Vue 3; and integrate the UI component of Element-plus and the rendering container of Three.js into the visual editing component; The interface construction module is used to construct a visual interface based on the UI component library of ElementElement-plus, and the visual interface is divided into a list display area, a model display area and an attribute configuration area; The interactive module is used to receive the user's interactive operation on the display interface, and call the corresponding module of Three.js to respond to the interactive operation, so as to configure the three-dimensional effect of the model and preview the configured three-dimensional effect; The code generation module is used to generate a code file according to the configured three-dimensional effect; The steps of the interaction module receiving the user's interactive operation on the visual interface and calling Three.js to respond to the interactive operation specifically include: receiving an interactive operation of a user dragging a display model in the list display area to the model display area; wherein, The display model is displayed in an image format and is packaged into corresponding components; the display model includes a built-in model and an uploaded model; Determine whether the currently displayed model is a built-in model; If the current display model is a built-in model, the object creation mode of Three.js is called to create the corresponding 3D model, and the 3D model is displayed in the model display area; If the currently displayed model is an uploaded model, the uploaded model file is loaded based on the loader. After loading is completed, the corresponding 3D model is displayed and a controller is constructed to realize the control of the created 3D model. The step of the interaction module receiving the user's interaction operation on the visual interface and calling Three.js to respond to the interaction operation also includes: Receive the parameter modification operation of the user in the attribute configuration area; according to the parameter modification operation, call the corresponding scene construction tool of Three.js to render the 3D model, and display the rendering effect in real time in the model display area; wherein, The attribute configuration area is provided with a plurality of interactive elements for modifying the three-dimensional model parameters; The parameter modification operation includes selection of a rendering mode; The step of the interaction module receiving the user's interaction operation on the visual interface and calling Three.js to respond to the interaction operation also includes: Receive the rendering scene selected by the user, and determine the selection range of each configuration parameter according to the rendering mode library of the selected rendering scene; wherein, The rendering mode library has a plurality of rendering scenes of different styles preset, each rendering scene corresponds to a different selection range of configuration parameters; Determine multiple sets of candidate configuration parameter sets based on historical behavior information of the current user; Sort the candidate configuration parameter sets according to the hardware configuration data of the current user, obtain a sorting result list, and feed it back to the user; Receive the configuration parameter set selected by the user, call the corresponding scene building tool of Three.js, and automatically render the three-dimensional module according to the selected configuration parameter set.

6. The system for visual editing of 3D models based on ThreeJS as claimed in claim 5, characterized in that: The interaction module is specifically used for: receiving an interactive operation of a user dragging a display model in the list display area to the model display area; wherein, The display model is displayed in an image format and is packaged into corresponding components; the display model includes a built-in model and an uploaded model; Determine whether the currently displayed model is a built-in model; If the current display model is a built-in model, the object creation mode of Three.js is called to create the corresponding 3D model, and the 3D model is displayed in the model display area; If the currently displayed model is an uploaded model, the uploaded model file is loaded based on the loader. After loading is completed, the corresponding 3D model is displayed and a controller is constructed to realize the control of the created 3D model.

7. The system for visual editing of 3D models based on ThreeJS as described in claim 6, characterized in that: The interactive module is also used to: receive the interactive operation of the user on the visual interface, and the step of calling Three.js to respond to the interactive operation also includes: Receive the parameter modification operation of the user in the attribute configuration area; according to the parameter modification operation, call the corresponding scene construction tool of Three.js to render the 3D model, and display the rendering effect in real time in the model display area; wherein, The property configuration area is provided with a plurality of interactive elements for modifying the three-dimensional model parameters.

Citation Information

Patent Citations

  • Three-dimensional image display method, electronic equipment and storage medium

    CN114926616A

  • Three-dimensional model processing method and device and electronic equipment

    CN115794063A

  • Graph display method and device, electronic equipment and readable storage medium

    CN116342799A

  • Dynamic form design method

    CN117032675A

  • Editing method of the three-dimensional shopping platform display interface for users

    EP2816521A1

Cited By

  • Three-dimensional scene automatic configuration method for industrial practical training

    CN122618179A

  • An Automatic 3D Scene Configuration Method for Industrial Training

    CN122618179B