Model rotation control method and device, equipment and storage medium
By using damping algorithms and WebSocket technology, the problem of rotation control synchronization between Unity and the web front-end was solved, achieving stable display of BIM models and realistic rotation effects, thus improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JIULING (JIANGSU) DIGITAL INTELLIGENT TECH CO LTD
- Filing Date
- 2021-04-29
- Publication Date
- 2026-05-05
AI Technical Summary
In existing technologies, when Unity is combined with a web front-end, the rotation controller cannot meet the requirements for realistic effects, resulting in unstable BIM model display and synchronization issues.
By employing a damping algorithm combined with WebSocket technology, and through nonlinear interpolation and a bidirectional communication protocol, damped rotation control and real-time synchronization of the BIM model are achieved.
It improves the display stability and user experience of BIM models, avoids repeated model jumps, and achieves real-time synchronization between the web front-end and the Unity client.
Smart Images

Figure CN115270018B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of model control, and more specifically to a model rotation control method, apparatus, device, and storage medium. Background Technology
[0002] Building Information Modeling (BIM) is a new tool in architecture, engineering, and civil engineering, used to represent computer-aided designs that are primarily three-dimensional, object-oriented, and architecturally relevant. BIM technology plays a crucial role in improving productivity, saving costs, and shortening construction periods through the digitization and integration of building data and information models. It possesses five key characteristics: visualization, coordination, simulation, optimization, and the ability to generate drawings.
[0003] Unity, also known as Unity 3D, is a comprehensive, multi-platform game development tool developed by Unity Technologies. It allows users to easily create interactive content such as 3D video games, architectural visualizations, and real-time 3D animations. It is a professional game engine that fully integrates graphics, sound, physics, and other functions.
[0004] Unity itself can respond to ordinary rotations based on linear interpolation between two points. Combined with the coordinates of the two points passed from the web frontend, a basic rotation controller can be implemented. However, as the need for rotation in conjunction with Unity on the web frontend increases, and more realistic effects are required, the basic rotation response method is no longer sufficient. While existing solutions, such as combining Unity with a web frontend to implement the aforementioned ordinary rotation controller, are widely used, they suffer from the following problems:
[0005] 1. Traditional Unity linear interpolation controllers cannot meet all the requirements of web controllers.
[0006] 2. When the web controller is frequently operated, the BIM model loaded by the Unity engine may exhibit a display effect of repeated horizontal jumping.
[0007] 3. The Web and Unity ends cannot achieve complete synchronization of rotation control; messages can only be sent to the Unity engine unilaterally via the Web. Summary of the Invention
[0008] To address the shortcomings of the existing technologies, this invention provides a model rotation control method, device, equipment, and storage medium. By utilizing a damping algorithm combined with WebSocket (full-duplex communication) technology, it achieves damped rotation control and real-time synchronization of BIM models loaded in Unity.
[0009] To achieve the above objectives, embodiments of the present invention provide a model rotation control method, the method comprising: acquiring a rotation end event and, in response to the rotation end event, calculating a rotation angle change value over each preset time interval within a predetermined time range; and controlling the model to be rotated to stop rotating in a nonlinearly damped manner within the predetermined time range based on the rotation angle change value.
[0010] The method further includes: sending the rotation angle change value to the display engine of the model to be rotated via a preset two-way communication protocol to drive the model to be rotated to stop rotating in a non-linear damping manner.
[0011] The preset bidirectional communication protocol is the WebSocket protocol.
[0012] The method further includes: obtaining the rotation end event includes obtaining a gesture event issued by the browser, wherein the gesture event is an event in which a press gesture is converted into a release gesture.
[0013] Calculating the rotation angle change value within a predetermined time range for each preset time interval further includes: obtaining the coordinate position of the movement gesture based on the user's previous operation behavior, and determining the rotation direction by the coordinate position of the raised gesture and the coordinate position of the movement gesture.
[0014] The calculation of the rotation angle change value within a predetermined time range for each preset time interval further includes: calculating the rotation angle change value within 2 seconds.
[0015] Calculating the rotation angle change value within a predetermined time range with respect to each preset time interval further includes: determining the time of the raised gesture as the initial time; calculating the initial angle based on the initial time; calculating the rotation angle corresponding to the rendering time of each frame after the initial time, wherein the difference between the rendering time of each frame and the initial time is less than or equal to the predetermined time; and calculating the rotation angle change value for each rotation angle within the predetermined time range based on the initial angle, the rotation angle corresponding to the rendering time of each frame, and the rotation direction.
[0016] An embodiment of the present invention also provides a model rotation control device, the device comprising: an acquisition module for acquiring a rotation end event; a calculation module for calculating a rotation angle change value within a predetermined time range with respect to each preset time interval in response to the rotation end event; and a control module for controlling the model to be rotated to stop rotating in a nonlinear damped manner within the predetermined time range according to the rotation angle change value.
[0017] Embodiments of the present invention also provide a computer device, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the computer program to implement the steps of the model rotation control method described in any of the above embodiments.
[0018] Embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the model rotation control method described in any of the above embodiments.
[0019] The advantages of this invention are that it utilizes a damping algorithm combined with WebSocket technology to achieve rotation control of the BIM model by the web controller based on nonlinear interpolation, thereby meeting the specific scenario requirements of the web controller. Simultaneously, by setting a constant rotation transformation time in the damping algorithm, it avoids the repeated horizontal jumping display effect of the BIM model when the web controller is frequently operated, thus improving the user's visual experience. Furthermore, the use of WebSocket technology solves the problem of information asynchrony between the web frontend and the Unity client, enabling real-time updates of angle transformations. Attached Figure Description
[0020] The technical solution and other beneficial effects of the present invention will become apparent from the following detailed description of specific embodiments of the invention, in conjunction with the accompanying drawings.
[0021] Figure 1 The first embodiment of the present invention provides a model rotation control method.
[0022] Figure 2 A schematic diagram of the model rotation control device provided in the second embodiment of the present invention is shown.
[0023] Figure 3 A schematic diagram of the structure of a computer device provided in the third embodiment of the present invention is shown. Detailed Implementation
[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0025] The terms "first," "second," "third," etc. (if present) in the specification, claims, and drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the objects described in this way can be used interchangeably where appropriate. In the description of this invention, "a plurality of" means two or more, unless otherwise expressly and specifically defined. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software, in one or more hardware circuits or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0026] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection, an electrical connection, or a connection that allows for communication; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0027] To make the objectives, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0028] Application Scenarios Overview
[0029] With the continuous development of internet technology, computer technology, and digital graphics processing technology, the cross-temporal and spatial display and human-computer interaction of 3D architectural models have become possible and are increasingly popular. For example, users can view and interact with 3D architectural models in a client's browser, such as through dragging, rotating, and scaling. The Unity engine, as a display engine, provides good rendering effects for 3D architectural models on the client side, resulting in clear and smooth visuals. Therefore, it is used in the rendering, display, and human-computer interaction of large-scale models. It should be understood that the terms "model," "3D model," and "3D architectural model" mentioned in this document all belong to Building Information Modeling (BIM). Other names that are substantially the same as BIM can also be considered BIM and should all be within the scope of protection of this invention.
[0030] Example 1
[0031] Figure 1The first embodiment of the present invention illustrates a model rotation control method. The model rotation control method provided in this embodiment, particularly the damped rotation control method for the model, can be applied to computer devices. The computer device can be an electronic device with installed drawing applications, such as a smartphone, tablet, laptop, desktop computer, or personal digital assistant; this embodiment does not limit the specific form of the computer device.
[0032] Furthermore, the damped rotation control method for a model provided in the first embodiment of the present invention can be executed by a model rotation control device as provided in the second embodiment. This device can be implemented as part or all of a computer device through software, hardware, or a combination of both. The execution subject of the following method embodiments will be described using a computer device as an example.
[0033] refer to Figure 1 The model rotation control method provided in the first embodiment of the present invention includes the following steps:
[0034] Step S10: Obtain the rotation end event and, in response to the rotation end event, calculate the rotation angle change value within a predetermined time range for each preset time interval;
[0035] Step S20: Based on the change value of the rotation angle, control the model to be rotated to stop rotating in a nonlinear damping manner within the predetermined time range.
[0036] Each step of the method described in this embodiment will be further described below.
[0037] In step S10, within the computer device, a building information model (BIM) can be loaded into a browser provided by the computer device using architectural software and then displayed on the computer device's display screen. For example, in this embodiment, the BIM model is loaded into a web application (e.g., a browser) using the Unity engine and then displayed on the computer device's screen. To improve the interaction efficiency between the web controller and the BIM model, communication can be performed between the Unity application and the web application using a bidirectional communication protocol. In some embodiments, the bidirectional communication protocol is the WebSocket protocol.
[0038] The WebSocket protocol is a new network protocol based on TCP (Transmission Control Protocol). It enables full-duplex communication between the browser and the server, allowing the server to proactively send information to the client. In other cases, the server can also act as a relay device between two clients to achieve real-time communication. The WebSocket protocol solves the shortcomings of HTTP's one-way communication. Many existing websites use Ajax polling to implement push technology. Polling involves the browser sending an HTTP request to the server at specific time intervals (e.g., every second), and the server returning the latest data to the client's browser. This traditional model has significant drawbacks: the browser needs to constantly send requests to the server, and HTTP requests may contain long headers, with only a small portion containing truly valid data, obviously wasting bandwidth and other resources. WebSocket simplifies data exchange between the client and server, allowing the server to proactively push data to the client. In the WebSocket API, the browser and server only need to complete a handshake once to establish a persistent connection and perform bidirectional data transmission, forming a fast channel for direct data exchange.
[0039] In a preferred embodiment, the BIM model resides in the Unity engine's desktop application. After the BIM model is loaded by Unity (i.e., automatically loaded upon opening the desktop application), the Unity desktop application connects to the web-based controller via a WebSocket server. Specifically, the Unity desktop application connects to the WebSocket server deployed in the Java backend through the same channel as the web application. Regarding the web-based controller, it loads on the web and connects to the BIM model loaded by Unity via the WebSocket server. After the BIM model is confirmed, its rotation can be controlled.
[0040] After the web client and the Unity client establish a communication connection via WebSocket, the web controller performs event listening to obtain the rotation end event. Obtaining the rotation end event includes obtaining gesture events issued by the browser, where the gesture event is the event where a pressed gesture is converted into a released gesture. In this embodiment, the damped inertial rotation effect implemented on the web client means that when the user stops operating the model's rotation, the rotation speed of the model to be rotated gradually decreases until the speed reaches zero and stops rotating. The damped inertial rotation effect on the web client can achieve a easing effect on the model's rotation. For example, when the user operates the model to perform rotation using the mouse in the browser, a pressed gesture indicates that the user is continuously operating the model's rotation, while a released gesture indicates that the user wants to terminate the rotation operation. The time of the released gesture is used as the start time of the damped rotation of the model.
[0041] Calculating the rotation angle change value within a predetermined time range for each preset time interval further includes: obtaining the coordinate position of the movement gesture based on the user's previous operation behavior, and determining the rotation direction by comparing the coordinate position of the raised gesture and the coordinate position of the movement gesture. Specifically, the final rotation direction of the model is determined by the user's previous operation behavior. Each time the model rotates, the controller can determine the direction using position information. Before obtaining the raised gesture, the controller also obtains the coordinate position of the movement gesture, and calculates the final rotation direction by comparing the two coordinate positions. For example, if the coordinates of the raised gesture position are X1, Y1 and the coordinates of the movement gesture position are X2, Y2, and the rotation center is set as the origin, the tangent angle is calculated. If the angle of the raised gesture position is less than the angle of the movement gesture position, the final rotation direction is determined to be counterclockwise; otherwise, it is clockwise.
[0042] Meanwhile, calculating the rotation angle change value within a predetermined time range for each preset time interval further includes the following process: determining the time of the raised gesture as the initial time; calculating the initial angle based on the initial time; calculating the rotation angle corresponding to the rendering time of each frame after the initial time, wherein the difference between the rendering time of each frame and the initial time is less than or equal to the predetermined time; and calculating the rotation angle change value for each rotation angle within the predetermined time range based on the initial angle, the rotation angle corresponding to the rendering time of each frame, and the rotation direction. Preferably, the predetermined time range is a 2-second variation time. Those skilled in the art can also set the predetermined time range (i.e., variation time) according to actual conditions to achieve the desired damped rotation effect. Since a constant 2-second variation time is set during the calculation process and the interpolated value inserted within this variation time is not constant, a nonlinear interpolation controller on the web side can be realized.
[0043] In this embodiment, when the total transformation time is set to 2 seconds, taking the time of the last lifting gesture as the initial time, denoted as the initial time X1, calculate the initial angle Y1. Each time a frame is rendered, bring in the time Xn (Xn < X1 + 2 seconds) and calculate the rotation angle Yn. Here, Xn refers to the time at the moment of each rendering. Generally, a browser renders 60 frames per second. Then, by calculating the difference between Yn and Y1, the rotation angle (i.e., the changing angle) for each time can be obtained. When the final rotation direction determined by the aforementioned method is counterclockwise, the changing angle is taken as a positive number; when the final rotation direction is clockwise, the changing angle is taken as a negative number. Thus, the damping rotation angle change value within 2 seconds can be obtained. Exemplarily, the above calculation can be performed through the following rotation angle damping calculation formula:
[0044] Yn = a + b * log(Xn)
[0045] Where a is taken as -1.72 and b is taken as 83.72. It can be understood that a and b are the preferred calibration values obtained based on simulation experiments. Those skilled in the art can also adjust these values according to actual needs to obtain the desired damping rotation effect.
[0046] In step S20, control the model to be ended in rotation to stop rotating in a non-linear damping manner within the predetermined time range according to the damping rotation angle change value calculated in step S10. Specifically, push the damping rotation angle change value calculated by the web controller to the BIM model loaded on the Unity side in real time through websocket to drive the BIM model to stop rotating in a non-linear damping manner. Therefore, by using the websocket technology, the effect of real-time update of angle transformation can be achieved between the web front end and the Unity side.
[0047] Example 2
[0048] Figure 2 Fig. shows a schematic structural diagram of a model rotation control device 100 provided by the second embodiment of the present invention. The device 100 includes: an acquisition module 10, configured to acquire a rotation end event; a calculation module 20, configured to calculate the rotation angle change value at each preset time interval within a predetermined time range in response to the rotation end event; and a control module 30, configured to control the model to be ended in rotation to stop rotating in a non-linear damping manner within the predetermined time range according to the rotation angle change value.
[0049] Meanwhile, it should be understood that the relevant features in the second embodiment and the first embodiment can be mutually referred to and borrowed from each other, and will not be elaborated here one by one.
[0050] Example 3
[0051] Figure 3A schematic diagram of a computer device 200 according to a third embodiment of the present invention is shown. The computer device includes a processor 310, a memory 320, a network interface 330, a display screen 340, and an input device 350 connected via a system bus 300. The processor 310 of the computer device 200 provides computing and control capabilities. The memory 320 of the computer device 200 includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface 330 of the computer device 200 is used for communication with external computer devices via a network connection. When the computer program is executed by the processor 310, it implements a model rotation control method. The display screen 340 of the computer device 200 can be a liquid crystal display screen or an electronic ink display screen. The input device 350 of the computer device 200 can be a touch layer covering the display screen 340, or buttons, a trackball, or a touchpad provided on the casing of the computer device 200, or an external keyboard, touchpad, or mouse, etc.
[0052] Those skilled in the art will understand that Figure 3 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0053] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program executable on the processor. When the processor executes the computer program, it performs the following steps: acquiring a rotation end event and calculating, in response to the rotation end event, a rotation angle change value over each preset time interval within a predetermined time range; and controlling a model to be rotated to stop rotating in a nonlinearly damped manner within the predetermined time range based on the rotation angle change value. Specific limitations and implementation methods of the above steps can be found in Embodiment 1 above, and will not be repeated here.
[0054] In another embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the following model rotation control method: acquiring a rotation end event and, in response to the rotation end event, calculating a rotation angle change value over each preset time interval within a predetermined time range; and controlling the model to be rotated to stop rotating in a nonlinearly damped manner within the predetermined time range based on the rotation angle change value.
[0055] For specific limitations and implementation methods of the above steps, please refer to Embodiment 1 above, which will not be repeated here.
[0056] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0057] The foregoing has provided a detailed description of a model rotation control method, apparatus, device, and storage medium provided by the embodiments of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the technical solutions and core ideas of the present invention. Those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A model rotation control method, characterized in that, The method includes: Obtain the rotation end event, which includes a gesture event sent by the browser, wherein the gesture event is an event in which a press gesture is converted into a release gesture; In response to the rotation end event, the rotation angle change value within a predetermined time range is calculated for each preset time interval; wherein, the time of the raised gesture is determined as the initial time, the initial angle is calculated based on the initial time, and the rotation angle damping calculation formula is used. The rotation angle corresponding to the rendering time of each frame after the initial time is calculated, and the change value of the rotation angle for each frame is obtained by calculating the difference between the rotation angle and the initial angle; a and b are calibration values obtained from simulation experiments, Xn refers to the rendering time of each frame, and Yn refers to the rotation angle; and Based on the change in rotation angle, the building information model to be rotated is controlled to stop rotating in a non-linear damping manner within the predetermined time range.
2. The model rotation control method as described in claim 1, characterized in that, The method further includes: The rotation angle change value is sent to the display engine of the building information model to be rotated through a preset two-way communication protocol, so as to drive the building information model to be rotated to stop rotating in a non-linear damping manner.
3. The model rotation control method as described in claim 2, characterized in that, The preset bidirectional communication protocol is the WebSocket protocol.
4. The model rotation control method as described in claim 1, characterized in that, Calculating the rotation angle change value within a predetermined time range for each preset time interval further includes: obtaining the coordinate position of the movement gesture based on the user's previous operation behavior, and determining the rotation direction by the coordinate position of the raised gesture and the coordinate position of the movement gesture.
5. The model rotation control method as described in claim 1, characterized in that, The calculation of the rotation angle change value within a predetermined time range for each preset time interval further includes: calculating the rotation angle change value within 2 seconds.
6. The model rotation control method as described in claim 4, characterized in that, The calculation of the rotation angle change value with each preset time interval within the predetermined time range further includes: The rotation angle change value for each rotation angle within the predetermined time range is calculated based on the initial angle, the rotation angle corresponding to the rendering time of each frame, and the rotation direction, wherein the difference between the rendering time of each frame and the initial time is less than or equal to the predetermined time.
7. A model rotation control device, characterized in that, The device includes: The acquisition module is used to acquire the rotation end event, which includes the gesture event sent by the browser, and the gesture event is the event of converting a press gesture into a release gesture; The calculation module is used to calculate the change in rotation angle over each preset time interval within a predetermined time range in response to the rotation end event; wherein, the time of the raised gesture is determined as the initial time, the initial angle is calculated based on the initial time, and the rotation angle damping calculation formula is used. The rotation angle corresponding to the rendering time of each frame after the initial time is calculated, and the change value of the rotation angle for each frame is obtained by calculating the difference between the rotation angle and the initial angle; a and b are calibration values obtained from simulation experiments, Xn refers to the rendering time of each frame, and Yn refers to the rotation angle; and The control module is used to control the building information model to be rotated to stop rotating in a non-linear damping manner within the predetermined time range according to the change value of the rotation angle.
8. A computer device, comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps in the model rotation control method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Building model display, data processing method, device, media, equipment and system
CN107506517A
Intel Real Sense-based automobile display application development method and system
CN107861714A